Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get raw data in uint16 format #17

Open
gustn6591 opened this issue Jul 19, 2023 · 1 comment
Open

How to get raw data in uint16 format #17

gustn6591 opened this issue Jul 19, 2023 · 1 comment

Comments

@gustn6591
Copy link

Hello, I managed to get a grayscale image of (480,640) through the code below.

cap_depth = cv2.VideoCapture("rtsp://admin:admin@192.168.1.10/depth", cv2.CAP_GSTREAMER)
while(True):
ret2, frame_depth = cap_depth.read()
cv2.namedWindow('kinova_depth', cv2.WINDOW_AUTOSIZE)
cv2.imshow('kinova_depth',frame_depth)
if cv2.waitKey(20) & 0xFF == ord('q'):
break
cap_depth.release()
cv2.destroyAllWindows()

However, the output image was in uint8 format ranging from 0 to 255, and accurate depth information could not be obtained.
I was able to get a value similar to uint16 through (pixel/255)*65535, but a lot of errors occurred because I had already brought the value of uint8.
I did a lot of searching and found several ways, but I didn't know the exact way to get depth data in uint16 format from realsense(D410) attached to gen3.
I know that using ros_rgbd.launch I can get the point cloud, so I'm pretty sure I can get uint16's information, but I don't know how.
I want to know how to get depth information from ros_kortex_vision repo or an example, so I leave a question.

Thank you

@felixmaisonneuve
Copy link
Contributor

Hi @gustn6591,

Depth stream is in 16bit encoding and we pass GRAY16_LE encoding to Gstreamer to get this point cloud.

else if (camera_type == "depth")
{
camera_type_ = CameraTypes::Depth;
image_encoding_ = sensor_msgs::image_encodings::TYPE_16UC1;
}

if (image_encoding_ == sensor_msgs::image_encodings::TYPE_16UC1)
{
gst_encoding = "GRAY16_LE";
}

The color stream however is in RGB8 encoding

else if (image_encoding_ == sensor_msgs::image_encodings::RGB8)
{
gst_encoding = "RGB";
}

if you launch the kinova_vision_rgbd.launch file, you will only have access to both color and depth stream, so make sure you are using the correct depth stream and not the color stream.

Best,
Felix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants