Invention content
The embodiment of the present application provides a kind of method, apparatus and storage device based on limb recognition card.Solve due to
Card angle in picture is not fixed, it is difficult to train a model problem for supporting the detection of multi-angle card, solve simultaneously
Due to computationally intensive, the problem of embedded device is difficult to meet real-time processing requirement.
The embodiment of the present application provides a kind of method based on limb recognition card, and this method includes:
Detect the edge of card;
The corresponding pixel in the edge of the card is converted to the sine curve of Hough Hough parameter spaces;Wherein, just
The intersection point of chord curve is peak point;
The ballot poll of the peak point is obtained according to the ballot accumulator of Hough parameter spaces;
Candidate region is determined according to the ballot poll of the peak point;
The determining candidate region is matched with angle card template, obtains card recognition result.
Further, the edge of the detection card includes:
It is respectively Gx and Gy to calculate pixel gradient in the directions x and the directions y in theorem in Euclid space using sobel operators;
The pixel is added in the directions x with the gradient absolute value in the directions y, the global gradient G of the pixel is obtained;
Global gradient G is more than the pixel of predetermined gradient threshold value as the edge of card.
Further, the gradient direction θ of the corresponding pixel in the edge is θ=arctan2 (Gy, Gx), theorem in Euclid space
Distance ρ=x of the origin to the corresponding pixel in the edge0cosθ+y0sinθ;Wherein, the corresponding pixel in the edge is in Europe
Formula is expressed as (x in space0,y0), it is expressed as in Hough parameter spaces (ρ, θ).
Further, the ballot poll according to the peak point determines that candidate region includes:
The peak point for being more than default poll threshold value according to the ballot poll determines directed line;
Candidate region is formed using the directed line.
Further, the condition for forming candidate region includes:
The angle that the opposite directed line in direction is formed is within the scope of preset first angle;With
The distance between opposite directed line in direction is within the scope of pre-determined distance;With
Angle is within the scope of preset second angle between adjacent directed line;With
The direction of directed line should be all clockwise or be all counterclockwise;With
The candidate region size of formation is in default magnitude range.
Further, candidate region efficient frontier point
It is defined as:Gradient direction directed line corresponding with marginal point is consistent, and the marginal point is answered apart from the marginal point pair
Directed line distance be less than pre-determined distance;
It is described to further include using directed line formation candidate region:
Marginal density is more than the candidate region of default marginal density threshold value as final candidate region;Wherein, edge
Density=candidate region efficient frontier point quantity/candidate region perimeter.
Further, described to match the determining candidate region with angle card template, obtain card recognition
As a result include:
Final candidate region is passed through into perspective transform, formation rule figure;
The regular figure of formation is normalized to consistent with angle card template size;
Regular figure after normalization is matched by difference of two squares matching process with angle card model, card is obtained
Recognition result.
Further, the regular figure by after normalization is carried out by difference of two squares matching process and angle card model
Matching, obtaining card recognition result includes:
Utilize formula R (x ", y ")=∑X ', y '(T (x ', y ')-I (x "+x ', y "+y '))2By the regular figure after normalization
It is matched with angle card model;Wherein, R (x ", y ") indicates that matching score, (x ', y ') indicate angle card model edge
Corresponding pixel, the corresponding pixel in regular figure edge after (x ", y ") expression normalization, T (x ', y ') expressions (x ',
Y ') pixel pixel value, I (x "+x ', y "+y ') indicates the pixel value of (x ", y ") pixel;
Using the minimum corresponding angle card model of matching score as card recognition result.
The embodiment of the present application also provides a kind of device based on limb recognition card, which includes:
Storage device, for storing program data;
Processor, for executing the program data in the storage device to realize the above-mentioned side based on limb recognition card
Method.
The embodiment of the present application also provides a kind of storage devices, are stored thereon with program data, and described program data are used for
The above-mentioned method based on limb recognition card is realized when being executed by processor.
The advantageous effect that the application can obtain is, votes the stage in hough, is only more than predetermined gradient threshold value to gradient
Marginal point ballot poll carry out accumulated counts, the interference of noise can be effectively reduced, the straight line detected is more accurate;It supports more
Angle card detects and identification;It is detected the result is that accurate location information, the card image after perspective transform is only
It needs to can reach performance requirement with angle card template matches, needs the grader mould that mass data supports without training
Type.
Specific implementation mode
To keep the purpose, technical scheme and advantage of the application clearer, below in conjunction with the application specific embodiment and
Technical scheme is clearly and completely described in corresponding attached drawing.Obviously, described embodiment is only the application one
Section Example, instead of all the embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not doing
Go out the every other embodiment obtained under the premise of creative work, shall fall in the protection scope of this application.
Fig. 1 is computer composed structure block diagram, and the critical piece of computer is shown.It is processor 110, interior in Fig. 1
115 access system bus 140 of portion's memory 105, bus bridge 120 and network interface, bus bridge 120 are used for bridge system bus
140 and I/O buses 145, I/O interfaces access I/O buses 145, and USB interface and external memory are connect with I/O interfaces.Fig. 1
In, processor 110 can be one or more processors, and each processing can have one or more processor cores;It is interior
Portion's memory 105 is volatile memory, such as register, buffer, various types of random access memory etc.;It is calculating
When machine booting operation, the data in internal storage 105 include operating system and application program;Network interface 115 can be with
For Ethernet interface, optical fiber interface etc.;System bus 140 can be used for data information, address information and control letter
Breath;Bus bridge 120 can be used for carrying out protocol conversion, system bus protocol is converted to I/O agreements or by I/O protocol conversions
It is system bus protocol to realize data transmission;I/O buses 145 are used for data information and control information, can be with bus termination
Resistance or circuit interfere to reduce signal reflex;I/O interfaces 130 are mainly connect with various external equipments, for example, keyboard, mouse,
Sensor etc., flash memory can access I/O buses by USB interface, and external memory is nonvolatile memory, such as firmly
Disk, CD etc..After power the computer, processor can will be stored in external storage digital independent therein to storage inside
In device, and storage inside computer instruction therein is handled, completes the function of operating system and application program.This shows
Example computer can be desktop computer, laptop, tablet computer, smart mobile phone etc..
Fig. 2 is a kind of flow diagram of the method based on limb recognition card provided by the embodiments of the present application, the flow
Schematic diagram includes:
Step 205, the edge of card is detected;
In the present embodiment, for identifying the quadrangle card in image shown in Fig. 4.Optionally, utilization is shown in fig. 5
It is respectively Gx and Gy that sobel operators, which calculate gradient of the pixel on image shown in Fig. 4 in the directions theorem in Euclid space x and y, specifically
For, when calculating Gx, the picture on card image shown in Fig. 4 is traversed using the left side template of sobel operators template shown in fig. 5
Vegetarian refreshments, the 3rd columns value are multiplied by the pixel value of corresponding three pixels respectively, then by three product additions, result A;1st row
Numerical value is multiplied by the pixel value of corresponding three pixels respectively, then by three product additions, result B;The difference of A and B is
Gx.When calculating Gy, the pixel on image shown in Fig. 4 is traversed using the right template of sobel operators template shown in fig. 5,
1st line number value is multiplied by the pixel value of corresponding three pixels respectively, then by three product additions, result C;3rd line number value
It is multiplied by the pixel value of corresponding three pixels respectively, then by three product additions, result D;The difference of C and D is Gy;It will
Gradient G x of the above-mentioned pixel in the directions x with y is added with Gy absolute values, obtains global gradient G=Gx+Gy of the pixel;
Global gradient G is more than predetermined gradient threshold value TGPixel as edge.In the present embodiment, TG values are 40.
Further, the gradient direction θ of the corresponding pixel in above-mentioned edge is θ=arctan2 (Gy, Gx), theorem in Euclid space
Distance ρ=x of the origin to the corresponding pixel in above-mentioned edge0cosθ+y0sinθ;Wherein, the corresponding pixel in above-mentioned edge is in Europe
Formula is expressed as (x in space0,y0), it is expressed as in Hough parameter spaces (ρ, θ).
Step 210, the sine that the corresponding pixel in the edge of the card is converted to Hough Hough parameter spaces is bent
Line;Wherein, sinusoidal intersection point is peak point;
Hough transform is in image procossing from the method for image recognition geometry.It utilizes the duality of point and line, will
The given curve in original image space becomes a point in Hough parameter spaces by curve representation form.So original graph
As the test problems of given curve translate into the spike problem in Hough parameter spaces, that is, detects overall permanence and be converted into inspection
Survey local characteristics.Point in theorem in Euclid space on straight line is a sine curve in Hough parameter spaces;In theorem in Euclid space
Multiple points on same straight line are a sinusoid series in Hough parameter spaces and set of curves intersects at a point, and claim this
Point is peak point.And the peak point under Hough parameter spaces, then the straight line under theorem in Euclid space is corresponded to, as shown in Figure 6.
Pixel is expressed as (x in theorem in Euclid space0,y0), and (ρ, θ) is expressed as in Hough parameter spaces, P points are Hough
Peak point in parameter space, the meaning represented by it are the l straight lines of theorem in Euclid space.Straight line phase is detected with traditional hough
Than detecting directed line.Directional information has important meaning when being subsequently formed polygon, while considering direction in the ballot stage
Information can remove the interference of ambient noise.
In the present embodiment, four sides of the quadrangle card in image shown in Fig. 4 correspond to four of theorem in Euclid space it is straight
Line.Point on four straight lines of theorem in Euclid space is converted to four sinusoidal songs of Hough parameter spaces respectively using Hough transform
Line cluster;Wherein, the intersection point of each sinusoid series is peak point, and above-mentioned peak point corresponds to four straight lines of theorem in Euclid space respectively.
Step 215, the ballot poll of the peak point is obtained according to the ballot accumulator of Hough parameter spaces;
In the present embodiment, in Hough parameter spaces, it is a ballot unit to define 52 ° of pixels.Optionally, it traverses
Hough parameter spaces are each voted the ballot accumulator of unit;The ballot of above-mentioned peak point is obtained according to above-mentioned ballot accumulator
Poll.
Step 220, candidate region is determined according to the ballot poll of the peak point;
Optionally, the peak point for default poll threshold value being more than according to ballot poll determines directed line;Using above-mentioned oriented
Straight line forms candidate region.
Further, in the present embodiment, the peak value that ballot poll is more than maximum poll quantity 5 percent is first counted
Point determines directed line further according to the highest peak point of poll of voting in the peak point counted;It is linear using above-mentioned directed line
Quadrangularly.Since quadrangle sum may be excessively high, in order to reduce quantity, the quadrangle by satisfaction as the condition of candidate region
As candidate region, as shown in Figure 7.
Further, the candidate region of above-mentioned formation needs while meeting the following conditions:The opposite directed line in direction is linear
At angle within the scope of preset first angle;The distance between opposite directed line in direction is within the scope of pre-determined distance;Phase
Angle is within the scope of preset second angle between adjacent directed line;The direction of directed line should be all clockwise or be all
Counterclockwise;The candidate region size of formation is in default magnitude range.
Still further, the candidate region of above-mentioned formation needs while meeting the following conditions:The opposite directed line in direction
The angle of formation is in 180 ± 30 degree;Magnitude range ± 20 picture of the distance between the opposite directed line in direction in card
In element;Angle is in 90 ± 30 degree between adjacent directed line;The direction of directed line should be all clockwise or be all
Counterclockwise;The candidate region size of formation is in size ± 30% of card.
Candidate region as shown in Figure 7 disclosure satisfy that all conditions of above-mentioned formation candidate region, but need further verification
Whether candidate region is true card.Specifically, the candidate region that marginal density is more than to default marginal density threshold value is made
For final candidate region;In the present embodiment, it is 50% to preset marginal density threshold value;Wherein, marginal density=candidate region
Efficient frontier point quantity/candidate region perimeter;In the present embodiment, candidate region efficient frontier point quantity as shown in Figure 7 is 60
Pixel, 100 pixels of candidate region Zhou Changwei, then marginal density is 60%, is more than default marginal density threshold value 50%, then such as Fig. 7
It shown candidate region can be as final candidate region.Efficient frontier point is defined as:Gradient direction is corresponding with marginal point to be had
It is consistent to straight line, and distance of the marginal point apart from the corresponding directed line of the marginal point is less than pre-determined distance.In the present embodiment
In, above-mentioned pre-determined distance is 3 pixels.
Step 225, the determining candidate region is matched with angle card template, obtains card recognition result;
Optionally, final candidate region is passed through into perspective transform, formation rule figure;By the regular figure of formation
It normalizes to consistent with angle card template size;Regular figure after normalization is passed through into difference of two squares matching process and angle card
Piece model is matched, and card recognition result is obtained.
Further, formula R (x ", y ")=∑ is utilizedX ', y '((x "+x ', y "+y ' 2 will be after normalization by T (x ', y ')-I
Regular figure is matched with angle card model;Wherein, R (x ", y ") indicates that matching score, (x ', y ') indicate angle card
The corresponding pixel of edge of model, (x ", y ") indicate the corresponding pixel in regular figure edge after normalization, T (x ', y ') table
Show the pixel value of (x ', y ') pixel, I (x "+x ', y "+y ') indicates the pixel value of (x ", y ") pixel;By minimum matching
The corresponding angle card model of score is as card recognition result.
Still further, in the present embodiment, the quadrangle card in image shown in Fig. 4 has corresponding four angle cards
Model, four angles are respectively 0 degree, 90 degree, 180 degree and 270 degree.Utilize formula R (x ", y ")=∑X ', y '(T (x ', y ')-I
(x "+x ', y "+y '))2By the regular rectangular shape after normalization respectively with 0 degree, 90 degree, 180 degree and 270 degree of angle card models into
Row matching, it is respectively 10,40,60 and 90 to obtain matching score;By minimum 10 corresponding 0 degree of angle card models of matching score
As card recognition result.It is matched by difference of two squares matching process, matching score is smaller, and matching result is more accurate.
Compared with prior art, the advantageous effect of the embodiment of the present application is, votes the stage in hough, only big to gradient
Accumulated counts are carried out in the ballot poll of the marginal point of predetermined gradient threshold value, the interference of noise can be effectively reduced, what is detected is straight
Line is more accurate;Support the detection of multi-angle card and identification;It is detected the result is that accurate location information, by perspective transform
Card image afterwards only needs to can reach performance requirement with angle card template matches, needs mass data branch without training
The sorter model of support.
Fig. 3 is a kind of structural schematic diagram of the device based on limb recognition card provided by the embodiments of the present application;The structure
Schematic diagram includes:Storage device 305 and processor 310;
Storage device 305, for storing program data;
Processor 310, for executing the program data in the storage device to realize the edge of detection card;It will be described
The corresponding pixel in edge of card is converted to the sine curve of Hough Hough parameter spaces;Wherein, sinusoidal intersection point is
Peak point;The ballot poll of the peak point is obtained according to the ballot accumulator of Hough parameter spaces;According to the peak point
Ballot poll determines candidate region;The determining candidate region is matched with angle card template, obtains card recognition
As a result.
Compared with prior art, the advantageous effect of the embodiment of the present application is, votes the stage in hough, only big to gradient
Accumulated counts are carried out in the ballot poll of the marginal point of predetermined gradient threshold value, the interference of noise can be effectively reduced, what is detected is straight
Line is more accurate;Support the detection of multi-angle card and identification;It is detected the result is that accurate location information, by perspective transform
Card image afterwards only needs to can reach performance requirement with angle card template matches, needs mass data branch without training
The sorter model of support.
Present invention also provides a kind of storage devices, are stored thereon with program data, described program data are for being handled
The edge of detection card is realized when device executes;It is empty that the corresponding pixel in the edge of the card is converted into Hough Hough parameters
Between sine curve;Wherein, sinusoidal intersection point is peak point;Institute is obtained according to the ballot accumulator of Hough parameter spaces
State the ballot poll of peak point;Candidate region is determined according to the ballot poll of the peak point;By the determining candidate region
It is matched with angle card template, obtains card recognition result.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
Including so that process, method, commodity or equipment including a series of elements include not only those elements, but also wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that wanted including described
There is also other identical elements in the process of element, method, commodity or equipment.
Above is only an example of the present application, it is not intended to limit this application.For those skilled in the art
For, the application can have various modifications and variations.It is all within spirit herein and principle made by any modification, equivalent
Replace, improve etc., it should be included within the scope of claims hereof.