Use openCv on a Captured 2D image from a character's camera view

Hi guys, I just recently found out about panda3d. And reading its capabilities and support in using python and C++ alongside 3rd party libraries like opencv. I thought it would be great for simulating my PhD project.

In my project I will be using RGB camera to perceive the environment and especially assessing plants and soil texture. And obviously use library like opencv for image processing etc…

So in a nutshell I would appreciate if somebody can point out to me how I can capture a 2D image of the camera view from a character/object in a scene to imitate my RGB camera in capturing images in the environment and then use that image for personal scripting or image analysis.

Sorry in advance, I am not a computer scientist, I am just getting my hands dirty with most of this things. Your help is appreciated, Thanks!

If a simple grab of the rendered view will serve your purposes, then one way to do it might be the “getScreenshot” method of the “DisplayRegion” class.

It might be used something like this:

# Get a screenshot of the default display-region that's
# associated with the default window ("")
screenshotTexture =

Note that if you prefer, there’s also a version of the method that, instead of returning a texture, stores the screenshot in a PNMImage.

And should you be using a display-region other than the default one, you would presumably just call “getScreenshot” on that instead.

1 Like

Okay, thanks for this it does seam something worth a try. And could solve my query. Hence, it is then okay for me to proceed learning panda3d. Thanks!!

1 Like

It’s my pleasure!

I hope that you enjoy your use of Panda3D–and welcome to the forum, too! :slight_smile:

1 Like