This post will be helpful in learning OpenCV using Python programming. Here I will show how to implement OpenCV functions and apply them in various aspects using some great examples. Then the output will be visualized along with the comparisons.
We will also discuss the basic of image processing and provide the detail explanation related to the OpenCV functions.
- OpenCV 3.4+
- Python 3.6+
- Image, Webcam or Video input
- Documentation Source: OpenCV Official Documentation
First, you need to setup your Python Environment with OpenCV. You can easily do it by following Life2Coding’s tutorial on YouTube: Linking OpenCV with Python 3
The goal is to make you understand how to create a black background image using OpenCV
Displays an image in the specified window.
winname Name of the window. mat Image to be shown.
Waits for a pressed key.
delay Delay in milliseconds. 0 is the special value that means “forever”.
Destroys all of the HighGUI windows.
- Create a numpy image using np.zeros()
- Display all the images using cv2.imshow()
- Wait for keyboard button press using cv2.waitKey()
- Exit window and destroy all windows using cv2.destroyAllWindows()
import numpy as np import cv2 my_img_1 = np.zeros((512, 512, 1), dtype = "uint8") cv2.imshow('Single Channel Window', my_img_1) my_img_3 = np.zeros((512, 512, 3), dtype = "uint8") cv2.imshow('3 Channel Window', my_img_3) cv2.waitKey(0) cv2.destroyAllWindows()
- How to Create a RGB Color Picker for Images using OpenCV Python - 22 April, 2022
- Combine Several Images Vertically with Padding using OpenCV Python - 21 April, 2022
- Combine Several Images Horizontally with Padding using OpenCV Python - 21 April, 2022