Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.

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

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.