CN112507759A - Image processing method and image processing device for identifying bank card - Google Patents

Image processing method and image processing device for identifying bank card Download PDF

Info

Publication number
CN112507759A
CN112507759A CN201910869801.4A CN201910869801A CN112507759A CN 112507759 A CN112507759 A CN 112507759A CN 201910869801 A CN201910869801 A CN 201910869801A CN 112507759 A CN112507759 A CN 112507759A
Authority
CN
China
Prior art keywords
bank card
image
edge
line segments
image processing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910869801.4A
Other languages
Chinese (zh)
Inventor
赵庆杭
刘国宝
王晓云
水源
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Unionpay Co Ltd
Original Assignee
China Unionpay Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Unionpay Co Ltd filed Critical China Unionpay Co Ltd
Priority to CN201910869801.4A priority Critical patent/CN112507759A/en
Publication of CN112507759A publication Critical patent/CN112507759A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/20Scenes; Scene-specific elements in augmented reality scenes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/24Aligning, centring, orientation detection or correction of the image
    • G06V10/245Aligning, centring, orientation detection or correction of the image by locating a pattern; Special marks for positioning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/44Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components

Abstract

The invention relates to an image processing method for identifying a bank card and an image processing system for identifying the bank card. The method comprises the following steps: an image acquisition step, which is to acquire an initial image of the bank card; an edge detection step, namely detecting edge pixel points of the initial image so as to separate a bank card image from the initial image; an outer frame positioning step, namely marking a plurality of line segments from edge pixel points of the bank card image, and determining a quadrilateral area as an outer frame of the bank card according to the line segments; and a posture transformation step, namely performing posture transformation on the outer frame of the bank card based on the preset size proportion of the bank card to obtain the image of the bank card in the just-facing state. According to the invention, the convenience of the user card binding operation can be realized, and the requirement of real-time operation at the embedded equipment end can be realized because the complexity of the algorithm is small.

Description

Image processing method and image processing device for identifying bank card
Technical Field
The invention relates to an image processing technology, in particular to an image processing method for identifying a bank card and an image processing method.
Background
Electronic payment is widely applied at the present stage, wherein the first link is that a user performs bank card binding operation. At present, most of user Applications (APP) support a mode of identifying a bank card by acquiring an image through a camera, except for a traditional mode of manually inputting a bank card number.
Fig. 1(a), (b), (c) and (d) respectively show APP binding operation interfaces of a payment treasure, a WeChat, a tenderer bank and a cloud flash payment. The basic flow of the prior art scheme is as follows:
(1) opening a mobile phone camera by the APP;
(2) customizing a rectangular scanning area in a camera viewfinder;
(3) waiting for the user to align the bank card to the edge of the scanning frame;
(4) and intercepting the picture of the bank card aligned with the edge of the scanning frame, and identifying the card number at a fixed position.
As shown in fig. 1, the prior art has the following disadvantages:
(1) the bank card surface is parallel to the camera;
(2) the distance between the bank card and the camera needs to be proper and just coincides with the edge of the shooting scanning frame.
That is, the bank card must be aligned with the scanning frame edge at four sides when operating on these operation interfaces, which makes the user need to perform relatively fine operation, resulting in poor user experience. This way of facilitating the scanning by the APP itself by increasing the user operational difficulty is unreasonable from a user experience point of view.
Disclosure of Invention
In view of the above problems, the present invention aims to provide an image processing method and an image processing method for identifying a bank card, which can simplify the difficulty of user operations and can adapt to a non-aligned scene.
The image processing method for identifying the bank card is characterized by comprising the following steps of:
an image acquisition step, which is to acquire an initial image of the bank card;
an edge detection step, namely detecting edge pixel points of the initial image so as to separate a bank card image from the initial image;
an outer frame positioning step, namely marking a plurality of line segments from edge pixel points of the bank card image, and determining a quadrilateral area as an outer frame of the bank card according to the line segments; and a posture transformation step, namely performing posture transformation on the outer frame of the bank card based on the preset size proportion of the bank card to obtain the image of the bank card in the just-facing state.
Optionally, a Prewitt algorithm is employed in the edge detection step.
Optionally, a Prewitt algorithm with high and low thresholds is used in the edge detection step.
Optionally, the edge detecting step includes:
(a) setting a high threshold M and a low threshold N, wherein 0< M <1, 0< N <1 and M > N;
(b) respectively detecting the initial image by using the high threshold M and the low threshold N, thereby respectively detecting a strong edge image and a weak edge image;
(c) taking the strong edge image as a main body, if the weak edge is connected with the main body, keeping the weak edge, and otherwise, abandoning the weak edge; and
(d) and performing morphological denoising to finally separate the bank card image from the initial image.
Optionally, the low threshold N is set to be half of the high threshold M.
Optionally, in the step of positioning the outer frame, a Hough line detection algorithm is used to mark a plurality of line segments from the edge points.
Optionally, the step of positioning the outer frame includes the steps of:
marking a plurality of line segments from the edge points by adopting a Hough linear detection algorithm;
classifying and merging the line segments;
determining two pairs of parallel line segments which can form a quadrangle; and
and calculating the area of the enclosed quadrangle, and if the ratio of the area of the quadrangle to the total area of the whole image is greater than a preset specified value, determining that the quadrangle area is the position of the bank card.
Optionally, the step of positioning the outer frame includes the steps of:
marking a plurality of line segments from the edge points by adopting a Hough linear detection algorithm;
classifying and merging the line segments;
extending the line segments after classification and combination at two ends to obtain two pairs of parallel line segments which can form a quadrangle, and forming the quadrangle; and
and calculating the area of the enclosed quadrangle, and if the ratio of the area of the quadrangle to the total area of the whole image is greater than a preset specified value, determining that the quadrangle area is the position of the bank card.
Optionally, the classifying and merging the line segments includes: and classifying the line segments on the same straight line into one class, merging the similar line segments with close distances, and discarding the isolated and shorter line segments.
Optionally, the preset specified value is 20-80%.
Optionally, the gesture transformation step comprises:
stretching the outer frame of the bank card according to the proportion of 85.60: 53.98; and
and rotating the bank card outer frame by the degree of an included angle between the long edge in the bank card outer frame and the horizontal plane.
An image processing apparatus for recognizing a bank card according to the present invention is characterized by comprising:
the image acquisition module is used for acquiring an initial image of the bank card;
the edge detection module is used for detecting edge pixel points of the initial image and separating a bank card image from the initial image based on the edge pixel points;
the outer frame positioning module is used for marking a plurality of line segments from edge pixel points of the bank card image and determining a quadrilateral area as a bank card outer frame according to the line segments; and
and the posture transformation module is used for carrying out posture transformation on the outer frame of the bank card based on the preset size proportion of the bank card to obtain the image of the bank card in the just-right state.
Optionally, the edge detection module employs a Prewitt algorithm.
Optionally, the edge detection module adopts Prewitt algorithm with high and low thresholds.
Optionally, a high threshold M and a low threshold N are set in the edge detection module, where 0< M <1, 0< N <1, and M > N, the initial image is detected by using the high threshold M and the low threshold N, so as to detect a strong edge image and a weak edge image, respectively, the strong edge image is used as a main trunk, if the weak edge is connected to the main trunk, the strong edge image is retained, otherwise, the weak edge image is discarded, and morphological denoising is performed, so that the bank card image is finally separated from the initial image.
Optionally, the outer frame positioning module marks a plurality of line segments from the edge points by using a Hough linear detection algorithm.
Optionally, the outer frame positioning module marks a plurality of line segments from the edge points by using a Hough linear detection algorithm, classifies and merges the line segments to determine two pairs of parallel line segments which can be enclosed into a quadrangle, calculates the area of the enclosed quadrangle, and if the ratio of the area of the quadrangle to the total area of the whole image is greater than a preset specified value, the quadrangle area is considered to be the position of the bank card.
Optionally, the outer frame positioning module marks a plurality of line segments from edge points by using a Hough linear detection algorithm, classifies and merges the line segments, extends the line segments after classification and merging at two ends to obtain two pairs of parallel line segments which can be defined into a quadrangle, forms the quadrangle, calculates the area of the enclosed quadrangle, and if the ratio of the area of the quadrangle to the total area of the whole image is greater than a preset specified value, determines that the quadrangle area is the position of the bank card.
Optionally, the posture conversion module stretches the bank card housing according to a ratio of 85.60:53.98 and rotates the bank card housing by a degree of an included angle between a long edge in the bank card housing and the horizontal plane.
The mobile terminal according to an aspect of the present invention is characterized by including the image processing device for identifying a bank card.
A computer-readable medium of an aspect of the invention, on which a computer program is stored, is characterized in that,
the computer program, when executed by a processor, implements the image processing method for identifying a bank card as described above.
A computer device according to an aspect of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the image processing method for identifying a bank card when executing the computer program.
As described above, according to the image processing method for identifying a bank card and the image processing apparatus for identifying a bank card of the present invention, the operation difficulty of a user can be reduced, and convenient card binding can be realized, and specifically, the following technical features can be provided:
(1) the bank card surface can be identified under the condition that the bank card surface is not parallel to the camera;
(2) the edge of the bank card does not need to be overlapped with the scanning frame, and the bank card is only required to be wholly positioned in the scanning frame and the area ratio exceeds a preset specified value;
(3) the algorithm complexity is small, and the method can be operated in real time at an embedded front end, wherein the embedded front end refers to terminal equipment with an embedded processor, such as a mobile phone, a tablet and other intelligent equipment with a camera (but not including a computer or a server).
Drawings
Fig. 1(a), (b), (c) and (d) show APP binding operation interfaces of a payment treasure, a WeChat, a tenderer bank and a cloud flash payment, respectively.
Fig. 2 is a flow chart illustrating an image processing method for identifying a bank card according to an embodiment of the present invention.
Fig. 3(a), (b), (c), and (d) are graphs showing the detection effects of edge detection using the Prewitt operator of the modified high-low threshold method, respectively.
Fig. 4 is a schematic diagram showing the original straight line segment detected by Hough transform in the outer frame positioning step.
FIG. 5 is a schematic view showing the outline of a quadrangle to which straight line segments are generalized in the outline positioning step.
Fig. 6 is a schematic diagram showing the state in which the bank card area is rotated in a stretching manner to be in a facing state by the posture changing step.
Fig. 7 is a diagram illustrating the result of detecting an original straight line segment in an embodiment of a hand-held bank card.
Figure 8 is a schematic diagram illustrating the region of the bank card acquired after extending the straight parallel line segment, in accordance with an embodiment of the hand-held bank card.
Fig. 9 is a block diagram showing a configuration of an image processing apparatus for identifying a bank card according to an embodiment of the present invention.
Detailed Description
The following description is of some of the several embodiments of the invention and is intended to provide a basic understanding of the invention. It is not intended to identify key or critical elements of the invention or to delineate the scope of the invention.
For the purposes of brevity and explanation, the principles of the present invention are described herein with reference primarily to exemplary embodiments thereof. However, those skilled in the art will readily recognize that the same principles are equally applicable to all types of image processing methods and image processing methods for identifying bank cards, and that these same principles may be implemented therein, as well as any such variations, without departing from the true spirit and scope of the present patent application.
Moreover, in the following description, reference is made to the accompanying drawings that illustrate certain exemplary embodiments. Electrical, mechanical, logical, and structural changes may be made to these embodiments without departing from the spirit and scope of the invention. In addition, while a feature of the invention may have been disclosed with respect to only one of several implementations/embodiments, such feature may be combined with one or more other features of the other implementations/embodiments as may be desired and/or advantageous for any given or identified function. The following description is, therefore, not to be taken in a limiting sense, and the scope of the present invention is defined by the appended claims and their equivalents.
Words such as "comprising" and "comprises" mean that, in addition to having elements and steps which are directly and explicitly stated in the description and the claims, the solution of the invention does not exclude other elements and steps which are not directly or explicitly stated.
Fig. 2 is a flow chart illustrating an image processing method for identifying a bank card according to an embodiment of the present invention.
As shown in fig. 2, the image processing method for identifying a bank card according to an embodiment of the present invention includes the steps of:
an image acquisition step S100: collecting an initial image of a bank card;
edge detection step S200: detecting edge pixel points of the initial image so as to separate a bank card image from the initial image;
outer frame positioning step S300: determining a quadrilateral area as a bank card outer frame from edge pixel points of the bank card image, if the positioning of the bank card outer frame is successful, continuing to step S400, otherwise, the method fails in flow; and
posture conversion step S400: and based on the preset size proportion of the bank card, carrying out posture transformation on the outer frame of the bank card to obtain a bank card image in a facing state.
The posture transformation step S400 obtains the bank card image in the right state, and then the bank card number is identified for the bank card image in the right state in step S500, if the card number identification is successful, the process of identifying the bank card number is ended, and if the card number identification is failed, the process of the method is failed. Step S500 is not included in the image processing method for identifying a bank card according to the present invention, and represents an operation that is generally continued after the posture of the bank card is changed by the image processing method for identifying a bank card according to the present invention.
Next, each step will be specifically described.
In the image capturing step S100, an initial image of the bank card is captured, for example, the initial image of the bank card is captured by a camera, and the bank card is scanned by the camera, so that the bank card does not need to be aligned with a preset bank card frame as in the prior art, but the bank card is placed on a desktop without a card surface being blocked.
Next, the edge detection step S200 is explained.
In the edge detection step S200, edge detection is performed to detect edge pixel points of the initial image, so that the bank card image is separated from the initial image.
Edge detection is a fundamental problem in image processing and computer vision, and the purpose of edge detection is to identify points in a digital image where brightness changes are significant. Significant changes in image attributes typically reflect significant events and changes in the attributes. These include: discontinuities in depth, surface orientation discontinuities, material property variations, and scene lighting variations.
Edge detection is a research area in image processing and computer vision, especially in feature extraction. The image edge detection greatly reduces the data volume, eliminates information which can be considered irrelevant, and retains important structural attributes of the image. There are many methods for edge detection, and most of them can be divided into two categories: one class based on look-up and one class based on zero-crossings. The search-based approach detects boundaries by finding the maximum and minimum values in the first derivative of the image, usually by locating the boundaries in the direction where the gradient is largest.
The process of recognizing the target by the human visual system comprises the following two steps of firstly, separating the image edge from the background; then, the details of the image can be perceived to recognize the outline of the image. Computer vision is just this process of mimicking human vision. Therefore, when the edge of the object is detected, the contour points are roughly detected, the originally detected contour points are connected through a link rule, and meanwhile, the missing boundary points are detected and connected and the false boundary points are removed. The edge of an image is an important feature of the image and is the basis of computer vision, pattern recognition and the like, so edge detection is an important link in image processing. However, edge detection is a difficult problem in image processing, since the edges of the actual scene image are often a combination of various types of edges and their blurred results, and the actual image signal is noisy. Noise and edges are high frequency signals, and it is difficult to take frequency bands as a trade-off.
This requires edge detection to solve the problem. There are many basic methods for edge detection, such as: the first order is Roberts Cross operator, Prewitt operator, Sobel operator, Canny operator, Krisch operator, compass operator; and Marr-Hildreth, the second derivative in the gradient direction crosses zero.
These edge detection methods are then simply compared: the Robert operator locates more accurately but is more sensitive to noise since it does not include smoothing. The Prewitt operator and the Sobel operator are first-order differential operators, the former is average filtering, the latter is weighted average filtering, the detected image edge can be larger than 2 pixels, the Prewitt operator and the Sobel operator have good detection effect on the image with gradually changed gray levels and low noise, but the processing effect is not ideal for the image mixed with multiple complex noises. The LOG filter method determines edge points by detecting second derivative zero crossings. A in the LOG filter is proportional to the width of the low-pass filter, and the larger a is, the more remarkable the smoothing effect is, and the better the noise is removed, but the more the details of the image are lost, and the lower the edge accuracy is. Therefore, contradiction exists between the edge positioning precision and the noise elimination level, and the noise level and the edge point positioning precision need to be properly selected according to specific problems. The gradient operator is simple in calculation, but the accuracy is not high, only the rough outline of the image can be detected, and the rough outline can be ignored for the thinner edge. The Prewitt and Sobel operators work better than Roberts. The detection effect of the LOG filter and the Canny operator is better than that of the gradient operator, and the thinner edge part of the image can be detected. Therefore, for different systems, it is necessary to select an appropriate operator for edge detection of an image according to different environmental conditions and requirements.
In the invention, to separate the bank card from the image, firstly, the boundary between the bank card and the background is found, and as a preferable mode, the Prewitt operator edge detection method is adopted to separate the edge point and the non-edge point in the image. The Prewitt operator has a good detection effect and is not complex in algorithm, and the Prewitt operator can be directly operated on devices such as a mobile phone and the like without transmitting images to a cloud background for processing.
Next, the Prewitt operator edge detection method will be specifically described.
The Prewitt operator is an edge detection of a first-order differential operator, and the edge is detected by using the gray difference of upper, lower, left and right adjacent points of a pixel point to reach an extreme value at the edge, so that part of a pseudo edge is removed, and the Prewitt operator has a smoothing effect on noise. The principle is that neighborhood convolution is carried out on an image by utilizing two direction templates and the image in an image space, wherein one of the two direction templates is used for detecting a vertical edge, the other one of the two direction templates is used for detecting a horizontal edge, and the maximum value of the two direction templates is taken as an output value. The following tables represent Prewitt templates in the vertical and horizontal directions, respectively:
Figure BDA0002202435100000091
the classical Prewitt operator considers: all the pixel points with the new gray value larger than or equal to the threshold are edge points, namely, the classical Prewitt operator adopts a single threshold and cannot adapt to scenes with complex changes, some edges cannot be detected when the threshold is too high, and many non-edges can be mistakenly identified when the threshold is too low. Therefore, the Prewitt operator in the improved high and low threshold manner is preferred in the present invention.
As an embodiment of the edge detection with the Prewitt operator using the improved high and low threshold mode, the edge detection step S200 includes the following sub-steps:
(a) firstly, setting a high threshold and a low threshold, determining the high threshold by taking the edge pixel point ratio as M, and setting the low threshold as N, wherein M > N, and the value standard of the high threshold is as follows: when the threshold value is equal to the value, it is determined that the number of edge pixels/the number of all pixels in the entire image is M, and thus 0< M < 1. Wherein, M may take a value of, for example, 5%, 10%, 15%, 20%, 30%, etc., without any limitation, and N may take a value lower than that of M, for example, N may be 1/2 of M, 1/3 of M, etc., and N is also not limited herein;
(b) respectively detecting the images by using the determined high threshold and low threshold, thereby correspondingly detecting a strong edge image and a weak edge image;
(c) taking the strong edge image as a main body, if the weak edge is connected with the main body, keeping the weak edge, and otherwise, abandoning the weak edge; (d) and performing morphological denoising as a final result, wherein the morphological denoising is to filter noise points in the image by using a morphological method, and the morphological opening operation is mainly used here to smooth the object boundary and eliminate small objects, so that the image contour is more prominent.
Fig. 3(a), (b), (c), and (d) are graphs showing the detection effect of edge detection using the Prewitt operator of the improved high-low threshold method, respectively.
Here, the detection effect shown in fig. 3 is a detection effect when M takes a value of 10% and N takes a value of 5%.
Fig. 3(a) shows an acquired original image. Fig. 3(b) shows a strong edge map detected by detecting an original image with a high threshold. Fig. 3(c) shows a weak edge map detected by detecting an original image with a low threshold. Fig. 3(d) shows a final edge map obtained by using a strong edge map as a main body, reserving if a weak edge is connected with the main body, and discarding otherwise, and performing morphological denoising.
The invention is characterized in that a Prewitt operator with high and low threshold values is adopted, and the reason for adopting two threshold values is as follows: after the Prewitt operator processing, each pixel point in the image is a calculated value, the threshold value is a threshold value for judging whether the pixel is an edge point, if the calculated value is higher than the threshold value, the pixel is considered to be an edge point, and if the calculated value is lower than the threshold value, the pixel is considered to be a non-edge point. Obviously, the higher the threshold is, the fewer the number of edge pixels is considered to be. Therefore, too high a threshold may result in many true pixels being ignored, while too low a threshold may result in many background points being mistaken for edge points. Therefore, in order to solve such a problem, the Prewitt operator with high and low thresholds is adopted in the present invention.
Next, the frame positioning step S300 will be described.
In the frame positioning step S300, a quadrilateral area is determined from the edge pixels detected in the edge detection step S200 as a bank card frame.
Fig. 4 is a schematic diagram showing the original straight line segment detected by Hough transform in the outer frame positioning step. FIG. 5 is a schematic view showing the outline of a quadrangle to which straight line segments are generalized in the outline positioning step.
Next, in the outer frame positioning step S300, a Hough linear detection algorithm is used to perform outer frame positioning, and referring to fig. 4 and 5, the specific steps are as follows:
firstly, a plurality of line segments are marked from edge points by using a Hough straight line detection algorithm, as shown in FIG. 4, 5 line segments are detected, wherein the 5 line segments specifically comprise: the line segments of four outer frames of the bank card and a line segment under four Chinese characters of 'a business bank';
then, classifying and merging the line segments, namely classifying the line segments on the same straight line into one class, merging similar line segments with close distances, and abandoning isolated and shorter line segments (namely abandoning one line segment below four Chinese characters of a 'business bank');
next, two pairs of parallel line segments that can enclose a quadrilateral are determined, and for example, whether the line segments are parallel can be determined by: the angle difference of the line segments is within a certain range, if the angle difference is less than or equal to 10 degrees, the line segments can be considered as parallel, on the other hand, the two pairs of parallel line segments are close to be mutually vertical, and the end points of the line segments are close to each other, so that straight lines are summarized to form a quadrilateral outer frame as shown in figure 5;
finally, the area of the quadrangle is calculated, if the ratio of the area of the quadrangle to the total area of the whole image is above a specified ratio, the quadrangle area is considered to be the position of the bank card, for example, the specified ratio can be set to be any value in the range of 20% to 80%, if the specified ratio is set to be 50%, the obtained quadrangle is considered to be valid if the ratio of the area of the quadrangle to the total area of the whole image is greater than or equal to 50%, and if the ratio is less than 50%, the obtained quadrangle is considered to be invalid and the quadrangle is discarded. The purpose of setting the prescribed ratio is to eliminate the interference of possible small quadrangles in the background, and to make the bank card area large enough to ensure the feasibility and accuracy of the subsequent card number identification.
Next, the posture changing step S400 will be described. Fig. 6 is a schematic diagram showing the state in which the bank card area is rotated in a stretching manner to be in a facing state by the posture changing step.
In the posture conversion step S400, the posture of the external frame of the bank card obtained in the external frame positioning step S300 is converted based on the size ratio of the bank card set in advance, so as to obtain the image of the bank card in the facing state.
The specification of the bank card is defined as 85.60 multiplied by 53.98mm according to the ID-1 standard in the international standard ISO/IEC 7810. Referring to the standard proportion, the bank card area obtained in the outer frame positioning step S300 is subjected to stretching and rotational transformation, so that the bank card area in the facing posture is finally obtained for subsequent card number identification. This is because, depending on the imaging angle and distance, the bank card outer frame obtained in the outer frame positioning step S300 may not be a standard rectangle, and the aspect ratio of the rectangle is not as high as 85.60:53.98, so that it is necessary to perform stretching, and the quadrangular outer frame processed in the outer frame positioning step S300 is stretched into a rectangle having an aspect ratio of 85.60: 53.98.
In addition, the photographed bank card may not be directly opposite, and in order to facilitate the identification of the subsequent card number, it is necessary to rotate to the opposite state shown in fig. 6, where the rotation angle is: the included angle between the long edge in the outer frame of the bank card and the horizontal line.
Next, another modified embodiment of the image processing method for identifying a bank card according to the present invention will be described.
The case where the bank card is placed on a desktop to be scanned or photographed as described in the above-described embodiments will be described next with respect to the embodiments in the case where the bank card is held by hand to be scanned or photographed.
Fig. 7 is a diagram illustrating the result of detecting an original straight line segment in an embodiment of a hand-held bank card. Figure 8 is a schematic diagram illustrating the region of the bank card acquired after extending the straight parallel line segment, in accordance with an embodiment of the hand-held bank card. When the user holds the bank card, a part of the bank card can be shielded by fingers. When the bank card is positioned, the extracted original straight line segments may have short length or have interruption, and after the line segments are classified and combined, more and proper extension needs to be performed at two ends, so that the bank card is considered to be a possible bank card outer frame as long as the line segments can be combined into a proper quadrangle.
The image processing method for identifying the bank card of the embodiment comprises the following steps:
an image acquisition step: acquiring an initial image of the bank card (the step is the same as the image acquisition step S100 in the above embodiment);
an edge detection step: detecting edge pixel points of the initial image to separate a bank card image from the initial image (the step is the same as the step S200 of edge detection in the above embodiment);
an outer frame positioning step: marking a plurality of line segments from edge pixel points of the bank card image, classifying and merging the line segments, namely classifying the line segments on the same straight line into one class, merging similar line segments with close distance, abandoning isolated and shorter line segments, then performing more and proper extension on two ends, and determining two pairs of parallel line segments which can form a quadrangle so as to form a proper quadrangle; and
posture transformation: based on the preset size proportion of the bank card, the posture of the outer frame of the bank card is transformed to obtain the image of the bank card in the facing state (the step is the same as the posture transformation step S400 in the above embodiment).
The outer frame positioning step in this embodiment includes the following specific sub-steps:
firstly, a plurality of line segments are marked from edge points by using a Hough straight line detection algorithm, as shown in FIG. 7, 5 line segments are detected, wherein the 5 line segments specifically include: the bank card comprises four line segments of an outer frame of the bank card and one line segment under four Chinese characters of a 'tenderer bank', wherein the line segments on 2 sides in the outer frame have parts shielded by fingers;
then, classifying and merging the line segments, namely classifying the line segments on the same straight line into one class, merging the similar line segments with close distance, abandoning the isolated and shorter line segments, then, as shown in fig. 9, performing more and proper extension on two sides (namely, the line segments of 2 sides in the outer frame have parts blocked by fingers), and determining two pairs of parallel line segments which can form a quadrangle so as to form a proper quadrangle;
next, two pairs of parallel line segments that can enclose a quadrilateral are determined, and for example, whether the line segments are parallel can be determined by: the angle difference of the line segments is within a certain range, if the angle difference is less than or equal to 10 degrees, the line segments can be considered as parallel, on the other hand, the two pairs of parallel line segments are close to be mutually vertical, and the end points of the line segments are close to each other, so that straight lines are summarized to form a quadrilateral outer frame as shown in figure 5;
finally, the area of the quadrangle is calculated, if the ratio of the area of the quadrangle to the total area of the whole image is above a specified ratio, the quadrangle area is considered to be the position of the bank card, for example, the specified ratio can be set to be any value in the range of 20% to 80%, if the specified ratio is set to be 50%, the obtained quadrangle is considered to be valid if the ratio of the area of the quadrangle to the total area of the whole image is greater than or equal to 50%, and if the ratio is less than 50%, the obtained quadrangle is considered to be invalid and the quadrangle is discarded. The purpose of setting the prescribed ratio is to eliminate the interference of possible small quadrangles in the background, and to make the bank card area large enough to ensure the feasibility and accuracy of the subsequent card number identification.
The image processing method for identifying a bank card according to the present invention is explained above, and then the image processing apparatus for identifying a bank card according to the present invention is executed
Fig. 9 is a block diagram showing a configuration of an image processing apparatus for identifying a bank card according to an embodiment of the present invention.
As shown in fig. 9, an image processing apparatus for identifying a bank card according to an embodiment of the present invention includes:
the image acquisition module 100 is used for acquiring an initial image of the bank card;
an edge detection module 200, configured to detect edge pixel points of the initial image, and separate a bank card image from the initial image based on the edge pixel points;
the outer frame positioning module 300 is configured to mark a plurality of line segments from edge pixel points of the bank card image, and determine a quadrilateral area as an outer frame of the bank card according to the plurality of line segments; and
and the posture transformation module 400 is used for carrying out posture transformation on the outer frame of the bank card based on the preset size proportion of the bank card to obtain the image of the bank card in the just-facing state.
The image acquisition module 100 may be implemented by a camera, for example, and the camera acquires an initial image of the bank card by scanning or shooting, but in the present invention, the bank card does not need to be aligned to a preset bank card frame as in the prior art, but the bank card is placed on a card surface on a desktop without being blocked.
Wherein the edge detection module 200 employs the Prewitt algorithm. It is preferred that the edge detection module 200 employ a Prewitt algorithm with high and low thresholds. The specific contents of the Prewitt algorithm using the high and low thresholds are as follows:
(a) firstly, setting a high threshold and a low threshold, determining the high threshold by taking the edge pixel point ratio as M, and setting the low threshold as N, wherein M > N, and the value standard of the high threshold is as follows: when the threshold value is equal to the value, it is determined that the number of edge pixels/the number of all pixels in the entire image is M, and thus 0< M < 1. Wherein, M may take a value of, for example, 5%, 10%, 15%, 20%, 30%, etc., without any limitation, and N may take a value lower than that of M, for example, N may be 1/2 of M, 1/3 of M, etc., and N is also not limited herein;
(b) respectively detecting the images by using the determined high threshold and low threshold, thereby correspondingly detecting a strong edge image and a weak edge image;
(c) taking the strong edge image as a main body, if the weak edge is connected with the main body, keeping the weak edge, and otherwise, abandoning the weak edge; and
(d) and performing morphological denoising as a final result.
The outer frame positioning module 300 marks a plurality of line segments from the edge points by using a Hough linear detection algorithm.
When the bank card is placed on a desktop for scanning or shooting, the outer frame positioning module 300 is configured as follows:
marking a plurality of line segments from the edge points by using a Hough linear detection algorithm;
classifying and merging the line segments, namely classifying the line segments on the same straight line into one class, merging similar line segments with close distances, and discarding the isolated and shorter line segments;
two pairs of parallel line segments that can enclose a quadrilateral are determined, for example, whether the line segments are parallel can be determined by: the angle difference of the line segments is within a certain range, if the angle difference is less than or equal to 10 degrees, the line segments can be considered as parallel, on the other hand, the two pairs of parallel line segments are approximately perpendicular to each other, and the end points of the line segments are close to each other, so that straight lines are summarized to form a quadrilateral outer frame;
the area of the quadrangle is calculated, if the ratio of the area of the quadrangle to the total area of the whole image is above a specified ratio, the quadrangle area is considered to be the position of the bank card, for example, the specified ratio can be set to any value of 20% -80%, if the specified ratio is set to 50%, the obtained quadrangle is considered to be valid if the ratio of the area of the quadrangle to the total area of the whole image is greater than or equal to 50%, and if the ratio is less than 50%, the obtained quadrangle is considered to be invalid and the quadrangle is discarded. The purpose of setting the prescribed ratio is to eliminate the interference of possible small quadrangles in the background, and to make the bank card area large enough to ensure the feasibility and accuracy of the subsequent card number identification.
As another alternative, when the hand-held bank card is scanned or photographed, the outer frame positioning module 300 is configured as follows:
marking a plurality of line segments from the edge points by using a Hough linear detection algorithm, wherein the line segments of 2 sides in the outer frame have parts shielded by fingers;
classifying and merging the line segments, namely classifying the line segments on the same straight line into one class, merging the similar line segments with close distance, abandoning the isolated and shorter line segments, then, carrying out more and proper extension on two sides (namely the line segments of 2 sides in the outer frame have parts blocked by fingers), and determining two pairs of parallel line segments which can be enclosed into a quadrangle so as to form a proper quadrangle;
two pairs of parallel line segments that can enclose a quadrilateral are determined, for example, whether the line segments are parallel can be determined by: the angle difference of the line segments is within a certain range, if the angle difference is less than or equal to 10 degrees, the line segments can be considered as parallel, on the other hand, the two pairs of parallel line segments are approximately perpendicular to each other, and the end points of the line segments are close to each other, so that straight lines are summarized to form a quadrilateral outer frame;
calculating the area of the quadrangle, and if the ratio of the area of the quadrangle to the total area of the whole image is above a specified ratio, then the quadrangle area is considered to be the location of the bank card, for example, the specified ratio can be set to any value in the range of 20% -80%, for example, in the case of setting to 50%, when the ratio of the area of the quadrangle to the total area of the whole image is greater than or equal to 50%, the obtained quadrangle is considered to be valid, and if the ratio is less than 50%, the obtained quadrangle is considered to be invalid, and the quadrangle is discarded. The purpose of setting the prescribed ratio is to eliminate the interference of possible small quadrangles in the background, and to make the bank card area large enough to ensure the feasibility and accuracy of the subsequent card number identification.
The posture transformation module 400 stretches the bank card housing according to the proportion of 85.60:53.98 and rotates the bank card housing by the degree of the included angle between the long edge in the bank card housing and the horizontal plane.
Based on the above, according to the image processing method for identifying the bank card and the image processing device for identifying the bank card of the present invention, the operation difficulty of the user can be reduced, and the convenient card binding can be realized, and specifically, the following technical characteristics can be provided:
(1) the bank card surface can be identified under the condition that the bank card surface is not parallel to the camera;
(2) the edge of the bank card does not need to be overlapped with the scanning frame, and the bank card is only required to be wholly positioned in the scanning frame and the area ratio exceeds a preset specified value;
(3) the algorithm complexity is small, and the method can be operated in real time at an embedded front end, wherein the embedded front end refers to terminal equipment with an embedded processor, such as a mobile phone, a tablet and other intelligent equipment with a camera (but not including a computer or a server).
Therefore, as described above, the image processing method for identifying a bank card and the image processing apparatus for identifying a bank card of the present invention can be applied to a wider image binding scene, thereby achieving convenience of user card binding operation, and because the complexity of the algorithm is small, the requirement of real-time operation at the embedded device end can be achieved.
In addition, the invention also provides a mobile terminal which is provided with the image processing device for identifying the bank card.
The invention also provides a computer-readable medium, on which a computer program is stored, characterized in that the computer program, when executed by a processor, implements the above-mentioned image processing method for identifying a bank card.
The invention also provides computer equipment which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, and is characterized in that the processor executes the computer program to realize the image processing method for identifying the bank card.
The above examples mainly illustrate the image processing method and image processing method for identifying a bank card of the present invention. Although only a few embodiments of the present invention have been described in detail, those skilled in the art will appreciate that the present invention may be embodied in many other forms without departing from the spirit or scope thereof. Accordingly, the present examples and embodiments are to be considered as illustrative and not restrictive, and various modifications and substitutions may be made therein without departing from the spirit and scope of the present invention as defined by the appended claims.

Claims (22)

1. An image processing method for identifying a bank card, comprising the steps of:
an image acquisition step, which is to acquire an initial image of the bank card;
an edge detection step, namely detecting edge pixel points of the initial image so as to separate a bank card image from the initial image;
an outer frame positioning step, namely marking a plurality of line segments from edge pixel points of the bank card image, and determining a quadrilateral area as an outer frame of the bank card according to the line segments; and
and a posture transformation step, namely performing posture transformation on the outer frame of the bank card based on the preset size proportion of the bank card to obtain the image of the bank card in the just-facing state.
2. The image processing method for identifying a bank card according to claim 1,
a Prewitt algorithm is employed in the edge detection step.
3. The image processing method for identifying a bank card according to claim 1,
and adopting a Prewitt algorithm with high and low thresholds in the edge detection step.
4. The image processing method for identifying a bank card according to claim 3, wherein the edge detection step comprises:
(a) setting a high threshold M and a low threshold N, wherein 0< M <1, 0< N <1 and M > N;
(b) respectively detecting the initial image by using the high threshold M and the low threshold N, thereby respectively detecting a strong edge image and a weak edge image;
(c) taking the strong edge image as a main body, if the weak edge is connected with the main body, keeping the weak edge, and otherwise, abandoning the weak edge; and
(d) and performing morphological denoising to finally separate the bank card image from the initial image.
5. The image processing method for identifying a bank card according to claim 4,
setting the low threshold N to be half of the high threshold M.
6. The image processing method for identifying a bank card according to claim 1,
in the outer frame positioning step, a plurality of line segments are marked from the edge points by adopting a Hough linear detection algorithm.
7. The image processing method for identifying a bank card according to claim 1,
the outer frame positioning step comprises the following steps:
marking a plurality of line segments from the edge points by adopting a Hough linear detection algorithm;
classifying and merging the line segments;
determining two pairs of parallel line segments which can form a quadrangle;
and calculating the area of the enclosed quadrangle, and if the ratio of the area of the quadrangle to the total area of the whole image is greater than a preset specified value, determining that the quadrangle area is the position of the bank card.
8. The image processing method for identifying a bank card according to claim 1,
the outer frame positioning step comprises the following steps:
marking a plurality of line segments from the edge points by adopting a Hough linear detection algorithm;
classifying and merging the line segments;
extending two sides of the classified and combined line segments to obtain two pairs of parallel line segments which can form a quadrangle, and forming the quadrangle; and
and calculating the area of the enclosed quadrangle, and if the ratio of the area of the quadrangle to the total area of the whole image is greater than a preset specified value, determining that the quadrangle area is the position of the bank card.
9. The image processing method for identifying a bank card according to claim 7 or 8,
classifying and merging the line segments comprises: and classifying the line segments on the same straight line into one class, merging the similar line segments with close distances, and discarding the isolated and shorter line segments.
10. The image processing method for identifying a bank card according to claim 7 or 8,
the preset specified value is 20-80%.
11. The image processing method for recognizing a bank card according to claim 1, wherein the posture transforming step comprises:
stretching the outer frame of the bank card according to the proportion of 85.60: 53.98; and
and rotating the bank card outer frame by the degree of an included angle between the long edge in the bank card outer frame and the horizontal plane.
12. An image processing apparatus for recognizing a bank card, comprising:
the image acquisition module is used for acquiring an initial image of the bank card;
the edge detection module is used for detecting edge pixel points of the initial image and separating a bank card image from the initial image based on the edge pixel points;
the outer frame positioning module is used for marking a plurality of line segments from edge pixel points of the bank card image and determining a quadrilateral area as a bank card outer frame according to the line segments; and
and the posture transformation module is used for carrying out posture transformation on the outer frame of the bank card based on the preset size proportion of the bank card to obtain the image of the bank card in the just-right state.
13. The image processing apparatus for identifying a bank card according to claim 12,
the edge detection module adopts a Prewitt algorithm.
14. The image processing apparatus for identifying a bank card according to claim 12,
the edge detection module adopts a Prewitt algorithm with high and low thresholds.
15. The image processing apparatus for identifying a bank card of claim 14,
setting a high threshold value M and a low threshold value N in the edge detection module, wherein 0< M <1, 0< N <1 and M > N, respectively detecting the initial image by using the high threshold value M and the low threshold value N, thereby respectively detecting a strong edge image and a weak edge image, taking the strong edge image as a main body, if the weak edge is connected with the main body, keeping the weak edge, otherwise, abandoning the weak edge image, and performing morphological denoising to finally separate the bank card image from the initial image.
16. The image processing apparatus for identifying a bank card according to claim 12,
the outer frame positioning module marks a plurality of line segments from the edge points by adopting a Hough linear detection algorithm.
17. The image processing apparatus for identifying a bank card according to claim 12,
the outer frame positioning module marks a plurality of line segments from edge points by adopting a Hough linear detection algorithm, classifies and merges the line segments to determine two pairs of parallel line segments which can form a quadrangle, calculates the area of the enclosed quadrangle, and if the ratio of the area of the quadrangle to the total area of the whole image is greater than a preset specified value, the quadrangle area is considered to be the position of the bank card.
18. The image processing apparatus for identifying a bank card according to claim 12,
the outer frame positioning module marks a plurality of line segments from edge points by adopting a Hough linear detection algorithm, classifies and merges the line segments, extends the line segments after classification and merging at two ends to obtain and determine two pairs of parallel line segments which can be enclosed into a quadrangle, forms the quadrangle, calculates the area of the enclosed quadrangle, and if the ratio of the area of the quadrangle to the total area of the whole image is greater than a preset specified value, the quadrangle area is considered to be the position of the bank card.
19. The image processing apparatus for identifying a bank card according to claim 1,
the posture transformation module stretches the outer frame of the bank card according to the proportion of 85.60:53.98 and rotates the outer frame of the bank card by the degree of an included angle between the long edge in the outer frame of the bank card and the horizontal plane.
20. A mobile terminal, characterized in that,
an image processing device for identifying a bank card according to any one of claims 12 to 19.
21. A computer-readable medium, having stored thereon a computer program,
the computer program, when executed by a processor, implements the image processing method for identifying a bank card of any one of claims 1 to 11.
22. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the image processing method for identifying a bank card according to any one of claims 1 to 11 when executing the computer program.
CN201910869801.4A 2019-09-16 2019-09-16 Image processing method and image processing device for identifying bank card Pending CN112507759A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910869801.4A CN112507759A (en) 2019-09-16 2019-09-16 Image processing method and image processing device for identifying bank card

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910869801.4A CN112507759A (en) 2019-09-16 2019-09-16 Image processing method and image processing device for identifying bank card

Publications (1)

Publication Number Publication Date
CN112507759A true CN112507759A (en) 2021-03-16

Family

ID=74923912

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910869801.4A Pending CN112507759A (en) 2019-09-16 2019-09-16 Image processing method and image processing device for identifying bank card

Country Status (1)

Country Link
CN (1) CN112507759A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007058634A (en) * 2005-08-25 2007-03-08 Ricoh Co Ltd Image processing method and image processor, digital camera equipment, and recording medium with image processing program stored thereon
CN106407980A (en) * 2016-11-03 2017-02-15 贺江涛 Image processing-based bank card number recognition method
CN108665495A (en) * 2017-03-30 2018-10-16 展讯通信(上海)有限公司 Image processing method and device, mobile terminal
CN109685074A (en) * 2018-10-17 2019-04-26 福州大学 A kind of bank card number row localization method based on Scharr operator

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007058634A (en) * 2005-08-25 2007-03-08 Ricoh Co Ltd Image processing method and image processor, digital camera equipment, and recording medium with image processing program stored thereon
CN106407980A (en) * 2016-11-03 2017-02-15 贺江涛 Image processing-based bank card number recognition method
CN108665495A (en) * 2017-03-30 2018-10-16 展讯通信(上海)有限公司 Image processing method and device, mobile terminal
CN109685074A (en) * 2018-10-17 2019-04-26 福州大学 A kind of bank card number row localization method based on Scharr operator

Similar Documents

Publication Publication Date Title
Ahmed Comparative study among Sobel, Prewitt and Canny edge detection operators used in image processing
EP2783328B1 (en) Text detection using multi-layer connected components with histograms
JP5542889B2 (en) Image processing device
JP5699788B2 (en) Screen area detection method and system
US7133572B2 (en) Fast two dimensional object localization based on oriented edges
US8712114B2 (en) Elegant solutions for fingerprint image enhancement
CN108982512A (en) A kind of circuit board detecting system and method based on machine vision
KR20150117646A (en) Method and apparatus for image enhancement and edge verification using at least one additional image
US10303969B2 (en) Pose detection using depth camera
US9245194B2 (en) Efficient line detection method
WO2014184372A1 (en) Image capture using client device
CN108171674B (en) Vision correction method for projector image with any visual angle
KR20160037305A (en) Method for User Authentication using Fingerprint Recognition
CN113283439B (en) Intelligent counting method, device and system based on image recognition
CN110738604A (en) Canny operator and Hough transformation-based large-dip angle certificate image correction method and system
JP3915621B2 (en) Lane mark detector
CN112507759A (en) Image processing method and image processing device for identifying bank card
Toyoura et al. Mono-spectrum marker: an AR marker robust to image blur and defocus
WO2019237560A1 (en) Border and page number scanning system
KR101829386B1 (en) Apparatus and method for detecting target
CN114359322A (en) Image correction and splicing method, and related device, equipment, system and storage medium
Guerreiro et al. Extraction of line segments in cluttered images via multiscale edges
CN112329572B (en) Rapid static living body detection method and device based on frame and flash point
JP2008181261A (en) Method and device for extracting contour line of object
Chethan et al. A Comparative Analysis of Different Edge Based Algorithms for Mobile/Camera Captured Images

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination