I get continuously PIL Images, using while True loop, and want to show them as a movie.
I can show an image by img.show(), but this code inside the loop makes multiple windows.
Would you tell me the way to display them as a movie?
I think the easiest way is to use ImageMagick in the command line to great a .gif file with the following command, assuming your image files are named something like image-1.png, image-2.png:
sudo apt-get install imagemagick
convert -delay 20 -loop 0 image-*.png my_movie.gif
This will create a my_movie.gif in the same directory where your images are located.
Another way to create a movie from frames is to use Blender, an open source program based on Python. I don't think Pillow supports creating gifs or movie files directly; every solution I have seen involves some other library, so I think the best way is to go with a simple command line tool.
Related
Hello: I am developing on Linux trying to use Python/OpenCV to process videos.
I have tried using Python2 and Python3 but no results.
import cv2
video = cv2.VideoCapture("myvideo.mp4")
status = video.isOpened()
In this case, status is a boolean and it is always false.
A quick search online pointed to the problem as Python OpenCV module is compiled with FFMPEG library turned on. As a result, it is cannot handle video.
But I am unable to find any solution to it.
Any help much appreciated.
See if you can use ffmpeg from command line and the video (with exactly the same path) as an input for some kind of simple manipulation or conversion.
Doing that, output it as an .avi file with a different coding and see if that makes any difference for OpenCV as an input.
Check if maybe you're able to use the feed from your webcam by modifying the script just a little bit.
Check if the path you provide is correct. Try putting the video in your home folder and providing an absolute path.
Try reinstalling ffmpeg according to these instrcutions.
If none of above work, follow this guide.
Visual Studio allows to visualize OpenCV images using Image Watch plugin (https://visualstudiogallery.msdn.microsoft.com/e682d542-7ef3-402c-b857-bbfba714f78d) during debug. This is very helpful for computer vision coding.
What is the proffered way to visualize images in Python binding to OpenCV? I am aware that it is possible to use cv2.imshow("name", image) but that is not very practical in contrast to Image Watch which allows to show many images at the same time and automatically does the update after change.
Is there any alternative to Image Watch for Python?
If you use VSCode, you can try the simply_view_image_for_python_opencv_debugging VSCode-Extension.
https://marketplace.visualstudio.com/items?itemName=johnguo.simply-view-image-for-python-opencv-debugging
I think maybe you'll want to look at Visual-Logging. It can produce a rather nice collection of your output that you can just open up in a browser. It is pip installable like so:
pip install visual-logging
Here is a page with a concise walkthrough that shows how it is used.
It's not nearly as fancy as that Visual Studio tool, but it might be your best option that already exists.
I had similar problems, so I've just created OpenCV Image Viewer Plugin, which works as you expect. You can install it to any JetBrains IDE, which support Python (directly or via plugin).
https://plugins.jetbrains.com/plugin/14371-opencv-image-viewer
I'm looking for a Python library that can combine images into a video.
A library that just allows you to create an empty video and feed images into it as frames is ideal.
Preferably with support for MPEG compression of the video file as well.
If you run linux then you can use ffmpeg to do this from the command line there is a python wrapper called pyFFmpeg that you can use - there is also pymedia but it doesn't look to be maintained.
BTW there are a number of projects that provide builds of ffmpeg for windows.
gstreamer is the tool you are looking for. you'll probably need an appsrc or something like that.
Ok, so I have Python 2.5 with Windows XP. I want to create a program that will create and/or manipulate an icon (.ico) file. Is there any module that can do this? Thanks.
EDIT:
I will need to save the image back into a .ico file.
Try the Python Image Library or PIL for short. Also, take a look at this plug in for PIL that makes it handle images correctly on windows: http://code.google.com/p/casadebender/wiki/Win32IconImagePlugin
There is also this: pythonMagick
I've found, via Google, numerous people asking the same question, but no solutions. The Python Image Library (PIL) has tools for stepping through an already existing multi-page TIFF, but nothing about creating them.
Libraries would hopefully be available on Windows, for Python 2.6.
If there's some freeware out there which will do the trick, I wouldn't mind seeing it, but I was hoping I could accomplish this in Python.
You can use ImageMagick for this (available on Unix and Windows).
A linux shell command would be
$ convert *.tif multipage.tif
where *.tif are all your individual tif files.
A freeware option: Irfanview can do it, even via the command line; this allows you to call it from Python.
From changes version 3.90:
New command line option:
/multitif=(tifname,file1,...,fileN)
Example to create multipage TIF test.tif from 2 other files:
i_view32 /multitif=(c:\test.tif,c:\test1.bmp,c:\dummy.jpg)
New command line option:
/append=tiffile
Example to open c:\test.jpg and append it as (TIF) page to c:\test.tif
i_view32 c:\test.jpg /append=c:\test.tif
I have used it once and know it works, though limitation on command line length apply.
you can use the command utility "tiffutil"