Closed samcaulfield closed 6 years ago
Currently this is not (easily) possible. However, we discussed your feature request and plan to expose a "camera-project" function, transforming a 3D world-space point to the 2D screen-space point.
Such a function would be very useful. Given the geometry's 3D bounding box it would be simple to calculate the screen-space bounding box after projecting the vertices into 2D as you say.
Until then, a colleague suggested a clever workaround - render the scene twice (once with and once without the object) and do an image subtraction to find the object's pixel mask. From there it's easy to get the bounding box in 2D. Unfortunately it involves two render passes but it's still better than manually cropping. In fact, instead of the second full render pass perhaps I could just render the object on its own in an otherwise empty scene to get the pixel mask.
I'll probably use that solution until there's an OSPRay function for doing this more easily. Thanks for your reply, I'll close this issue.
If you don't mind to look at all pixels than you can also just check the alpha channel to detect where the object is (and where is just background) -- no need to render the scene twice then.
Hi,
Is there a way to get the screen-space bounding box of an OSPGeometry once it has been rendered? I'm trying to automatically extract cropped images of certain objects in the scene from the rendered image of the entire scene.
For example, I'd like to be able to get a bounding box ((x, y) top-left position and (x, y) width, height)) if the given OSPGeometry is on-screen.
Thanks