ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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]);
       count++;
       *(image(i,j)+1) = *(&img->data[count]);
       count++;
       *(image(i,j)+2) = *(&img->data[count]);
        count++;
      }
    }
 //ROS_INFO("data = [%d]",*(&img->data[0]));
 cvStartWindowThread();
cvShowImage("view",image.Ipl());

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

Comments

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
0

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

ahendrix gravatar image

It sounds like you may be looking for the cv_bridge conversion tutorial: http://wiki.ros.org/cv_bridge/Tutoria...

edit flag offensive delete link more

Comments

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 
    roscpp 
    (...) 
    cv_bridge (...)
)

package.xml :

<build_depend>cv_bridge</build_depend>
<run_depend>cv_bridge</run_depend>

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

Question Tools

1 follower

Stats

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

Seen: 513 times

Last updated: Oct 06 '14