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

How do i use ros TF to capture object position based on colour and calculate relative distance?

asked 2014-09-17 04:28:42 -0500

chiongsterx gravatar image

Hi im currently doing position detection. By using Opencv color(red) detection i detect the red object and now i want to publish it in the tf and show where and the distance between the object and camera.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-09-17 04:44:12 -0500

Rabe gravatar image

updated 2014-09-18 03:05:12 -0500

In case you have all the necessary data, you basicly follow this tutorial and publish it relative to your camera.

I don't know if I understood you correctly, but for this to work, you need to already have all the necessary information, that is the distance and the position of the object. TF won't do that for you, you'll need to get that data out of OpenCV.


Edit to answer your comment:

TF is only a representation of known data. It is used for queries like "I know the ball is 3m from the camera, and the camera is 2m next to my robot, where is the ball in regards to the robot?". You have to make sure yourself, that these informations are available and correct.

Now, for how to get this information: Writing everything from scratch is a lot of hard work. You said you already know, where your object is in your picture (I guess you have the information available as "x pixels from the left side and y pixels from the top"). Now you'll need some kind of depth information, like with a kinect where you can look up the distance at the area of your object. Or you know how big your target is, and then try to estimate the distance via the observed size of the object in your image. When you have this, then you can publish this information.

Or you use an already available package to do the work for you. Take a look at the ar_track_alvar package, it tracks markers via a kinect (or a normal webcam) and publishes this information as tf.

Maybe, if you can give a bigger picture of what you are trying to achieve, we can help you better.

Good luck


Next edit:

Regarding what you want to do: I was thinking along the lines of "What do you want to track the coloured object for? Could you use the ar_track_alvar package or some other instead?"

As I said, to write the complete code from "I have a picture with a red ball in the upper corner" to "The red ball is 2.5 x, 0.3 y and 1.2 z from the camera" is not just a couple of lines, especially if you have little experience / no idea where to get started. Try to find packages that already do the stuff you want to do and see if you can adapt them.

edit flag offensive delete link more

Comments

Oh... i didn't know that... so i have get opencv to calculate distance and position?? May i know whether there is any tutorial on that? Sorry not that good at opencv.

chiongsterx gravatar image chiongsterx  ( 2014-09-17 07:17:49 -0500 )edit

Hi yes thanks for all that information. Regarding what i'm trying to achieve, it is to actually allow the camera to detect on object based on the colour. After that, the camera will calculate the distance of object from camera.

chiongsterx gravatar image chiongsterx  ( 2014-09-18 01:16:00 -0500 )edit

Oh yes, i'm using this website's colour detection and tracking to detect the object. http://opencv-srf.blogspot.ro/2010/09... Right now i need to figure out how to do position detection. It would be great if you could teach me on that. Thanks for the help!

chiongsterx gravatar image chiongsterx  ( 2014-09-18 01:18:01 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-09-17 04:28:42 -0500

Seen: 2,307 times

Last updated: Sep 18 '14