
FFMPEGĪn alternative to using OpenCV is to use subprocess to wrap the FFMPEG, a command line video and audio processing utility. equivalent to a 2D matrix or grayscale image). Often for image processing it is useful to separate out the channels and just work on a single channel at a time (e.g. the x-direction of the image) and the third dimension relates to the three colour channels. the y-direction of the image), the second dimension relates to columns of the image (e.g. In the above code, “ frame” is a three-dimensional tensor or array where the first dimension relates to rows of the image (e.g.

# Display the frame until new frame is available # These allow for a frame rate to be printed # Optional - set to YUV mode (remove for BGR) # Function to convert array to JPEG for display as video frameĭisplay.display(display.Image(data=f.getvalue())) This is useful for bio-inspired processing. The code separates out each of the YUV components and displays them next to each other. As drawing windows led to errors I designed a workaround where I used PIL (Python Image Library) and IPython to generate an image from the Numpy array and then show it at about 30 fps. This lead me to look for alternative visualisation strategies that I describe below.Ī good place to start with OpenCV is this video tutorial. I could capture images from the webcam but not display them in a window.

One problem I had in Linux (Ubuntu 18.04) is that the GTK libraries didn’t play nicely in the Conda environment. There are thus several out of date Stack Overflow answers that come up in the searches, that refer to installing from specific sources (e.g. Setting up a new environment with Jupyter Notebook and Open CV is now straightforward:Īs a note – installing OpenCV in Conda seems to have been a pain up to a few years ago. I generally use Conda/Anaconda these days to manage my Python environments (the alternative being old skool virtual environments). The tutorials here are a good place to start. Now there is a nice Python wrapper and you don’t need to touch any low-level code. Things have come a long way since my early experiences with OpenCV in C++ over a decade ago. The default library for video processing in Python is OpenCV.
