WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Grabbing screen shots (but not to file) (https://forum.worldviz.com/showthread.php?t=710)

pbeeson 08-29-2006 02:58 PM

Grabbing screen shots (but not to file)
 
I would like to be able to capture the current screen to a python object of some sort (list, string, I don't really care). Is this possilbe in Vizard, or can I only dump to .BMP files?

I can install PIL then open and read in the BMP file, but reading the file it not optimal as it may begin before the file writing ends (plus it involves using another third-party software along with Vizard). It would be much nicer if it could be done within Vizard.

---------

If this is not possible, any suggestions on how to quickly get the screen buffer would be appreciated.

farshizzo 08-29-2006 05:48 PM

There is no command that will return the raw data of the screen capture. Capturing to a file and reading the file is probably the easiest solution. Do you need this for real-time use?

When you issue the viz.screencapture command the file is not created immediately. It is created at the end of the next frame. So when you issue the command wait until the next frame before reading the file.

pbeeson 08-29-2006 08:10 PM

It would be nice to get this in real-time. I thought it might be possible to install pyopengl and grab the screen buffer, but I'm not sure exactly how to tell the python OpenGl code which OpenGL buffer it should care about. Does Vizard store the ID of the OpenGl window it opens?

This is mostly just for displaying the Vizard display on a linux machine that is running software that interacts with Vizard via an xmlrpc server I set up (using Vizard as a robot simulation environment). I'm thinking the easiest thing might just be to run a vncserver in Windows and view the Windows desktop in Linuz through a vnc-client, but it would have been nice to send the Vizard screen buffer (as a string) through the xmlrpc interface.
----------
Any more suggestions are welcome.

BTW, I'm new to Vizard, so where can I report bugs?

farshizzo 08-29-2006 08:56 PM

You want to stream the frame buffer uncompressed at 60 hz? What window size are you running in?

Quote:

Does Vizard store the ID of the OpenGl window it opens?
There is no built-in way to get the OpenGL ID from Vizard.

A plugin could be made to capture the screen contents of the graphics window and return it as a string in python. If you are using Vizard 3.0 then I could create this plugin for you.

Quote:

BTW, I'm new to Vizard, so where can I report bugs?
You can report bugs on the forum.

pbeeson 08-30-2006 07:29 AM

Quote:

Originally Posted by farshizzo
You want to stream the frame buffer uncompressed at 60 hz? What window size are you running in?

Once I have the (630x480) buffer, I can always run it through libz or something to get out a compressed string, then unpack it on the other end of the socket I'll post it on. Plus, 20-30 Hz will probably be good enough to get a sense of what the agent sees (to compare with the metrical and symbolic maps that our research software creates---using the "virtual robot sensors" I built for the Vizard agent).

Quote:

Originally Posted by farshizzo
A plugin could be made to capture the screen contents of the graphics window and return it as a string in python. If you are using Vizard 3.0 then I could create this plugin for you.

That would be extrememly helpful. I am not familiar with programming in Windows (in fact the machine I'm using doesn't even have Visual Studio), so unless its something I could do in python with minimal knowledge of Vizard or OpenGL, it would be best to have someone else write this for me.

Unfortunately, I'm running Vizard 2.53g. Is that a deal breaker? Regardless, I'll contact support to beta test v3.0, but I'll have to ask my employer about his plans to upgrade our Vizard purchase an upgrade to v3 when it comes out. Let me know.

farshizzo 08-30-2006 01:49 PM

Quote:

Unfortunately, I'm running Vizard 2.53g. Is that a deal breaker? Regardless, I'll contact support to beta test v3.0, but I'll have to ask my employer about his plans to upgrade our Vizard purchase an upgrade to v3 when it comes out. Let me know.
It should be possible to create this plugin for 2.5 as well. If you plan on signing up for the beta release then I would prefer to make it for 3.0.

farshizzo 08-30-2006 02:55 PM

1 Attachment(s)
I just finished implementing the plugin for 3.0. Here are some notes about the plugin:

- It grabs the screen buffer directly from windows, not OpenGL. The benefit is that it can capture a little faster and it can run in a separate thread.

- The image is in raw BGR format.

- The image is inverted vertically because in Windows the origin of an image is the top left corner.

I've attached a zip file which contains the plugin and an example file. Again, this will only work with Vizard 3.0

pbeeson 08-30-2006 03:29 PM

Thanks a million. Although I definately plan to beta test v3.0, would it be selfish for me to request a plugin for 2.5 as well ? :o

I'm assuming of course that it is similar is strucutre, so that I won't steal too much of your time. But, we are trying to get a pilot experiment up and running in a VERY short period, so keeping with Vizard 2.5 for the next few weeks might be the best bet.

Again, thanks. And if this is asking too much, please let me know, and I'll make due.

farshizzo 08-30-2006 04:42 PM

1 Attachment(s)
Here is a version of the plugin that should work with Vizard 2.53g. Let me know if it doesn't suite your needs.

pbeeson 08-30-2006 06:14 PM

This is perfect. Works great. Thanks for all your help.


All times are GMT -7. The time now is 12:33 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC