Do automation/test card sliding notches? Try this 2023 optimized OpenCV solution
Students who have been tossing about automated testing and crawler authorization verification recently should not be able to avoid the sliding verification code - Jiexian, NetEase Yidun, and hCaptcha are all using it. Although the deep learning solution is powerful, the threshold for standardizing data and setting up a GPU environment is too high; Pure OpenCV requires no training, is quick to get started, and can run on a single CPU. With further optimization of parameters and processes in 2023, it will be more than enough to deal with more than 80% of conventional gaps!
This article will help you:
- Sorting out the core features of modern sliding notches
- Use the latest OpenCV 4.7 API to implement a set of robust recognizers
- Attached are practical performance/robustness optimization tips
⚠️ Important note: This article is only used for authorized technical research and legal automated testing. For actual application, please abide by the website's "Terms of Service" and robots.txt, and control the frequency of requests!
1. First understand what the sliding gap looks like (key!)
Many students use template matching and Canny as soon as they come up, and the results are very poor - the core reason is that the general screening rules for regular gaps are not grasped. The characteristics of mainstream gaps in 2023 (such as the third generation lightweight version of Jiexian) are actually very fixed:
Universal gap feature (adapted to mainstream products such as JiExperience/Yidun)
- Shape: A simplified version of the "concave" cut out of a square/rectangular shape (usually a regular polygon with clear outlines)
- Position: 50%-90% of the area** on the right side of the picture** (the system is afraid that dragging too far to the left will be too easy)
- Size: The width is 10%-30% of the original image, and the height is close to the width (avoid interference objects that are too flat or too sharp)
- Filling Degree: The actual pixel area within the outline, accounting for 60%-90% of the outer rectangle (excluding hollow/solid interference from text and watermarks)
2. Environment preparation: 30 seconds to set up the foundation
2.1 Dependent installation (fixed version to avoid compatibility issues)
2.2 Test images (don’t just use one!)
Find at least 10 pictures of different scenes and different notch styles:
- Cut from the official website/public demo of the third generation of JiExperience
- Cut from NetEase Yidun lightweight version
- Climbed it by myself (within legal limits!)
3. Core identification process: four steps for the 2023 optimized version
Many old tutorials used "Grayscale → Canny → Contour Screening". Now we have added CLAHE Histogram Equalization (processing darker/brighter verification codes), Morphological Closure Operation (filling small gaps in the gap outline), and the process is more stable:
Complete runnable code
4. What other tips can further improve the recognition rate?
4.1 Performance optimization (single CPU can also be 2-3 times faster)
💡 Image scaling: If the original image is about 300x150, no need to reduce it; if it exceeds 600x300, scale it down to 300x150, the recognition accuracy will be almost unchanged, and the speed will be much faster.
4.2 Enhanced robustness (deal with more than 85% of interference)
🚀 Multi-threshold Canny: If a single Canny parameter does not work, you can try(100, 200)、(80, 180)、(120, 220)Three parameters, take the intersection contour, which can filter out many noise edges.
🚀 Color Space Supplement: If the LAB processing effect is not good, you can convert to HSV - H channel can separate the color of the background and the gap. For example, the tone of some gaps in Jiexuan is reddish, and the H channel threshold can be used to extract the foreground more cleanly.
5. Expanded Resources & Legal Tips
Extended resources
Another legal reminder
This article is only used for authorized technical research and legal automated testing (such as your own company's system, testing allowed by open APIs)! If you crack the commercial verification code without authorization, you may violate the "Network Security Law" and "Criminal Law" (such as the crime of illegal intrusion into computer information systems and the crime of damaging computer information systems), and you will be responsible for the consequences!
The confrontation with verification code technology is ongoing - if you need to identify complex dynamic blur and 3D rotation verification codes, it is still recommended to use the official API or find a professional AI team to cooperate!

