Camera calibration node in stereo mode shows nothing

asked 2017-06-06 17:28:48 -0500

NickVot gravatar image

updated 2017-06-06 17:29:14 -0500

Hi, I want to calibrate my stereo camera that made of two monocular webcams. Here is my camera node code.

#include <iostream>

#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>

#define FPS 30

sensor_msgs::ImageConstPtr right_view_message;
image_transport::Publisher left_view_publisher;
image_transport::Publisher right_view_publisher;

void left_view_callback(const sensor_msgs::ImageConstPtr& message){
    if(right_view_message == NULL) return;

    std_msgs::Header header = std_msgs::Header(message->header);

    cv::Mat right_view_mat = cv_bridge::toCvShare(right_view_message, "rgb8")->image;
    cv::Mat left_view_mat = cv_bridge::toCvShare(message, "rgb8")->image;

    sensor_msgs::ImagePtr left_view_message = cv_bridge::CvImage(header, "rgb8", left_view_mat).toImageMsg();
    sensor_msgs::ImagePtr right_view_message = cv_bridge::CvImage(header, "rgb8", right_view_mat).toImageMsg();

    left_view_publisher.publish(left_view_message);
    right_view_publisher.publish(right_view_message);
}

void right_view_callback(const sensor_msgs::ImageConstPtr& message){
    right_view_message = message;
}

int main(int argc, char **argv){
    right_view_message = NULL;
    std::cout << "stereo_cam_node" << std::endl;

    ros::init(argc, argv, "stereo_cam_node");
    ros::NodeHandle node;

    image_transport::ImageTransport image_transport(node);

    image_transport::Subscriber left_view_subscriber = image_transport.subscribe("/left_cam/image_raw", 1, left_view_callback);
    image_transport::Subscriber right_view_subscriber = image_transport.subscribe("/right_cam/image_raw", 1, right_view_callback);

    left_view_publisher = image_transport.advertise("/left_cam/sync_raw", 1);
    right_view_publisher = image_transport.advertise("/right_cam/sync_raw", 1);

    ros::spin();
    return 0;
}

If I run a camera calibration node with one image like

rosrun camera_calibration cameracalibrator.py --size 6x8 --square 0.024 image:=left_cam/image_raw

It works well. However in stereo mode like

rosrun camera_calibration cameracalibrator.py --size 6x8 --square 0.024 right:=/right_cam/image_raw left:=/left_cam/image_raw

it shows nothing just as there are no image messages. What should I do? Please help me.

edit retag flag offensive close merge delete