Is the extraction of a timestamp from the header of a sensor_msgs::Image
that easy:
void imageCb(const sensor_msgs::ImageConstPtr& imsg) {
cv_bridge::CvImagePtr cv_ptr;
try {
cv_ptr = cv_bridge::toCvCopy(imsg, sensor_msgs::image_encodings::TYPE_16UC1);
}
catch (cv_bridge::Exception& e) {
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
//get header info
std_msgs::Header h = imsg->header;
cout<<h<<endl; //all at once
cout<<h.stamp<<endl; //specific parts of it
cout<<h.stamp.sec<<endl;
cout<<h.stamp.nsec<<endl;
cout<<h.seq<<endl;
//do some with it
This is the output
seq: 11536 //all info
stamp: 1455792836.004090186
frame_id: camera_depth_optical_frame
1455792836.004090186 //stamp
1455792836 //sec
4090186 //nsec
11536 //seq
Originally posted by user23fj239 on ROS Answers with karma: 748 on 2016-02-18
Post score: 2