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 publisher_camera_info.py
import rospy
from sensor_msgs.msg import CameraInfo, Image
import yaml
class CameraInfoPublisher():
def __init__(self):
rospy.init_node("camera_info_publisher")
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
print(tmp_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 = rospy.Time.now()
self.info_pub.publish(msg)
self.rate.sleep()
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()
pub.publish()
# 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