Summary of the invention
Consider the technical matters occurred in correlation technique, the invention provides a kind of polygon detecting technology, the target polygon in image can be detected accurately.
According to an aspect of the present invention, provide a kind of polygon detecting method, comprising: the edge image obtaining input picture; Many straight lines to be selected are extracted from described edge image; Divided into groups by described many straight lines to be selected, often group comprises n bar limit, and calculates n the intersection point on described n bar limit, using the candidate vertices of a described n intersection point as n limit shape; Corner Detection is carried out to described input picture, obtains one group of candidate vertices maximum with described angle point similarity, using the summit as described n limit shape.
In the present embodiment, straight line is combined with the detection of angle point, utilizes two kinds of constraints jointly to detect target polygon, propose a kind of based on straight line and the polygonal algorithm of Corner Detection target, make use of known conditions better, there is detection feature fast and accurately.
Wherein, the edge image of described acquisition input picture, specifically comprises: convert described input picture to gray level image; Use edge detector to carry out rim detection to described gray level image, and bulk processing is added to the edge detected, obtain described edge image.
In technique scheme, preferably, describedly from described edge image, extract many straight lines to be selected, specifically comprise: Hough transformation is carried out to described edge image; Connecting line segment is found out, using the connecting line segment that finds out as described many straight lines to be selected according to Hough transformation peak value.
After edge image makes Hough transformation, find obvious Hough transformation peak value, then utilize the peak value found, search and connecting line segment.For image length and wide in smaller value L, if the distance between find two line segments is less than L/16, then they are merged into a long line segment, finally only get the line segment that length is greater than L/4.Such basic assumption is that the size of target polygon in picture can not be little especially, and its edge may be blocked.This strategy can get rid of a part of line segment, and for zone boundary by noise or hidden by other objects and cause border occur some be interrupted situation had better fault-tolerance and robustness.
In technique scheme, preferably described Corner Detection is carried out to described input picture, specifically comprises: calculate each point in described input picture in the x direction with y direction on the difference of consecutive point; Usage criteria function obtains angle point response with described difference for parameter calculates; When described angle point response is greater than preset value, determine that this point is an angle point.
In technique scheme, preferably described described many straight lines to be selected to be divided into groups, specifically comprise: according to the slope range on the limit of n limit shape, choose the straight line of straight slope in described slope range; According to the central point of the straight line chosen relative to the position of image, the straight line chosen is divided into n group; From described n group, take out straight line respectively, obtain n bar straight line, described n bar straight line, as one group, obtains new some groups.
According to a further aspect in the invention, additionally provide a kind of polygon detecting device, comprising: acquiring unit, be connected to extraction unit, obtain the edge image of input picture; Described extraction unit, is connected to grouped element, for extracting many straight lines to be selected from described edge image; Described grouped element, is connected to matching unit, and for being divided into groups by described many straight lines to be selected, often group comprises n bar limit, and calculates n the intersection point on described n bar limit, using the candidate vertices of a described n intersection point as n limit shape; Described matching unit, for carrying out Corner Detection to described input picture, obtains one group of candidate vertices maximum with described angle point similarity, using the summit as described n limit shape.
In the present embodiment, straight line is combined with the detection of angle point, utilizes two kinds of constraints jointly to detect target polygon, propose a kind of based on straight line and the polygonal algorithm of Corner Detection target, make use of known conditions better, there is detection feature fast and accurately.
In technique scheme, preferably, described acquiring unit comprises: converting unit, for converting described input picture to gray level image; Detecting unit, for using edge detector to carry out rim detection to described gray level image, and adding bulk processing to the edge detected, obtaining described edge image.
In technique scheme, preferably, described extraction unit comprises: Hough transformation unit, for carrying out Hough transformation to described edge image; Search unit, for finding out connecting line segment according to Hough transformation peak value, using the connecting line segment that finds out as described many straight lines to be selected.
After edge image makes Hough transformation, find obvious Hough transformation peak value, then utilize the peak value found, search and connecting line segment.For image length and wide in smaller value L, if the distance between find two line segments is less than L/16, then they are merged into a long line segment, finally only get the line segment that length is greater than L/4.Such basic assumption is that the size of target polygon in picture can not be little especially, and its edge may be blocked.This strategy can get rid of a part of line segment, and for zone boundary by noise or hidden by other objects and cause border occur some be interrupted situation had better fault-tolerance and robustness.
In technique scheme, preferably, described matching unit comprises: computing unit, for calculate each point in described input picture in the x direction with y direction on the difference of consecutive point, usage criteria function obtains angle point response with described difference for parameter calculates; Judging unit, when described angle point response is greater than preset value, determines that this point is an angle point.
In technique scheme, preferably, described grouped element comprises: choose unit, for the slope range on the limit according to n limit shape, chooses the straight line of straight slope in described slope range; Allocation units, for according to the central point of straight line chosen relative to the position of image, the described straight line choosing unit selection is divided into n group; Assembled unit, for taking out straight line respectively from described n group, obtains n bar straight line, and described n bar straight line, as one group, obtains new some groups.
Embodiment
In order to more clearly understand above-mentioned purpose of the present invention, feature and advantage, below in conjunction with the drawings and specific embodiments, the present invention is further described in detail.It should be noted that, when not conflicting, the feature in the embodiment of the application and embodiment can combine mutually.
Set forth a lot of detail in the following description so that fully understand the present invention, but the present invention can also adopt other to be different from other modes described here and implement, and therefore, the present invention is not limited to the restriction of following public specific embodiment.
Fig. 1 shows the schematic flow diagram of polygon detecting method according to an embodiment of the invention.
As shown in Figure 1, polygon detecting method can comprise the following steps according to an embodiment of the invention:
Step 102, obtains the edge image of input picture; Step 104, extracts many straight lines to be selected from edge image; Many straight lines to be selected are divided into groups by step 106, and often group comprises n bar limit, and calculate n the intersection point on n bar limit, using the candidate vertices of n intersection point as n limit shape; Step 108, carries out Corner Detection to input picture, obtains one group of candidate vertices maximum with angle point similarity, using the summit as n limit shape.
In the present embodiment, straight line is combined with the detection of angle point, utilizes two kinds of constraints jointly to detect target polygon, propose a kind of based on straight line and the polygonal algorithm of Corner Detection target, make use of known conditions better, there is detection feature fast and accurately.
Wherein, the edge image of described acquisition input picture, specifically comprises: convert described input picture to gray level image; Use edge detector to carry out rim detection to described gray level image, and bulk processing is added to the edge detected, obtain described edge image.
In technique scheme, preferably, describedly from described edge image, extract many straight lines to be selected, specifically comprise: Hough transformation is carried out to described edge image; Connecting line segment is found out, using the connecting line segment that finds out as described many straight lines to be selected according to Hough transformation peak value.
After edge image makes Hough transformation, find obvious Hough transformation peak value, then utilize the peak value found, search and connecting line segment.For image length and wide in smaller value L, if the distance between find two line segments is less than L/16, then they are merged into a long line segment, finally only get the line segment that length is greater than L/4.Such basic assumption is that the size of target polygon in picture can not be little especially, and its edge may be blocked.This strategy can get rid of a part of line segment, and for zone boundary by noise or hidden by other objects and cause border occur some be interrupted situation had better fault-tolerance and robustness.
In technique scheme, preferably described Corner Detection is carried out to described input picture, specifically comprises: calculate each point in described input picture in the x direction with y direction on the difference of consecutive point; Usage criteria function obtains angle point response with described difference for parameter calculates; When described angle point response is greater than preset value, determine that this point is an angle point.
In technique scheme, preferably described described many straight lines to be selected to be divided into groups, specifically comprise: according to the slope range on the limit of n limit shape, choose the straight line of straight slope in this scope; According to the central point of the straight line chosen relative to the position of image, the straight line chosen is divided into n group; From described n group, take out straight line respectively, obtain n bar straight line, described n bar straight line, as one group, obtains new some groups.
Be that preferred embodiment illustrates according to polygon detecting method of the present invention hereinafter with quadrilateral.
Fig. 2 shows the schematic flow diagram of quadrilateral detection method according to an embodiment of the invention.
As shown in Figure 2, step 102, is converted to gray level image I by input picture.Use Canny edge detector, to gray level image I Edge detected, and edge carries out the expansion process of ± 3 pixels, makes edge lengthen overstriking, obtains edge image.
Step 104, edge image makes Hough transformation.
Step 106, finds 16 obvious Hough transformation peak values, then utilizes the peak value found, and searches and connecting line segment.For image length and wide in smaller value L, if the distance between find two line segments is less than L/16, then they are merged into a long line segment, finally only get the line segment that length is greater than L/4.Such basic assumption is that the size of object quadrangle in picture can not be little especially, and its edge may be blocked.This strategy can get rid of a part of line segment, and for zone boundary by noise or hidden by other objects and cause border occur some be interrupted situation had better fault-tolerance and robustness.
Step 108, the line segment number detected, if be less than 4, then enter step 110, reduce and judge the threshold value of peak value, then repeat step 108, if threshold value drops to 0 or inspection does not measure at least 4 line segments, think there is no obvious quadrilateral in former picture, otherwise all line segments are expanded to straight line.
Step 112, if the absolute value of straight slope is greater than 1, so judges the limit of straight line as vertical direction, and for the limit of vertical direction, if the central point of straight line is at left one side of something of image, then this straight line is included into left side group, otherwise is included into the right group.In like manner slope absolute value is less than or equal to 1, is the limit of horizontal direction, and central point is upper at image, is included into top group, otherwise following group.So just straight line is divided in order to 4 groups.
Step 114, if after being divided into group, existing empty group, then enters step 124, think and can not find object quadrangle, otherwise enter step 116.
Step 116, carries out harris Corner Detection to gray scale picture, obtains the angle point response function value of each point.Concrete grammar is the difference of each some consecutive point in the x and y direction in computed image, and utilizes criterion function with the value of difference for parameter calculates the value R obtaining the response of harris angle point, and this value is higher, represents the more approximate angle point of this point.
Step 118, takes out 1 straight line respectively at every turn from 4 groups of straight lines, and totally 4 straight lines are one group of candidate limit.4 candidate vertices are calculated with these 4 candidate limits.Utilize candidate vertices to carry out the judgement of quadrilateral position: if the position on summit has been arrived outside picture, get rid of this group candidate vertices.Otherwise, calculate the R value sum on these 4 summits.
Step 120, if all candidate vertices are all excluded, then think and can not find object quadrangle, otherwise enter step 122.
Step 122, gets R value and that maximum group summit, is the object quadrangle summit detected, thus detects object quadrangle.
Said method uses Canny rim detection, and it extracts edge in image.On this basis, use Hough transformation, find the method detection of straight lines of totalizer peak value at Hough parameter space.The straight line all detections obtained is divided into 4 groups according to position and slope, get each one of straight line in 4 groups at every turn, obtain 4 quadrilateral summits to be selected, enumerate the summit of all quadrilaterals to be selected, by harris Corner Detection, calculate the quadrilateral summit of 4 points for detecting of most likely angle point.Straight line and angle point two aspect are considered by the present invention simultaneously, make full use of the character of quadrilateral, improve the accuracy detecting object quadrangle.
Fig. 3 shows the block diagram of polygon detecting device according to an embodiment of the invention.
As shown in Figure 3, polygon detecting device 300 comprises according to an embodiment of the invention: acquiring unit 302, is connected to extraction unit 304, obtains the edge image of input picture; Described extraction unit 304, is connected to grouped element 306, for extracting many straight lines to be selected from described edge image; Described grouped element 306, is connected to matching unit 308, and for being divided into groups by described many straight lines to be selected, often group comprises n bar limit, and calculates n the intersection point on described n bar limit, using the candidate vertices of a described n intersection point as n limit shape; Described matching unit 308, for carrying out Corner Detection to described input picture, obtains one group of candidate vertices maximum with described angle point similarity, using the summit as described n limit shape.In the present embodiment, straight line is combined with the detection of angle point, utilizes two kinds of constraints jointly to detect target polygon, propose a kind of based on straight line and the polygonal algorithm of Corner Detection target, make use of known conditions better, there is detection feature fast and accurately.
In technique scheme, preferably, described acquiring unit 302 comprises: converting unit 3022, for converting described input picture to gray level image; Detecting unit 3024, for using edge detector to carry out rim detection to described gray level image, and adding bulk processing to the edge detected, obtaining described edge image.
In technique scheme, preferably, described extraction unit 304 comprises: Hough transformation unit 3042, for carrying out Hough transformation to described edge image; Search unit 3044, for finding out connecting line segment according to Hough transformation peak value, using the connecting line segment that finds out as described many straight lines to be selected.After edge image makes Hough transformation, find obvious Hough transformation peak value, then utilize the peak value found, search and connecting line segment.For image length and wide in smaller value L, if the distance between find two line segments is less than L/16, then they are merged into a long line segment, finally only get the line segment that length is greater than L/4.Such basic assumption is that the size of target polygon in picture can not be little especially, and its edge may be blocked.This strategy can get rid of a part of line segment, and for zone boundary by noise or hidden by other objects and cause border occur some be interrupted situation had better fault-tolerance and robustness.
In technique scheme, preferably, described matching unit 308 comprises: computing unit 3082, for calculate each point in described input picture in the x direction with y direction on the difference of consecutive point, usage criteria function obtains angle point response with described difference for parameter calculates; Judging unit 3084, when described angle point response is greater than preset value, determines that this point is an angle point.
In technique scheme, preferably, described grouped element 306 comprises: choose unit 3062, for the slope range on the limit according to n limit shape, chooses the straight line of straight slope in described slope range; Allocation units 3064, for according to the central point of straight line chosen relative to the position of image, the described straight line choosing unit selection is divided into n group; Assembled unit 3066, for taking out straight line respectively from described n group, obtains n bar straight line, and described n bar straight line, as one group, obtains new some groups.
More than being described with reference to the accompanying drawings according to technical scheme of the present invention, the target Polygon position in image can have been detected according to above method when not having other prioris.In actual applications, having more priori, by revising the threshold value of above-mentioned function, these prioris can be effectively utilized, thus more tally with the actual situation and detect target polygon more accurately.Further, the thought of grouping can expand to and be divided into any group, and this method also just can expand to the method detecting arbitrary polygon, has very strong extendability.
The foregoing is only the preferred embodiments of the present invention, be not limited to the present invention, for a person skilled in the art, the present invention can have various modifications and variations.Within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.