Summary of the invention
The technical issues of in view of occurring in the related technology, the present invention provides a kind of polygon detecting technologies, can be accurate
The target polygon detected in image.
According to an aspect of the invention, there is provided a kind of polygon detecting method, comprising: obtain the edge of input picture
Image;A plurality of straight line to be selected is extracted from the edge image;The a plurality of straight line to be selected is grouped, every group includes n
Side, and the n intersection point on the n side is calculated, using the n intersection point as the candidate vertices of the side n shape;To the input picture
Corner Detection is carried out, one group and the maximum candidate vertices of angle point similarity are obtained, using the vertex as the side n shape.
In the present embodiment, straight line is combined with the detection of angle point, it is jointly more to detect target using two kinds of constraints
Side shape proposes a kind of algorithm based on straight line and Corner Detection target polygon, makes better use of known conditions, has detection
Quick and accurate feature.
Wherein, the edge image for obtaining input picture, specifically includes: the input picture is converted into grayscale image
Picture;Edge detection is carried out to the gray level image using edge detector, and overstriking processing is carried out to the edge detected, is obtained
The edge image.
In the above-mentioned technical solutions, it is preferred that it is described that a plurality of straight line to be selected is extracted from the edge image, it is specific to wrap
It includes: Hough transformation is carried out to the edge image;Connecting line segment is found out according to Hough transformation peak value, the connecting line that will be found out
A plurality of straight line to be selected described in Duan Zuowei.
After making Hough transformation to edge image, apparent Hough transformation peak value is found, then using the peak value found, to look into
Look for simultaneously connecting line segment.The smaller value L in length and width for image, if the distance between two lines section found is less than L/
16, then a long line segment is combined them into, length is finally only taken to be greater than the line segment of L/4.Such basic assumption is that target is more
Size of the side shape in picture will not be especially small, and its edge may be blocked.This strategy can exclude a part of line
Section, and zone boundary by noise jamming or is covered and caused boundary there is a situation where certain interruptions to have by other objects
Better fault-tolerance and robustness.
In the above-mentioned technical solutions, preferred described to input picture progress Corner Detection, it specifically includes: calculating institute
State in input picture each point in the x direction with the difference on the direction y with consecutive points;Usage criteria function is ginseng with the difference
Number, which calculates, obtains angle point response;When the angle point response is greater than preset value, determine that the point is an angle point.
In the above-mentioned technical solutions, preferably described to be grouped a plurality of straight line to be selected, it specifically includes: according to n
While shape while slope range, choose straight line of the straight slope in the slope range;According to the central point of the straight line of selection
Relative to the position of image, the straight line of selection is divided into n group;Straight line is taken out respectively from the n group, obtains n straight line,
The n straight line obtains new several groups as one group.
According to another aspect of the present invention, a kind of polygon detecting device is additionally provided, comprising: acquiring unit is connected to
Extraction unit obtains the edge image of input picture;The extraction unit, is connected to grouped element, is used for from the edge graph
A plurality of straight line to be selected is extracted as in;The grouped element, is connected to matching unit, for carrying out a plurality of straight line to be selected
Grouping, every group includes n side, and calculates the n intersection point on the n side, using the n intersection point as the candidate vertices of the side n shape;
The matching unit obtains one group and the maximum time of angle point similarity for carrying out Corner Detection to the input picture
Vertex is selected, using the vertex as the side n shape.
In the present embodiment, straight line is combined with the detection of angle point, it is jointly more to detect target using two kinds of constraints
Side shape proposes a kind of algorithm based on straight line and Corner Detection target polygon, makes better use of known conditions, has detection
Quick and accurate feature.
In the above-mentioned technical solutions, it is preferred that the acquiring unit includes: converting unit, is used for the input picture
It is converted into gray level image;Detection unit, for carrying out edge detection to the gray level image using edge detector, and to detection
Edge out carries out overstriking processing, obtains the edge image.
In the above-mentioned technical solutions, it is preferred that the extraction unit includes: Hough transformation unit, for the edge
Image carries out Hough transformation;Searching unit, for finding out connecting line segment according to Hough transformation peak value, the connecting line that will be found out
A plurality of straight line to be selected described in Duan Zuowei.
After making Hough transformation to edge image, apparent Hough transformation peak value is found, then using the peak value found, to look into
Look for simultaneously connecting line segment.The smaller value L in length and width for image, if the distance between two lines section found is less than L/
16, then a long line segment is combined them into, length is finally only taken to be greater than the line segment of L/4.Such basic assumption is that target is more
Size of the side shape in picture will not be especially small, and its edge may be blocked.This strategy can exclude a part of line
Section, and zone boundary by noise jamming or is covered and caused boundary there is a situation where certain interruptions to have by other objects
Better fault-tolerance and robustness.
In the above-mentioned technical solutions, it is preferred that the matching unit includes: computing unit, for calculating the input figure
As in each point in the x direction with the difference on the direction y with consecutive points, usage criteria function using the difference be parameter calculate obtain
Obtain angle point response;Judging unit determines that the point is an angle point when the angle point response is greater than preset value.
In the above-mentioned technical solutions, it is preferred that the grouped element includes: selection unit, for according to n while shape while
Slope range chooses straight line of the straight slope in the slope range;Allocation unit, for the center according to the straight line of selection
Position of the point relative to image, is divided into n group for the straight line that the selection unit is chosen;Assembled unit, for dividing from the n group
Not Qu Chu straight line, obtain n straight line, the n straight line obtains new several groups as one group.
Specific embodiment
To better understand the objects, features and advantages of the present invention, with reference to the accompanying drawing and specific real
Applying mode, the present invention is further described in detail.It should be noted that in the absence of conflict, the implementation of the application
Feature in example and embodiment can be combined with each other.
In the following description, numerous specific details are set forth in order to facilitate a full understanding of the present invention, still, the present invention may be used also
To be implemented using other than the one described here other modes, therefore, the present invention is not limited to following public specific realities
Apply the limitation of example.
Fig. 1 shows the schematic flow diagram of the polygon detecting method of embodiment according to the present invention.
As shown in Figure 1, the polygon detecting method of embodiment according to the present invention may comprise steps of:
Step 102, the edge image of input picture is obtained;Step 104, it is extracted from edge image a plurality of to be selected straight
Line;Step 106, a plurality of straight line to be selected is grouped, every group includes n side, and calculate the n intersection point on n side, and n is handed over
Candidate vertices of the point as the side n shape;Step 108, Corner Detection is carried out to input picture, obtains one group and angle point similarity maximum
Candidate vertices, using the vertex as the side n shape.
In the present embodiment, straight line is combined with the detection of angle point, it is jointly more to detect target using two kinds of constraints
Side shape proposes a kind of algorithm based on straight line and Corner Detection target polygon, makes better use of known conditions, has detection
Quick and accurate feature.
Wherein, the edge image for obtaining input picture, specifically includes: the input picture is converted into grayscale image
Picture;Edge detection is carried out to the gray level image using edge detector, and overstriking processing is carried out to the edge detected, is obtained
The edge image.
In the above-mentioned technical solutions, it is preferred that it is described that a plurality of straight line to be selected is extracted from the edge image, it is specific to wrap
It includes: Hough transformation is carried out to the edge image;Connecting line segment is found out according to Hough transformation peak value, the connecting line that will be found out
A plurality of straight line to be selected described in Duan Zuowei.
After making Hough transformation to edge image, apparent Hough transformation peak value is found, then using the peak value found, to look into
Look for simultaneously connecting line segment.The smaller value L in length and width for image, if the distance between two lines section found is less than L/
16, then a long line segment is combined them into, length is finally only taken to be greater than the line segment of L/4.Such basic assumption is that target is more
Size of the side shape in picture will not be especially small, and its edge may be blocked.This strategy can exclude a part of line
Section, and zone boundary by noise jamming or is covered and caused boundary there is a situation where certain interruptions to have by other objects
Better fault-tolerance and robustness.
In the above-mentioned technical solutions, preferred described to input picture progress Corner Detection, it specifically includes: calculating institute
State in input picture each point in the x direction with the difference on the direction y with consecutive points;Usage criteria function is ginseng with the difference
Number, which calculates, obtains angle point response;When the angle point response is greater than preset value, determine that the point is an angle point.
In the above-mentioned technical solutions, preferably described to be grouped a plurality of straight line to be selected, it specifically includes: according to n
While shape while slope range, choose straight line of the straight slope in a range;Central point according to the straight line of selection is opposite
In the position of image, the straight line of selection is divided into n group;Straight line is taken out respectively from the n group, obtains n straight line, it is described
N straight line obtains new several groups as one group.
Hereinafter illustrate polygon detecting method according to the present invention as preferred embodiment using quadrangle.
Fig. 2 shows the schematic flow diagrams of the quadrangle detection method of embodiment according to the present invention.
As shown in Fig. 2, step 102, is converted to gray level image I for input picture.Using Canny edge detector, to ash
It spends image I and detects edge, and carry out the expansion process of ± 3 pixels to edge, so that edge is lengthened overstriking, obtain edge image.
Step 104, Hough transformation is made to edge image.
Step 106,16 apparent Hough transformation peak values are found, then using the peak value found, search simultaneously connecting line segment.
The smaller value L in length and width for image merges them if the distance between two lines section found is less than L/16
At a long line segment, length is finally only taken to be greater than the line segment of L/4.Such basic assumption is that object quadrangle is big in picture
It is small will not be especially small, and its edge may be blocked.This strategy can exclude a part of line segment, and for regional edge
Boundary is by noise jamming or is covered and caused boundary there is a situation where certain interruptions better fault-tolerance and Shandong by other objects
Stick.
Step 108, it checks the line segment number detected, if it is less than 4, then enters step 110, reduce the threshold for determining peak value
Value, then repeatedly step 108, if threshold value drop to 0 or inspection do not measure at least 4 line segments, it is believed that without obvious in original picture
Quadrangle, all line segments are otherwise extended to straight line.
Step 112, if the absolute value of straight slope is greater than 1, straight line is determined for the side of vertical direction, for vertical
The right group is otherwise included into if the central point of straight line, in left one side of something of image, which is included into left side group in the side in direction.Together
It manages slope absolute value and is less than or equal to 1, be the side of horizontal direction, central point is half of on the image, is included into top group, otherwise below
Group.Straight line 4 groups have been divided into thus.
Step 114, if after being divided into group, there are sky groups, then enter step 124, it is believed that can not find object quadrangle, otherwise
Enter step 116.
Step 116, harris Corner Detection is carried out to gray scale picture, obtains the angle point receptance function value of each point.Specifically
Method is to calculate the difference of each point consecutive points in the x and y direction in image, and using criterion function using the value of difference as parameter
The value R for obtaining the response of harris angle point is calculated, this value is higher, represents the more approximate angle point of the point.
Step 118,1 straight line is taken out respectively from 4 groups of straight lines every time, totally 4 straight lines are one group of candidate side.With this 4
Candidate side calculates 4 candidate vertices.The judgement of quadrangle position is carried out using candidate vertices: if picture has been arrived in the position on vertex
Except, exclude this group of candidate vertices.Otherwise, the sum of the R value on this 4 vertex is calculated.
Step 120, if all candidate vertices are all excluded, then it is assumed that can not find object quadrangle, otherwise enter step
122。
Step 122, R value and maximum that group of vertex are taken, for the object quadrangle vertex detected, to detect target
Quadrangle.
Using Canny edge detection, it extracts the edge in image to the above method.On this basis, become using Hough
It changes, detects straight line in the method that Hough parameter space finds accumulator peak value.By it is all detect obtained straight line according to position and
Slope is divided into 4 groups, takes each one, the straight line in 4 groups every time, finds out 4 quadrangle vertex to be selected, enumerates all four sides to be selected
The vertex of shape, by harris Corner Detection, 4 points for calculating most likely angle point are the quadrangle vertex detected.This
Invention considers straight line and two aspect of angle point simultaneously, makes full use of the property of quadrangle, improves the standard of detection object quadrangle
True property.
Fig. 3 shows the block diagram of the polygon detecting device of embodiment according to the present invention.
As shown in figure 3, the polygon detecting device 300 of embodiment according to the present invention includes: acquiring unit 302, connection
To extraction unit 304, the edge image of input picture is obtained;The extraction unit 304, is connected to grouped element 306, for from
A plurality of straight line to be selected is extracted in the edge image;The grouped element 306, is connected to matching unit 308, and being used for will be described
A plurality of straight line to be selected is grouped, and every group includes n side, and calculates the n intersection point on the n side, using the n intersection point as
The candidate vertices of the side n shape;The matching unit 308, for the input picture carry out Corner Detection, obtain one group with it is described
The maximum candidate vertices of angle point similarity, using the vertex as the side n shape.In the present embodiment, by the inspection of straight line and angle point
Survey combines, and is constrained jointly using two kinds to detect target polygon, proposes a kind of more based on straight line and Corner Detection target
The algorithm of side shape, makes better use of known conditions, has the characteristics that detection is quick and accurate.
In the above-mentioned technical solutions, it is preferred that the acquiring unit 302 includes: converting unit 3022, and being used for will be described defeated
Enter image and is converted into gray level image;Detection unit 3024, for carrying out edge inspection to the gray level image using edge detector
It surveys, and overstriking processing is carried out to the edge detected, obtain the edge image.
In the above-mentioned technical solutions, it is preferred that the extraction unit 304 includes: Hough transformation unit 3042, for institute
It states edge image and carries out Hough transformation;Searching unit 3044 will be searched for finding out connecting line segment according to Hough transformation peak value
Connecting line segment out is as a plurality of straight line to be selected.After making Hough transformation to edge image, apparent Hough transformation peak is found
Value, then using the peak value found, to search simultaneously connecting line segment.The smaller value L in length and width for image, if find
The distance between two lines section is less than L/16, then combines them into a long line segment, and length is finally only taken to be greater than the line of L/4
Section.Such basic assumption is that size of the target polygon in picture will not be especially small, and its edge may be blocked.
This strategy can exclude a part of line segment, and zone boundary is covered by noise jamming or by other objects and causes side
There is a situation where certain interruptions better fault-tolerance and robustness on boundary.
In the above-mentioned technical solutions, it is preferred that the matching unit 308 includes: computing unit 3082, described for calculating
Each point is in the x direction with the difference on the direction y with consecutive points in input picture, and usage criteria function is using the difference as parameter
It calculates and obtains angle point response;Judging unit 3084 determines that the point is an angle when the angle point response is greater than preset value
Point.
In the above-mentioned technical solutions, it is preferred that the grouped element 306 includes: selection unit 3062, for according to the side n
The slope range on the side of shape chooses straight line of the straight slope in the slope range;Allocation unit 3064, for according to selection
Straight line position of the central point relative to image, the straight line that the selection unit is chosen is divided into n group;Assembled unit 3066,
For taking out straight line respectively from the n group, n straight line is obtained, the n straight line obtains new several groups as one group.
It has been described in detail above with reference to the accompanying drawings according to the technique and scheme of the present invention, other can not had according to above method
The target Polygon position in image is detected in the case where priori knowledge.In practical applications, more priori knowledges are had,
By modifying the threshold value of above-mentioned function, these priori knowledges can be effectively utilized, to more tally with the actual situation more accurately
Detect target polygon.Also, the thought of grouping, which can be extended to, is divided into any group, and this method can also be extended to detection
The method of arbitrary polygon has very strong scalability.
The foregoing is only a preferred embodiment of the present invention, is not intended to restrict the invention, for the skill of this field
For art personnel, the invention may be variously modified and varied.All within the spirits and principles of the present invention, made any to repair
Change, equivalent replacement, improvement etc., should all be included in the protection scope of the present invention.