What is the fastest way to scale and display an image in Python?
I am required to display a two dimensional numpy.array of int16 at 20fps or so. Using Matplotlib's imshow chokes on anything above 10fps. There obviously are some issues with scaling and interpolation. I should add that the dimensions of the array are not known, but will probably be around thirty by four hundred.
These are data from a sensor that are supposed to have a real-time display, so the data has to be re-sampled on the fly.
Asked by: Alina893 | Posted: 28-01-2022
The fastest way to display 30x400 data points is to:
Use OpenGL color arrays
If you can quickly transform your data to what OpenGL understands as color array, you could create a vertex array describing quads, one for each sensor, then update your color array and draw this orthographically on screen.
Use OpenGL textures
If you can quickly transform your datapoints to an opengl texture you can draw one quad with fixed UV coordinates that is bound to this texture.
Pygame has support for conversion of Numpy/Numarray to surfaces, Pygame can then transform such surfaces which involves resampling, after resampling you can blit it on screen.
pyglet makes dealing with opengl very easyAnswered by: Agata188 | Posted: 01-03-2022
python - Fastest Way to Plot Surface Animation
I have a grid of points X,Y and an array of matrices containing values of those points at different times, Z. Currently, I am outputting a surface plot image using matplotlib before appending them together to make an animation. This is very slow since matplotlib must render each image individually meaning plotting 1000 frames of an animation take tens of minutes, code shown below for i in range (len(Z...
2D animation in Python
I'm writing a simulator in Python, and am curious about options and opinions regarding basic 2D animations. By animation, I'm referring to rendering on the fly, not displaying prerendered images. I'm currently using matplotlib (Wxagg backend), and it's possible that I'll be able to continue using it, but I suspect it won't be able to sufficiently scale in terms of performance or capabilities. Requirements a...
animation - How do I track an animated object in Python?
I want to automate playing a video game with Python. I want to write a script that can grab the screen image, diff it with the next frame and track an object to click on. What libraries would be useful for this other than PIL?
Python Animation Timing
I'm currently working on sprite sheet tool in python that exports the organization into an xml document but I've run into some problems trying to animate a preview. I'm not quite sure how to time the frame rate with python. For example, assuming I have all of my appropriate frame data and drawing functions, how would I go about coding the timing to display it at 30 frames per second (or any other arbitrary rate).
animation - Python problem with resize animate GIF
I'm want to resize animated GIF with save animate. I'm try use PIL and PythonMagickWand (ImageMagick) and with some GIF's get bad frame. When I'm use PIL, it mar frame in read frame. For test, I'm use this code: from PIL import Image im = Image.open('d:/box_opens_closes.gif') im.seek(im.tell()+1) im.seek(im.tell()+1) im.seek(im.tell()+1) im.show() When I'm use MagickWand with this code...
How to extract a given frame from a .gif animation in Python
I'm trying to figure out how to extract a given frame from an animated-gif, possibly in PIL, in Python. I'm not able to easily dig this up, and I'm guessing it would take some knowledge of the gif format, something that is not readily understandable to me. Is there any straightforward way to accomplish this? Do I need to do some custom parsing?
python - How can I speed up an animation?
I'm trying to create a Matplotlib animation of my paw data, where you can see the pressure distribution on the entire pressure plate over time (256x64 sensors for 250 frames). I found a working example on Matplotlib's own site
animation - Error in python script
I wrote a python script to make an animation but when I run it I get the error AttributeError: 'module' object has no attribute 'ion' Here is the script: import numpy as np import pylab as pl data = np.loadtxt( "random.dat" ) pl.ion() M = len( data )-1 N = len( data[:,0] ) line , = pl.plot( data[0,1:] , pl.ones( M ) , 'o' ) for i in xrange( 1 , N ): ...
python - Motion Animation
I have a project in Python 2.7 and PyGTK 2.24. I am using the following code to create a motion animation of a gtk.Image inside a gtk.Fixed. def fishmove(): global fishmove if fishmove < 640: fishmove = fishmove + 10 fixed_hab.move(fish1, fishmove, 50) gobject.timeout_add(1, fishmove) However, while the program comes up without throwin...
python - 3D Animation of Fractals
I'm giving a presentation on Fractal Antennas (take a look at my previous threads) in November and I wanted to incorporate some animation to make my presentation easier to visualize the content I am referring to. Most of these animations would be relatively short, probably a minute long at the most. There are a few animations that would be fantastic to have: Fractal Mountains - The animation continues to a...
python - wx.Timer for animation
Simple animation, this works but would the replaced image data stay in the buffer? And is using timer for animation harmful to CPU? I mean like self.timer.Start(25) does some cool animations from individual image files. self.nm = ['01.png', '02.png', '03.png', '04.png'] self.stop = 0 def time(self, event): self.count += 1 if self.count == 1: self.anime = wx.StaticBitmap(self, -...
Still can't find your answer? Check out these communities...
PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python