Ask Your Question
0

synchronize kinect rgb/image_color depth/image or points

asked 2012-08-24 05:12:08 -0500

Pitscho gravatar image

updated 2012-09-19 08:41:09 -0500

-------------------- SOLUTION ----------------- message_filters::TimeSynchronizer... has to be message_filters::Synchronizer... found that out after a day


How to mark as solved ?

Hi

I want to synchronize the image_color and the depth/image topic of a kinect.

both topics have different frequencies. i hoped before that they publish at the same time but sadly not.

is there a way to let these to topics been published simultaneously?


other posibility is to use a topic with rgb and d info, but i need an easy way to get the opencv rgb image.


the only topic i see, which has all info is "depth/points", but I need an opencv RGB image also, an iterative loop over the pointcloud to obtain the opencv image pixel by pixel seems to be studpi, because rgb image topic already exists.


why doesn'T that work:


private:
    message_filters::Subscriber<sensor_msgs::image> image_sub;
    message_filters::Subscriber<sensor_msgs::image> pointcloud_sub;

    message_filters::TimeSynchronizer<sensor_msgs::image, sensor_msgs::image=""> synchronizer;

public :

    // Constructor
    VisualAidingOpenni()
        :  nh("~")/*, it(nh)*/, synchronizer(1), ....

private:
void a function ()... {

        image_sub.subscribe(nh, topic_image, 1);
        pointcloud_sub.subscribe(nh, topic_pointcloud, 1);
        synchronizer.connectInput(image_sub, pointcloud_sub);
        synchronizer.registerCallback(boost::bind(&VisualAidingOpenni::subscriber_Callback,this , _1, _2));
}


void  subscriber_Callback(const sensor_msgs::ImageConstPtr& msg, const sensor_msgs::ImageConstPtr& pointcloud)
    {

...
}

forget the word pointcloud, tried the depth image at last, so everything in sensor_msgs::image


this doesn't even compile


private:
    message_filters::Subscriber<sensor_msgs::image> image_sub;
    message_filters::Subscriber<sensor_msgs::image> pointcloud_sub;
    typedef sync_policies::ApproximateTime<sensor_msgs::image, sensor_msgs::image=""> MySyncPolicy;
    message_filters::TimeSynchronizer<mysyncpolicy> synchronizer;

void function()
{
        image_sub = new message_filters::Subscriber(nh, topic_image, 1);
        pointcloud_sub = new message_filters::Subscriber(nh, topic_pointcloud, 1);
        synchronizer = new message_filters::TimeSynchronizer<mysyncpolicy>(MySyncPolicy(10), image_sub, pointcloud_sub);
 synchronizer.registerCallback(boost::bind(&VisualAidingOpenni::subscriber_Callback,this , _1, _2));

}

void  subscriber_Callback(const sensor_msgs::ImageConstPtr& msg, const sensor_msgs::ImageConstPtr& pointcloud)
    {

i get this error


/opt/hector/students/friedrich/hector_visual_aiding/hector_visaid_monocular/src/visual_aiding_openni.cpp:-1: In Elementfunktion »void VisualAidingOpenni::CamInfo_Callback(const CameraInfoConstPtr&)«:
:-1: Fehler:[CMakeFiles/visual_aiding_openni.dir/src/visual_aiding_openni.o] Fehler 1

THX

edit retag flag offensive close merge delete

Comments

Shouldn't "mysyncpolicy" be "MySyncPolicy"?

jbohren gravatar image jbohren  ( 2012-08-24 06:59:20 -0500 )edit

i have no idea why it isn't upper case here, but it is in qtcreator

Pitscho gravatar image Pitscho  ( 2012-08-24 07:01:36 -0500 )edit

Also could you post the error in a codeblock, it's getting mangled.

jbohren gravatar image jbohren  ( 2012-08-24 07:05:30 -0500 )edit

Yeah, there's no information on the error there.

jbohren gravatar image jbohren  ( 2012-08-24 07:09:06 -0500 )edit

well, the error message just tells me in which function i have the error, nothing more-

Pitscho gravatar image Pitscho  ( 2012-08-24 07:10:26 -0500 )edit

i installed 11.10 these days after i had ubuntu 12.04. since then my debugger information isn't as accurate as before, i don't know why. i use qtcreator. build type is debug.

Pitscho gravatar image Pitscho  ( 2012-08-24 07:11:45 -0500 )edit

The build type wouldn't affect compiler errors.

jbohren gravatar image jbohren  ( 2012-08-24 07:27:59 -0500 )edit

Can you try building it on the command line?

jbohren gravatar image jbohren  ( 2012-08-24 08:48:32 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2012-08-24 05:22:56 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

You can set up a callback in ROS that synchronizes messages from multiple topics with a TimeSynchronizer: http://www.ros.org/wiki/message_filters#Time_Synchronizer

As Dan Lazewatsky says in the comments below, if the timestamps aren't identical, then you might be able to use an ApproximateTimePolicy with the TimeSynchronizer.

edit flag offensive delete link more

Comments

hi, i did that, but .. the two topics i subscribe publish in different frequencies. i need the rgb and d information as synchron as possible.

Pitscho gravatar image Pitscho  ( 2012-08-24 05:33:04 -0500 )edit

/camera/rgb/image_color and /camera/depth_registered/image at the same time synchron would be perfect

Pitscho gravatar image Pitscho  ( 2012-08-24 05:37:56 -0500 )edit
1

Since the hardware doesn't synchronize the image acquisition, there is no way to get precisely synchronized images from a kinect. Using the ApproximateTime sync policy with a time synchronizer is probably your best option.

Dan Lazewatsky gravatar image Dan Lazewatsky  ( 2012-08-24 06:12:54 -0500 )edit

so the data in /camera/depth/pointcloud with xyzrgb information is also not really synchron for positon and color ?

Pitscho gravatar image Pitscho  ( 2012-08-24 06:17:51 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-08-24 05:12:08 -0500

Seen: 1,896 times

Last updated: Sep 19 '12