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

Drivers for stereo camera

asked 2018-02-05 23:11:31 -0600

jake3991 gravatar image

I've purchased a cool stereo camera, very low cost and I'm hoping it works well. However there is a pretty big issue, I can't get it to play nice with ROS. It is a single board with two lenses and one USB cable.

Camera: https://www.amazon.com/gp/product/B00...

I've tried a couple ideas such as the opencv based video streamer, and even a driver written for this camera but so far no luck. Does anyone know of a good way to tackle this problem? I've tried looking for a sub address or something along those lines. When using the opencv streamer address 0 yields a side by side image from the right and left lens. The idea here would be to have a node grab the images and publish them to something like right/Image_raw and left/Image_raw.

Thanks for any help!

edit retag flag offensive close merge delete

Comments

I suspect that the camera you have and the one in the link are slightly different. The one in the link ( https://www.amazon.com/gp/product/B00... ) is not synchronized and is visible as two USB devices, for which your driver ( http://wiki.ros.org/elp_stereo_camera ) is intended.

tryan gravatar image tryan  ( 2018-07-10 10:04:46 -0600 )edit

My guess is you have the synchronized version ( https://www.amazon.com/s?field-keywor... ), which is a single USB device and streams as one video (side-by-side). If so, as others suggest, I'd split and republish as two images. Then, feed it to any stereo processing node.

tryan gravatar image tryan  ( 2018-07-10 10:24:02 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2018-02-05 23:19:19 -0600

ahendrix gravatar image

You say you found a driver for this camera, but you don't provide a link to it or describe how it doesn't work. That makes it hard to help you.

The OpenCV streaming interface sounds promising. Being able to grab the left and right images simultaneously is a huge advantage when dealing with stereo cameras. I suspect the boundary between the images doesn't move, so if the existing driver doesn't work out you should be able to write one that uses OpenCV's streaming interface. I'd just grab the dual image, split it apart and publish the left and right images separately (with identical timestamps).

edit flag offensive delete link more
0

answered 2018-02-08 14:16:00 -0600

jake3991 gravatar image

updated 2018-02-08 14:18:04 -0600

Hey thanks for getting back to me! I have implemented exactly what was suggested but I'm hitting a bit of a roadblock with the camera info. I used the opencv based camera driver found here ( http://wiki.ros.org/video_stream_opencv ) as my starting point. As you may know it publishes not only the image from the camera but also the camera information associated with a calibration. It seems that when you use more than one "camera_info_manager::CameraInfoManager" in the same place you get the following error message.

[ERROR] [1518120816.976389693]: Tried to advertise a service that is already advertised in this node [/camera/set_camera_info]

Does anyone have an idea how to get around this? You'll find my code and launch file below. I'm somewhat of a ROS newbie so if you happen to have more than one idea I'd love to hear the simplest one!

Also for reference here is the camera driver I found that does not work. http://wiki.ros.org/elp_stereo_camera

cpp file

#include <ros ros.h=""> #include <image_transport image_transport.h=""> #include <camera_info_manager camera_info_manager.h=""> #include <opencv2 highgui="" highgui.hpp=""> #include <opencv2 imgproc="" imgproc.hpp=""> #include <cv_bridge cv_bridge.h=""> #include <sstream> #include <boost assign="" list_of.hpp="">

// Based on the ros tutorial on transforming opencv images to Image messages

sensor_msgs::CameraInfo get_default_camera_info_from_image(sensor_msgs::ImagePtr img){ sensor_msgs::CameraInfo cam_info_msg; cam_info_msg.header.frame_id = img->header.frame_id; // Fill image size cam_info_msg.height = img->height; cam_info_msg.width = img->width; ROS_INFO_STREAM("The image width is: " << img->width); ROS_INFO_STREAM("The image height is: " << img->height); // Add the most common distortion model as sensor_msgs/CameraInfo says cam_info_msg.distortion_model = "plumb_bob"; // Don't let distorsion matrix be empty cam_info_msg.D.resize(5, 0.0); // Give a reasonable default intrinsic camera matrix cam_info_msg.K = boost::assign::list_of(1.0) (0.0) (img->width/2.0) (0.0) (1.0) (img->height/2.0) (0.0) (0.0) (1.0); // Give a reasonable default rectification matrix cam_info_msg.R = boost::assign::list_of (1.0) (0.0) (0.0) (0.0) (1.0) (0.0) (0.0) (0.0) (1.0); // Give a reasonable default projection matrix cam_info_msg.P = boost::assign::list_of (1.0) (0.0) (img->width/2.0) (0.0) (0.0) (1.0) (img->height/2.0) (0.0) (0.0) (0.0) (1.0) (0.0); return cam_info_msg; }

int main(int argc, char** argv) { ros::init(argc, argv, "image_publisher"); ros::NodeHandle nh; ros::NodeHandle _nh("~"); // to get the private params image_transport::ImageTransport it(nh); image_transport::CameraPublisher pub_left = it.advertiseCamera("left", 1); image_transport::CameraPublisher pub_right = it.advertiseCamera("right", 1);

// provider can be an url (e.g.: rtsp://10.0.0.1:554) or a number of

device, (e.g.: 0 would be /dev/video0) std::string video_stream_provider; cv::VideoCapture cap; if (_nh.getParam("video_stream_provider", video_stream_provider)){ ROS_INFO_STREAM("Resource video_stream_provider: " << video_stream_provider); // If we are given a string of 4 chars or less (I don't think we'll have more than 100 video devices connected) // treat is as a number and act accordingly so we open ...

(more)
edit flag offensive delete link more

Comments

I suspect you just need to namespace the camera_info providers so that they don't collide, but your code formatting makes it nearly impossible to read. Please reformat your code using the "preformatted text" button (marked 101010) so that it is readable.

ahendrix gravatar image ahendrix  ( 2018-02-08 22:51:58 -0600 )edit
0

answered 2018-02-07 03:46:12 -0600

The ability to grab left and right camera simultaneously is almost as good as a Global shutter camera (Which is generally very expensive ).

The image could be easily split using OpenCv and then be republished as topics .

The published topics could be fed into http://wiki.ros.org/stereo_image

edit flag offensive delete link more

Comments

tryan gravatar image tryan  ( 2018-07-10 11:05:23 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-02-05 23:11:31 -0600

Seen: 1,332 times

Last updated: Feb 08 '18