ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Saving jpeg depth image from /camera/depth/image on Kinect

asked 2012-08-22 04:11:18 -0500

Fer Nunez gravatar image

updated 2016-10-24 09:01:53 -0500

ngrennan gravatar image

Hello. When I try right clicking the image window, from image:=/camera/depth/image, to save the image on jpeg format I get on my folder a totally black picture. I know it works on RGB images and on image:=/camera/depth/image_rect_raw. So any idea to get the image on jpeg format from image:=/camera/depth/image cuz it's way better than image:=/camera/depth/image_rect_raw.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2012-08-22 04:49:16 -0500

joq gravatar image

Neither of those is an image in the JPEG sense. They are depth images.

If you want the RGB camera image, use one of these topics (or the rectified versions):

  • camera/rgb/image_mono
  • camera/rgb/image_color

See REP-0118 for details.

edit flag offensive delete link more
1

answered 2012-09-19 23:05:13 -0500

Luis Parra gravatar image

You can get a depth image suscribing to the ROS topic and using OpenCV to save the file

    void kinectWindow::getDepthImageFromKinect(sensor_msgs::Image image)
{    
    cv_bridge::CvImagePtr cv_ptr(new cv_bridge::CvImage);

    if (frameCounter==6) {
    char numstr[21]; // enough to hold all numbers up to 64-bits
    sprintf(numstr, "%d", fileCounter);
    std::string result = directory + name + numstr + ext;

    cv::imwrite(result, (cv_ptr->image)*10);
    frameCounter = 0;
    fileCounter++;
    } else {
    frameCounter++;
    }
}

Just initializate as string directory, name (filename), and desired extension (ext) and be sure to suscribe to the right topic... You can check how to suscribe to topics here

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-08-22 04:11:18 -0500

Seen: 3,494 times

Last updated: Sep 19 '12