How to get Viewport pixel color
-
Hi,
I want to know the active viewport color value of each pixel .
Like the red rectangular area I marked in the figureThanks for any help!
-
Hello @chuanzhen,
thank you for reaching out to us. In Python there is no really good way to do this. Your best option is to render the
BaseDraw
you are interested in with RenderDocument with the OpenGL renderer as the render engine. Which will work fine if you only need a viewport representation once in a blue moon, but will quickly become a giant bottleneck if you need access to a viewport framebuffer dozens of times per second. In this case I would recommend moving to C++, as you have there somewhat direct access to the viewport draw buffer with BaseDraw::GetViewportImage.Cheers,
Ferdinand -
@ferdinand Thanks for your hlep!
-
@ferdinand Hi,i use RenderDocument in python,although it is a little slow and needs to wait for a second, it works successfully.
Thanks for your help,gif show it works: