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

Revision history [back]

click to hide/show revision 1
initial version

Although I'm not 100% sure what you're trying to do, the image_geometry library might have some useful stuff in it.

For example, the project3dToPixel(point) and/or projectPixelTo3dRay(uv) might be useful.

If you're wondering if, at any given time, the camera's center axis is intersecting the objects bounding box, you might have to implement that by hand, or grab an example from online somewhere by searching for something like "code for ray passing through a bounding box".

Although I'm not 100% sure what you're trying to do, the image_geometry library might have some useful stuff in it.

For example, the project3dToPixel(point) and/or projectPixelTo3dRay(uv) might be useful.

If you're wondering if, at any given time, the camera's center axis is intersecting the objects bounding box, you might have to implement that by hand, or grab an example from online somewhere by searching for something like "code for ray passing through a bounding box".

Or are you trying to find the world coordinates of the point at which the camera's center axis intersects the object? If so, is the object shape arbitrary? Or is it like a cube or sphere or some other geometric primitive shape?

Although I'm not 100% sure what you're trying to do, the image_geometry library might have some useful stuff in it.

For example, the project3dToPixel(point) and/or projectPixelTo3dRay(uv) might be useful.

If you're wondering if, at any given time, the camera's center axis is intersecting the objects bounding box, you might have to implement that by hand, or grab an example from online somewhere by searching for something like "code for ray passing through a bounding box".

Or are you trying to find the world coordinates of the point at which the camera's center axis intersects the object? If so, is the object shape arbitrary? Or is it like a cube or sphere or some other geometric primitive shape?

EDIT: I understand better now. What I would do is convert my object model to an octree and do ray tracing on that. There are two options that I know of, one is to use Octomap which has the castRay function or use the Octrees in Point Cloud Library which have the OctreePointCloudSearch functions.

In either case you'll need to convert your model into something that one of those libraries can use. Depending on what format the object is already in, here are some hints for doing it with Octomap. For Point Cloud Library, I know you can at least import from a PLY file using this class.

Then just use the camera location as the origin of the ray and the camera direction as the ray direction and bingo! For what it's worth, I think I've used PCL and Octomap to do something similar in the past and don't recall either one being easier or harder than the other, so I don't think it matters too much which you choose.