Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Color snapshots unpredictably 4-channel RGBA or 3-channel RGB

#1
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)
#2
Images generated by RoboDK 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.




Users browsing this thread:
1 Guest(s)