RoboDK Forum
Color snapshots unpredictably 4-channel RGBA or 3-channel RGB- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+ - - -论坛:RoboDK错误(//www.sinclairbody.com/forum/Forum-RoboDK-bugs)
+--- Thread: Color snapshots unpredictably 4-channel RGBA or 3-channel RGB (/Thread-Color-snapshots-unpredictably-4-channel-RGBA-or-3-channel-RGB)



Color snapshots unpredictably 4-channel RGBA or 3-channel RGB-hn-cso-06-08-2023

Code:
print(cam.setParam("Settings"))
# FOV=63.911 PixelSize=2.599117 Size=640x480 Snapshot=640x480 SHOW_LIMITS FOCAL_LENGTH=1.00 FAR_LENGTH=2800.00 BG_COLOR=#ffffff Persp WindowResize
bytes_img = RDK.Cam2D_Snapshot("", cam, "Color")
nparr = np.frombuffer(bytes_img, np.uint8)
img = cv2.imdecode(nparr, cv2.IMREAD_UNCHANGED)
print(img.shape)
# sometimes (480, 640, 4), sometimes (480, 640, 3)
What happens:Color cameras sometimes give 4-channel RGBA images, and sometimes 3-channel RGB images. I think it has to do with whether there are transparent objects in the scene but I'm not sure. Thesamecamera can give different image channels, it's not two different cameras.
What I expect to happen:Snapshots are either always 4-channel RGBA or always 3-channel RGB regardless of what happens to be in front of the camera.

(OS: macOS, RoboDK version: latest, just downloaded now and tried on currently available latest version)


RE: Color snapshots unpredictably 4-channel RGBA or 3-channel RGB-Albert-06-08-2023

图像生成的无袖长衫DK in this manner should not have an alpha channel. Did you see transparency with these images? Can you share an RDK file that allows us to reproduce this issue?

We could force it to always be RBG and not RGBA but it would penalize performance.