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

Revision history [back]

click to hide/show revision 1
initial version

I don't think that this is the best approach for your problem and you could remove much of the code.

void imageCb_r(const sensor_msgs::ImageConstPtr& image)
{
    ROS_ERROR("callback - r");
    /// This is not needed. The callback is triggered only if there is some data. 
    if ( &image == NULL) 
    return;

    try
    { 
        /// This is simple assignment, no conversion so there is nothing to throw.
        imageIn_r = image;   
    }
    catch (cv_bridge::Exception& e)
    {
        ROS_ERROR("Conversion error: %s", e.what());
        return;
    }
}

The names sound like a stereo camera, you however do not care about the timestamps so that not the right images are used to create a stereo pair. You could use a TimeSynchronizer for that: http://wiki.ros.org/message_filters

The cv::WaitKey(1) should not make a difference at it's length is negligible compared to the whole process()-call.

A much bigger influence has the duration of your Rate. You just check for new images every 33ms which could delay your processing much more than the 1ms Waitkey (although I'm not sure how long the execution of the waitkey really takes).