Getting started with OpenCV and Python

Image for post
Image for post
Photo by Pop & Zebra on Unsplash

Installation!

$ pip install opencv-python
> import cv2
Image for post
Image for post
Your OpenCV is installed!
brew install python python3
brew install opencv3 --with-contrib --with-python3
> import cv2
Image for post
Image for post
Your OpenCV is installed!
$ sudo apt-get install libopencv-dev python-opencv
Image for post
Image for post
And it’s a wrap

Simple operations on images using OpenCV

Image for post
Image for post
Read you image
import cv2# Load an color image in grayscaleimage = cv2.imread(‘watch.jpg’,0)
Image for post
Image for post
Display your image
cv2.imshow(‘image’,image) # the title and path to imagecv2.waitKey(0) # Waits for the next key to be pressedcv2.destroyAllWindows()
Image for post
Image for post
Save you image
cv2.imwrite(‘watchgray.png’,image)
Image for post
Image for post
That’s all folks!
Reading, Displaying and Saving an image

The Andela Way

A pool of thoughts from the brilliant people at Andela

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store