How FAST give opencv browser screen(selenium)? - python

There is a game, where if you want to play you need to look all screen(all screen is a - canvas). How can I give this canvas to opencv FAST(0.1 sec upd)? Now I simply make screenshots of screen with selenium(drive.save_screenshot("foo.png")) but this way is too slow(0.3-0.5 sec).
Is there any way to save screenshots faster or other way to give opencv access to screen or smth else. Maybe I need to save screenshot as bytes but not as file to upd canvas faster?
Also I found this https://python-mss.readthedocs.io/examples.html#part-of-the-screen but I didn't find how to use it with selenium. Python.
Photo of canvas:

Related

Is there a way to take a "screenshot" in pygame, and then save it as a sprite so as to reduce code complexity?

The title says it all, although in my instance, the reason I wish to use this feature is I plan on having a all this stuff moving around, until I call this "dialogue()" function, when everything will stop, and I will have dialogue options moving about the screen. However, I don't want to continually render everything in the background, so is there some way of going about taking a screenshot in pygame?
You can capture the contents of the Pygame.Surface by making a copy with screen.copy() then when you want to redraw you use screen.blit(copy, (0,0)). And then you draw on top of that.
Another option is to change your code so that you render the background into a separate surface rather than copying it from the screen and then combine the foreground with the dialogue with it by bliting the background and then the foreground to the screen.
If this isn't right for you, please share more about your program. I haven't used Pygame in a while so this is mostly based on the documentation https://www.pygame.org/docs/ref/surface.html

Ghost in Python isn't taking full resolution browser screenshots

Windows 7/Python 2.6
I am trying to take full browser screenshots and then use pillow to compare the images. I have started to use Ghost for the screenshots because i couldn't seem to get Selenium/PhantomJS to take full browser screenshots in headless mode. When i take a screenshot using Ghost the resolution of the images are like 780x8000 even thought i set the viewport size to 1920x680 (just testing resolution sizes while getting use to pillow). Sadly i can't share the screenshots but here is just is a snippet of code.
from ghost import Ghost
self.ghost = Ghost(viewport_size=(1920,680))
self.ghost.open('someurl')
self.ghost.capture_to('somedir')
After taking the screenshot the image is showing all the items in the webpage, but at the 1000px wide breakpoint for the layout.
Can someone either explain how to get the desired results of getting screenshots at 1920x"PageHeight" using either ghost or possible some other python package?
I have found the fix and it is to not set the viewport size in the constructor but using the set_viewport_size(x,y) method.
You should be able to take headless screenshots w/ selenium+phantomjs if you call
driver.set_window_size(x, y)
and then
driver.get_screenshot_as_file( "/path/to/img.png" )

move a stereoscopic video on the screen

I would like to move a (stereoscopic) video on a computer screen automatically. Think of the video as the ball in a Pong game. The problem is that it should be a stereoscopic 3D video. So the video size itself is kind of small. I did this kind of movements with pictures or drawing object, but I don't know how to do it with video material!
Does somebody know how I can do this? I already searched for video tools in python like pygame or pyglet. I have an external player Bino 3d which can open the desired video. But how can I make it move around the screen?
Or is there a tool in other programming languages like c/c++ or Matlab which can help?
By the way, the program will be on a Linux OS.
I'll be grateful for any help or hints!
Anna
I'd try to use a decent video client (mplayer, vlc). They can present the video in lots of ways, hopefully your stereoscopic issue can be solved by them.
Then I would let the client present a single window (not fullscreen) which I then would move around using window manager controls.
If you must not have window decorations around the video or if the output shall be a specific window, I think mplayer at least can be told to use an existing window to perform the output in. Maybe that's an approach then.

Selecting area of the screen with Python

I'm developing a screen shot utility in Python. At the moment it is specifically for Linux. So far I have the ability to take a screen shot of the full desktop, and have it upload to Imgur, then copy the link to clipboard. Now I want to expand into functions such as screen shots of the active window, or of a specific selection. If anyone could help, I'd love to know what kind of module would work best for this, and how to implement such a module.
The functionality will depend on what you are using for image grabbing.
With PIL
http://effbot.org/imagingbook/imagegrab.htm
With GTK
To take a screenshot of active window :
http://faq.pygtk.org/index.py?req=show&file=faq23.039.htp
Also look at the pixbuf api
http://library.gnome.org/devel/gdk-pixbuf/
http://developer.gimp.org/api/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html
Off topic
There are some screen cast tools: http://pypi.python.org/pypi/castro/1.0.4

Python: OSX Library for fast full screen jpg/png display

Frustrated by lack of a simple ACDSee equivalent for OS X, I'm looking to hack one up for myself. I'm looking for a gui library that accommodates:
Full screen image display
High quality image fit-to-screen (for display)
Low memory usage
Fast display
Reasonable learning curve (the simpler the better)
Looks like there are several choices, so which is the best? Here are some I've run across:
PyOpenGL
PyGame
PyQT
wxpython
I don't have any particular experience with any of these, nor any strong desire to become an expert - I'm looking for the simplest solution.
What do you recommend?
[Update]
For those not familiar with ACDSee, here's what it does that I care about:
Simple list/thubmnail display of images in a directory
Sort by name/size/type
Ability to view images full screen
Single-key delete while viewing full screen
Move to next/previous image while viewing full screen
Ability to select a group of images for:
move to / copy to directory
delete
resize
ACDSee has a bunch of niceties as well, such as remembering directories you've moved images to in the past, remembering your resize settings, displaying the total size of the images you've selected, etc.
I've tried most of the options I could find (including Xee) and none of them quite get there. Please keep in mind that this is a programming/library question, not a criticism of any of the existing tools.
I will recommend using wxPython to create such a viewer, wxPython is easy to learn, free, cross platform and blends well in OSX. Even if you want to use pyopengl, wxPython would be good with pyopengl.
see such tutorials http://showmedo.com/videotutorials/video?name=1790000&fromSeriesID=179
and there is already cornice written in wxpython/PIL, may be you can modify that. It has been inspired by the famous Windows-only ACDSee :)
it's not an answer to your coding question but for (a big part of) the lack of ACDsee equivalent (requires OSX 10.5+):
Simple list/thubmnail display of images in a directory: Finder.app
Sort by name/size/type: Finder.app will do name & type, not image size (but does file size)
Ability to view images full screen: quick preview (spacebar / eye icon)
Single-key delete while viewing full screen: command-backspace while viewing in quickpreview, both windowed and fullscreen
Move to next/previous image while viewing full screen: both quickprewiew (after selecting a group of images or whole directory with cmd-a) and Preview.app
Ability to select a group of images for[...]: Finder.app will does all but resize
seems like you have everything except resize just pressing the spacebar while in finder.
Preview.app will resize both a single image or multiple ones in one batch.
Use an App like Picasa (now available on mac). Use AppleScript through Python to control it from your application.
Failing that, use PyObjC to create Cocoa image display component and dialogs, and so on.
I ended up using PyGame, has been pretty good so far.

Categories

Resources