No timestamp in Image header from CV_bridge

asked 2021-03-02 12:56:31 -0500

CharlieR gravatar image

Hi I am using CV_bridge to read a video stream from a webcam and send it to another node via the Image message from common_messages-->senosr_messages. I need the timestamp that the image was taken in the subscriber node, but when I read the header of the Image message I just get 0. Not sure if I have done something wrong or if this is a common error. Ity would be great if anyone could help. OS: Ubuntu 20.04 , ROS: Noetic, Python3

Charlie

edit retag flag offensive close merge delete

Comments

Afaik, it's the publishing side's responsibility to set the header.stamp field. The various methods in CvBridge don't copy it.

I need the timestamp that the image was taken in the subscriber node

I'm not sure I understand you correctly, but if you mean you'd like to know when the message was received by the subscriber, then that information is not available by default.

There are a few Q&As about that topic specifically here on ROS Answers. I'd advise you to use Google to search. Make sure to append site:answers.ros.org to your query.

gvdhoorn gravatar image gvdhoorn  ( 2021-03-03 02:46:12 -0500 )edit

Thanks for your help. Sorry, let me clarify it. I want to see at what time the image was captured by the camera, but would like to access it from the subscriber. Is it a common issue that Cv bridge does not do this?

If cv_bridge doesn't do it is there a way to write to the header whilst using cv_bridge? Charlie

CharlieR gravatar image CharlieR  ( 2021-03-03 08:36:58 -0500 )edit

I want to see at what time the image was captured by the camera,

that should then be set by the publisher (ie: the camera driver).

Is it a common issue that Cv bridge does not do this?

I don't believe it's a responsibility of CvBridge, but of the driver.

After you've converted an incoming message, you'd still be able to access the header.stamp of the original message. If that doesn't contain a valid timestamp, then I would conclude the publishing side hasn't set it properly.

If cv_bridge doesn't do it is there a way to write to the header whilst using cv_bridge?

this confuses me a little: in general the publishing side would be responsible for setting that field. On the receiving side, you'd convert the message to an image, and would then still be able to access the header ...(more)

gvdhoorn gravatar image gvdhoorn  ( 2021-03-03 08:42:22 -0500 )edit

If this is so, what happens when imgmsg_to_cv2 is used? Is the ROS Image header info lost in the conversion?

Kansai gravatar image Kansai  ( 2021-08-10 20:10:44 -0500 )edit