OpenCV & Python

Getting started with Computer Vision and Video in Python

Keno Leon
5 min readAug 7, 2020

--

OpenCV is the goto library for many image and video projects in Python, I remember struggling a bit with the documentation when starting out, so here’s a guided coding tour that I hope helps you.

Install OpenCV: <= Search for your particular environment, but this usually works:pip install opencv-python

What is it ?

OpenCV is a lot of things mostly dealing with processing images and video on your computer, my current interests are AI and real time applications, so this is biased towards that; for starters let’s look at simply capturing video from your webcam :

The above script consists of creating a video capture and then feeding that into a loop where frames are read and displayed one by one with imshow, the conditional checks for the exit command (type q to exit), cap.release and cv2.destroyAllWindows outside of the loop then deal with final cleanup. The result should be a video feed with the default OpenCV UI: 

--

--