OpenCV Basic example
OpenCV (Open Source Computer Vision Library) is a library of programming functions mainly aimed at real-time computer vision. Originally developed by Intel, it was later supported by Willow Garage then Itseez (which was later acquired by Intel). The library is cross-platform and free for use under the open-source Apache 2 License. Starting with 2011, OpenCV features GPU acceleration for real-time operations. wiki
I am using python for this example and you can install python using Python Releases for Windows | Python.org link.
Get Sanjaya Deshapriya’s stories in your inbox
Join Medium for free to get updates from this writer.
You can verify your python version using below command
py --versionWe are using pip to install opencv (PIP is a package management system used to install and manage software packages/libraries written in Python.) You can check your pip version using below command
py -m pip -VTo upgrade pip version
py -m pip install --upgrade pipTo install OpenCV use below command
py -m pip install opencv-pythonNow OpenCV successfully installed on your machine. We can check OpenCV version using below python code
import cv2cv2.__version__
Open web cam and show video using imshow
import cv2cam = cv2.VideoCapture(0)if not cam.isOpened():
raise IOError("Cannot open webcam")while True:
ret, frame = cam.read()
cv2.imshow('open web cam', frame)c = cv2.waitKey(1)
if c == 27:
breakcam.release()
cv2.destroyAllWindows()






