Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Latency on camera in ROS

For my project I need to analyse the vision of a robot, I attached a camera to it and I can view the videostream in ROS. I measure the latency by pointing the camera at a stopwatch on my screen and then take a screenshot. I can see the current time on the stopwatch and the current time on the stream, the difference between those is the latency.

Outside ROS, just by using a simple C++ program and openCV I measure a latency of 120ms. In ROS the (almost exact) same code gives me a latency of 230ms.

        while (ros::ok()) {
        thetaCapture.read(frame);
        if (frame.empty()) {
            ROS_ERROR("Empty frame read from camera stream");
            break;
        }

        cv::imshow("Theta Vision", frame);
        // Stop program on any key press
        if (cv::waitKey(1) > 1) break; 

        sensor_msgs::ImagePtr msg = cv_bridge::CvImage(std_msgs::Header(), "bgr8", frame).toImageMsg();
        imagePub.publish(msg);
        //  ros::spinOnce();
        //  rate.sleep();
    }

Basically all this node does is send the camera output to another node. Are there any techniques or ways to lower the camera latency in ROS? I experimented with Ros.Rate() etc. but that didn't change much so far.