Article Directory
Preface
- Basic package opencv-python
- High distribution opencv-contrib-python
1. Image basis
1.1 Theoretical introduction
Use cv2.imread() to change the storage format :
from jpg:rgb—>opencv:bgr
One image processing:
- 1. Three-dimensional array
- 2. Draw a three-dimensional scatter chart
- 3. The histogram of the image: the gray-scale image of the statistical pixel distribution
- Three-dimensional color image == "turned to one-dimensional grayscale image
- Draw a histogram
- ravel() method pulls the array dimension into a one-dimensional array
- Hist function function-draw a histogram
1.2 Case 1-Handwritten Digit Recognition
Enter a picture: identify the digital
opencv, remove the messy lines and dots in the digital picture, filter out all the messy lines, and keep only the digital lines
- Create a picture
Choose the thickest line to write the number, and use other lines (not the thickest) to add and embellish
-
Number recognition
-
Generate verification code pip install captcha
-
To get all the files in this folder, you can use the for (root, dirs, files) in walk (path name) function .
2. Image filtering and preprocessing
Opencv filtering and edge detection: recognition of lane lines
'''
Identifies geometric features in the image, such as: line circle square
1. Grayscale color image is converted to grayscale image
2. Filtering is prepared for edge detection. What about filtering? The interference of noise on edge detection eliminates the influence of noise
3. Edge detection Canny Sobel Laplacian> Find the difference between adjacent or close pixels (pixel difference)
4. Shape feature detection Hough transform
'''
2.1 Filtering
-
Mean filter
-
Set salt and pepper noise
-
Gaussian filter-must be an odd term
-
Median filtering-must be an odd term
2.2 Edge detection
- Canny
- Sobel
- Laplace
Three, image transformation
- Affine transformation
- Perspective transformation
3.1 Affine transformation
Two-dimensional to two-dimensional graphics, translation, rotation, zoom and other operations
- Pan
- Zoom out and pan
- Spin
3.2 Perspective transformation
Two-dimensional transformation into three-dimensional space and then projected to a new plane, also known as: projection mapping.
Function 1: Turn to the real image plane. Function 2: Transform or transform the original captured image to improve the accuracy of image recognition.
pst1: coordinate point in the original image pst2: coordinate point
to be generated