Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use OpenCV to get the card number in C++

Shulou Source: shulou.com Published: 2022-06-02 06:06:03 10月04日 Update

C++ how to use OpenCV to get the card number, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Using Canny edge extraction, turning grayscale image-- Gaussian blur-- morphological closed operation-- Canny edge extraction

Display effect

The red box is the result of processing.

Look for the outline and draw all the contours in the picture. let's take a look.

Then run it to see the effect.

You can see that all the found outlines are drawn on the right. How do we locate the area with the blue line? through the analysis, we can see that there are several characteristics:

The length of the area is more than half the length of the card number.

The rotation value of the rectangle formed by the region is very low and can be ignored.

Modify the setting of the search area if the length of the rectangle is half the length of the picture and the degree of rotation is less than 3

Then we'll run it again and have a look.

As you can see, we located directly to the area we were looking for.

Migration and interception according to fixed area

After reading the above, have you mastered how to use OpenCV to get the card number in C++? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Area length card number outline outline content effect method more rectangle edge problem location operation helplessness to this end drawing reason right picture picture Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Microsoft Redmi MariaDB Shulou Technology