Edge/Line Detection (Features)
Operation |
Uses |
---|---|
cv2.Canny(image, T_lower, T_upper, aperture_size, L2Gradient) | The Canny Edge Detection is an algorithm used for edge detection. It reduces noise using Gaussian Smoothing and computes image gradient using The Sobel filter. |
cv2.HoughLines(edges, 1, np.pi/180, 200) | The Hough Transform is a method that is used in image processing to detect any shape if that shape can be represented in mathematical form. It can detect the shape even if it is broken or distorted a little bit. |
cv2.HoughCircles(image, cv2.HOUGH_GRADIENT, 1, 20, param1 = 50, param2 = 30, minRadius = 1, maxRadius = 40) | Circle detection finds a variety of uses in biomedical applications, ranging from iris detection to white blood cell segmentation. |
cv2.cornerHarris(src, dest, blockSize, kSize, freeParameter, borderType) | Harris Corner detection algorithm was developed to identify the internal corners of an image. The corners of an image are basically identified as the regions in which there are variations in the large intensity of the gradient in all possible dimensions and directions. |
cv2.goodFeaturesToTrack(image, max_corner, quantity_level, min_distance) | The cv2.goodFeaturesToTrack() function in OpenCV is used for corner detection. |
cv2.drawKeypoints(input_image, key_points, output_image, colour, flag) | The distinguishing qualities of an image that make it stand out are referred to as key points in an image. The key points of a particular image let us recognize objects and compare images. This can be done by using the cv2.drawKeypoints() method. |
Canny Edge Detection
The Canny Edge Detection is an algorithm used for edge detection. It reduces noise using Gaussian Smoothing and computes image gradient using The Sobel filter. Finally, apply Hysteresis thresholding which that 2 threshold values T_upper and T_lower which are used in the Canny() function.
cv2.Canny(image, T_lower, T_upper, aperture_size, L2Gradient)
Houghline Method for Line Detection
The Hough Transform is a method that is used in image processing to detect any shape if that shape can be represented in mathematical form. It can detect the shape even if it is broken or distorted a little bit.
cv2.HoughLines(edges, 1, np.pi/180, 200)
Houghline Method for Circle Detection
Circle detection finds a variety of uses in biomedical applications, ranging from iris detection to white blood cell segmentation.
cv2.HoughCircles(image, cv2.HOUGH_GRADIENT, 1, 20, param1 = 50,
param2 = 30, minRadius = 1, maxRadius = 40)
Harris Corner Method for Corner Detection
Harris Corner detection algorithm was developed to identify the internal corners of an image. The corners of an image are basically identified as the regions in which there are variations in the large intensity of the gradient in all possible dimensions and directions.
cv2.cornerHarris(src, dest, blockSize, kSize, freeParameter, borderType)
Shi-Tomasi Method for Corner Detection
In Shi-Tomasi Method, the basic intuition is that corners can be detected by looking for significant changes in all directions. We consider a small window on the image and then scan the whole image, looking for corners. Shifting this small window in any direction would result in a large change in appearance if that particular window happens to be located in a corner.
cv2.goodFeaturesToTrack(imgage, max_corner, quantity_level, min_distance)
Keypoints Detection
The distinguishing qualities of an image that make it stand out are referred to as key points in an image. The key points of a particular image let us recognize objects and compare images. This can be done by using the cv2.drawKeypoints() method.
cv2.drawKeypoints(input_image, key_points, output_image, colour, flag)
Other Detection Techniques
OpenCV module provides functions and classes for the detection of various objects. We can detect a circle or ellipses in an image using the SimpleBlobDetector() function, which is basically used to detect any shape in which the pixels are connected.
Another detection technique used is template matching. It is an image processing technique that is used to find the location of small parts/templates of a large image. This technique is widely used for object detection projects, like product quality, vehicle tracking, robotics, etc. This technique can also be used in matching for detecting document fields in a document image.
We can also use OpenCV to detect emotions. Emotion detectors are used in many industries, one being the media industry where it is important for the companies to determine the public reaction to their products. Smile detectors can also work with a live feed from webcams.
Other than that, OpenCV’s Sobel edge detection method can also be used to detect the edges of an image in a live stream video. Edge detection involves mathematical methods to find points in an image where the brightness of pixel intensities changes distinctly, which requires finding the gradient of the grayscale image. It also makes use of the Laplacian() function.
Python OpenCV Cheat Sheet
The Python OpenCV Cheat Sheet is your complete guide to mastering computer vision and image processing using Python. It’s designed to be your trusty companion, helping you quickly understand the important ideas, functions, and techniques in the OpenCV library. Whether you’re an experienced developer needing a quick reminder or a newcomer excited to start, this cheat sheet has got you covered.
In this article, we’ve gathered all the vital OpenCV concepts and explained them in simple terms. We’ve also provided practical examples to make things even clearer. You’ll learn everything from how to handle images to using advanced filters, spotting objects, and even exploring facial recognition. It’s all here to help you on your journey of discovering the amazing world of computer vision.
Table of Content
- Python OpenCV Cheat Sheet 2023
- Core Operations
- Drawing Shapes and Text on Images
- Arithmetic Operations on Images
- Morphological Operations on Images
- Geometric Transformations on Image
- Image Thresholding
- Edge/Line Detection (Features)
- Image Pyramids
- Changing the Colorspace of Images
- Smoothing Images
- Working With Videos
- Camera Calibration and 3D Reconstruction