ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

what is the best for object tracking??

asked 2014-10-06 04:18:36 -0600

Robot gravatar image

updated 2014-10-06 11:26:53 -0600

joq gravatar image

I have one urdf model of a car. It gets one camera in front of it. its grabbing the picture and publishing on a topic. I have write a callBack function where it will receive the image data. By the pixel by pixel data it will convert it to a opencv image, and will display on a window. Now my next step is to use the image data to track one target object. which will be the best way to do. I am really stuck in here.

 flag = 0;
 ROS_INFO("in image node function");
 int h = *(&img->height);
 int w = *(&img->width);
 cv::WImageBuffer3_b image(h,w);
 int step = image.WidthStep();
 step = 3; 
 for(int i=(h-1);i>=0;i--)
    for(int j=(w-1);j>=0;j--)
       *(image(i,j)) = *(&img->data[count]);
       *(image(i,j)+1) = *(&img->data[count]);
       *(image(i,j)+2) = *(&img->data[count]);
 //ROS_INFO("data = [%d]",*(&img->data[0]));

the above is my imagecall back function. I have all the pixel data. please help me. Thank you in advance

edit retag flag offensive close merge delete


I am really stuck in here, please give me any hints,,, thank you in advance

Robot gravatar image Robot  ( 2014-10-06 08:58:56 -0600 )edit

This has been the topic of a great many PhD theses. It may help if you can constrain your problem a little bit.

ahendrix gravatar image ahendrix  ( 2014-10-06 13:17:20 -0600 )edit

using those pixel data I am able to generate the image. it is perfectly showing. the problem is the structure I am using to store the image file with all the relevant data is a WImagebuffer3_b. In order to perform any image processing I am gonna need in cv::Mat format. will cv_bridge will be perfect

Robot gravatar image Robot  ( 2014-10-06 17:19:26 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-10-06 17:35:10 -0600

ahendrix gravatar image

It sounds like you may be looking for the cv_bridge conversion tutorial:

edit flag offensive delete link more


undefined reference to `cv_bridge::toCvCopy(boost::shared_ptr<sensor_msgs::image_<std::allocator<void> > const> const&, std::basic_string<char, std::char_traits<char="">, std::allocator<char> > const&)' this is the error I am getting all the time.. any idea???? please...

Robot gravatar image Robot  ( 2014-10-07 03:00:42 -0600 )edit

Did you add cv_bridge in your package.xml and CMakeLists ? CMakeLists :

find_package(catkin REQUIRED COMPONENTS 
    cv_bridge (...)

package.xml :


and did you include it ?

bchiffreville gravatar image bchiffreville  ( 2014-10-07 03:14:35 -0600 )edit

I am sorry it worked. I missed to ad the cv_bridge in the CMakelist.txt....

Robot gravatar image Robot  ( 2014-10-07 03:20:22 -0600 )edit

now it is in cv_bridge::CvImagePtr*. but I want it as a cv_Mat& format. what would be the next step.. thanks again.....

Robot gravatar image Robot  ( 2014-10-07 03:34:48 -0600 )edit

The image member of the CvImage class is a cv::Mat.

ahendrix gravatar image ahendrix  ( 2014-10-07 03:39:02 -0600 )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

1 follower


Asked: 2014-10-06 04:18:36 -0600

Seen: 436 times

Last updated: Oct 06 '14