-
Notifications
You must be signed in to change notification settings - Fork 0
guide opencv
Tianshu Huang edited this page Oct 12, 2018
·
2 revisions
This guide isn't very complete. If you have experience with OpenCV, or figured out a few things while learning, feel free to add to this page!
In order to maintain inter-compatibility between Python modules, please use Python 3.
pip install opencv-pythonor (if python3 outside of virtual environment in linux)
pip3 install opencv-python- Reading an image:
# Read image
image = cv2.imread(filepath)- Image conversions:
# Convert grayscale
image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Convert to HSV
image_hsv = cv2.cv2Color(image, cv2.COLOR_BGR2HSV)- Showing images:
cv2.imshow("This is an image window", image_gray)
cv2.waitKey(0)
cv2.destroyAllWindows()The second two lines close the window whenever any keys are pressed in the window and continues execution. Since it's hard to write unit tests for problems without clear correct answers such as clustering problems, most vision algorithms will have to rely on visual inspection for testing.