Video_source node in ros_deep_learning package for Apriltag detection

I am currently using the video_source node in the ros_deep_learning package for my Apriltag detection projects. I have done the calibration process to get the intrinsic parameters of the camera. I wrote a script to publish this camera information (as the Apriltag detection ROS node require both the image and the camera info message). However, when I run the node, it say the two message have 0 synchronized pair.

If someone has the same problem, please share the solution with me. Many thanks

Here is the

import rospy
from sensor_msgs.msg import CameraInfo, Image
import yaml

class CameraInfoPublisher():
    def __init__(self):
        self.info_pub = rospy.Publisher("video_source/camera_info", CameraInfo, queue_size=10)       
        self.rate = rospy.Rate(30)

    def callback(self, image):
        tmp_image_header_stamp = image.header.stamp

    def publish(self):
        msg = CameraInfo()
        name, width, height, model, D, K, R, P = self.read_data()

        msg.height = height
        msg.width = width
        msg.distortion_model = model
        msg.D = D
        msg.K = K
        msg.R = R
        msg.P = P
        # msg.header.stamp = tmp_image_header_stamp
        while not rospy.is_shutdown():
            msg.header.stamp =

    def read_data(self):
        with open("/home/reception03/Desktop/imx_ws/src/camera_info/config/ost.yaml", "r") as f:
            data = yaml.safe_load(f)

            name = data["camera_name"]
            width = data["image_width"]
            height = data["image_height"]
            model = data["distortion_model"]
            D = data["distortion_coefficients"]["data"]
            K = data["camera_matrix"]["data"]
            R = data["rectification_matrix"]["data"]
            P = data["projection_matrix"]["data"]
            return name, width, height, model, D, K, R, P

if __name__ =='__main__':
    pub = CameraInfoPublisher()
    # rospy.spin()

The error:

 Topics '/video_source/raw' and '/video_source/camera_info' do not appear to be synchronized. In the last 10s:
	Image messages received:      295
	CameraInfo messages received: 295
	Synchronized pairs:           0

Hi @tom.nqduc, I’m unfamiliar with synchronized message pairs and not sure how you would synchronize them from different nodes, sorry about that. Perhaps posting a similar question to the ROS Discourse would engage the community of ROS developers there more familiar with it. Or you could modify the code of the video_source node in the ros_deep_learning package itself and maybe publishing the messages at the same time from there would help?

It was also my understanding that the camera_info messages are published at a much lower rate than the image frames and don’t need to be synchronized, but I could be wrong.

It turns out that the two message are different by a tiny fractional amount of time and could not be sync. I have fixed the code above to set the time instead of to the current timestamp that the images were published, and it works. Another additional query regarding this video_source node is that how can I set the camera frame. The detection node is working however, transform return empty frame ID value.

It doesn’t look like I set the frame_id in videoSource or propagate it in the other nodes. If you need it, you should be able to add it in the code here - you can retrieve the frame number from stream->GetFrameCount()

Exactly what I did, thanks for the solution.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.