CN102774539B - Bar on-line automatic counting method based on modified gradient Hough circle transformation - Google Patents
Bar on-line automatic counting method based on modified gradient Hough circle transformation Download PDFInfo
- Publication number
- CN102774539B CN102774539B CN201210203505.9A CN201210203505A CN102774539B CN 102774539 B CN102774539 B CN 102774539B CN 201210203505 A CN201210203505 A CN 201210203505A CN 102774539 B CN102774539 B CN 102774539B
- Authority
- CN
- China
- Prior art keywords
- tmpctr
- bar
- present frame
- roi
- counting
- 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.)
- Expired - Fee Related
Links
Images
Landscapes
- Image Analysis (AREA)
Abstract
The invention relates to a bar on-line automatic counting method based on modified gradient Hough circle transformation. The method includes that after threshold parameters of normal radii, minimum radii, maximum radii and combined radii of bars in various specifications are determined, each frame of real-timely collected bar end surface patterns is processed by the following steps of firstly, reinforcing a current frame of bar end surface patterns on the basis of a modified gradient Hough circle transformation method, subjecting the current frame of bar end surface patterns to Regional Max detection and distance detection according to the corresponding threshold parameters, determining an actual observation central point of a current frame of bar end surfaces, and finally, establishing a relevance matching pair relationship between the actual observation central point of the current frame of bar end surfaces and an actual observation central point of a prior frame of bar end surfaces according to horizontal motion speeds of the bars, wherein in each relevance matching pair relationship, if the actual observation central point of the current frame and the actual observation central point of the prior frame are distributed on the left side and the right side of a bar counting central datum line respectively, a counting variable is added by one, and otherwise, the counting variable is reduced by one. The bar on-line automatic counting method has the advantages of being high in real-time performance, high in counting accuracy and capable of bidirectional counting.
Description
Technical field
The invention belongs to bar on-line Auto-counting technical field.Relate in particular to a kind of bar on-line automatic counting method based on improving gradient Hough circle transformation.
Background technology
Steel rolling mill's bar production requires finished product number in accordance with regulations to carry out standardization bailing.But the bar that at present China steel rolling mill produces all adopts artificial counting, not only easily makes mistakes, efficiency is low, packaging quantity can not be guaranteed requirement, and with the robotization steel rolling cover that mismatches, affect the raising of production efficiency and equipment; On the other hand, because packing can not guarantee accurate number, market sale, only according to weight metering, can not obtain and should have an economic benefit from popular in the world rolling with negative tolerance mode, cause steel rolling mill to sustain a loss economically, therefore bar accurate counting tool is of great significance.
Traditional dynamo-electric method bar on-line Auto-counting design proposal exists mechanical wear serious, and maintenance cost is high and to shortcomings such as small-sized bar counting precision are not high.In order to overcome determining of dynamo-electric method, those skilled in the art have in succession proposed the multiple image processing method based on bar section and have realized bar on-line Auto-counting.More representational method has following several at present:
1. assemble at center
As " the online visual meter number system research of bar production " (Luo Sanding, Sha Sha, Shen Deyao etc. small-sized microcomputer system, 2004.25 (4): " cheer " aggregation method 671-675.) proposing has advantages of speed height and zmodem, class of fit algorithm, successfully solve close-packed arrays and part edge circumstance of occlusion, but easily occur the problem of miscount and many countings.
2. image distance
As " the automatic count of the steel rods technology based on image processing " (Wang Jinhua, Sun Hao, Xu Jinwu etc. iron and steel, 2004.39 (5): 34-37.) introduced " image distance " concept, by calculating and compare the image distance of each picture element of bar region, identify marginal point and central point.This method depends critically upon the effect that image is cut apart, and easily produces miscount.
3. template matches
As " research of bar on-line counting interrupt face localization method " (Zhang Da, Xie Zhi etc. Chinese journal of scientific instrument .2010.5,31 (5): 1173-1178.) technology, by template matches and change Threshold segmentation mixed method, realize the centralized positioning of bar section, and then extract bar positional information, realize bar real-time follow-up counting.Although this method is improved Threshold segmentation, there is the inadequate natural endowment of template matches, easily counting loss, is difficult to carry out accurate counting to being out of shape serious bar image.
When the difficult point of bar on-line automatic counter system is that bar transmits in conveyer chain, easily occur overlapping crossover phenomenon, this has brought very large difficulty with separated to counting.Adopt photoelectric technology and image processing techniques to carry out accurate metering, now obtained some effects.Photoelectric technology is applicable to bar does not have overlapping intersection or the not serious situation of overlapping intersection, and along with the reducing of diameter of rod, the situation of overlapping intersection is more and more serious, now only by photoelectric technology, is difficult to solve Auto-counting problem.Adopt digital image processing techniques can solve preferably the bar identification counting in overlapping intersection situation, but image processing techniques is subject to the limitation of ground unrest, illumination effect and disposal route, it is on-the-spot that existing bar on-line automatic counting method can't be applicable to various bar production completely.
Summary of the invention
The present invention is intended to overcome above-mentioned technological deficiency, object be to provide a kind of real-time, counting precision is high, can effectively realize two-way counting and meet the bar on-line automatic counting method based on improving gradient Hough circle transformation of industry spot demand.
In order to realize above-mentioned object, the step of the bar on-line automatic counting method that the present invention adopts is:
The first step, bar threshold parameter are determined
This step is to the corresponding standard radius Rnom of different size bar, least radius Rmin, maximum radius Rmax and merges determining of radius R cmb threshold parameter, and concrete steps are:
1) four parameter: ROI.X that rectangular area ROI are set represent upper left, ROI region angle point x axial coordinate, and ROI.Y represents upper left, ROI region angle point y axial coordinate, and ROI.Width represents ROI peak width, and ROI.Height represents ROI region height.
2) gather the 1st frame bar section image of a certain scale rod bar.
3) gathered bar section image is designated as to present frame parameter and determines image, in present frame parameter is determined image, selected ROI area image is present frame ROI image, then binaryzation present frame ROI image.
4) the present frame ROI image of binaryzation is carried out to range conversion and Gaussian Blur processing, generate present frame ROI and strengthen image; Then present frame ROI is strengthened to image carries out that RegionalMax detects and parameter is determined the distance detection in stage, finally determine present frame bar section actual observation central point, determined present frame bar section actual observation central point strengthens at present frame ROI the radius that the pixel value in image is corresponding bar.
5) every kind of corresponding bar number of radius value in statistics present frame ROI image, is saved in the radius value of maximum probability wherein in a line of R array.
6) gather this kind of specification the 2nd to f_thres two field picture, wherein f_thes gets any one value in [50 ~ 200], respectively to every two field picture according to step 3) ~ 5) process.
7) ask for the mean value in R array, this mean value is set to the standard radius Rnom of this kind of scale rod bar, then obtain respectively Rmin=(0.3 ~ 0.6 of this kind of scale rod bar) * Rnom, Rmax=(12 ~ 1.8) * Rnom and Rcmb=(1.5 ~ 2.5) * Rnom, finally above parameter is saved in threshold parameter file ParameterSet.txt.
8) to every kind of scale rod bar respectively according to step 2) ~ 7) carry out determining of threshold parameter.
Second step, bar on-line Auto-counting
According to the specification of the bar to be counted of selecting, corresponding standard radius Rnom, least radius Rmin, maximum radius Rmax and merging radius R cmb threshold parameter in read threshold Parameter File ParameterSet.txt, gather the 1st online frame bar section original image, be designated as the online bar section original image of present frame, then according to following steps, carry out bar on-line Auto-counting, count results is stored in counting variable barCount, and the initial value of counting variable barCount is set to 0.
1) the online bar section original image of present frame is successively carried out to ROI region division, binaryzation, corrosion and Gaussian Blur pre-service, generate present frame ROI pretreatment image, obtain and preserve the vertical projection of present frame ROI pretreatment image.
2) employing improvement gradient Hough circle transformation method obtains present frame ROI enhancing image, then present frame ROI is strengthened to the distance detection that image carries out RegionalMax detection and counting stage, finally determines present frame bar section actual observation central point.
3) the online bar section original image of present frame is designated as to the online bar section original image of former frame, present frame ROI pretreatment image is designated as former frame ROI pretreatment image, and present frame bar section actual observation central point is designated as former frame bar section actual observation central point; Gather afterwards online next frame bar section original image, be designated as the online bar section original image of present frame.
4) with the step 1) of second step.
5) with the step 2 of second step).
6) vertical projection based on former frame and present frame ROI pretreatment image, estimation bar integral level movement velocity G_Speed.
7) first utilize described bar integral level movement velocity G_Speed, based on bee-line criterion, set up associated pair relationhip of former frame and present frame bar section actual observation central point; In conjunction with each bar section actual observation central point coupling in former frame and present frame, to the distribution situation in bar counting central datum line horizontal direction, according to following counting rule, carry out bar on-line Auto-counting again:
This rule supposition bar integrated moving direction is right-to-left, if bar integrated moving direction is from left to right, and the collection image that camera can be reversed, counting rule remains unchanged, and the vertical center line of selecting in addition ROI region is bar counting central datum line.
(1) if the x axial coordinate of certain the bar section actual observation central point in former frame on the right of bar counting central datum line, in present frame, the x axial coordinate of the actual observation central point of associated coupling, on the left side of bar counting central datum line, adds 1 to counting variable barCount value.
(2) if the x axial coordinate of certain the bar section actual observation central point in former frame on the left side of bar counting central datum line, in present frame, the x axial coordinate of the actual observation central point of associated coupling, on the right of bar counting central datum line, subtracts 1 to counting variable barCount value.
The bar on-line Auto-counting of present frame finishes.
8) according to step 3) ~ 7) successively the bar of every frame is carried out to on-line automatic counting, until this batch of whole countings of bar to be counted are complete, last counting variable batCount value is the sum of this batch of bar to be counted.
Employing described in the technical program improves gradient Hough circle transformation method and obtains present frame ROI enhancing image, and step is:
1) definition and initialization ROI accumulative total matrix accum, in ROI pretreatment image, the corresponding accumulative total of any one pixel p (xi, yi) variable is accum (xi, yi), its initial value is 0.
2) adopt the horizontal and vertical direction gradient of all pixels in Sobel operator calculating present frame ROI pretreatment image, ask for the edge of present frame ROI pretreatment image.
3) take out a certain marginal point p (xi, yi) in present frame ROI pretreatment image, and R=Rmin is set.
4) if R≤Rmax, a p (xi, yi) of first take is starting point, after some p (xi, yi) normal direction skew R distance, navigate to doubtful centre point p (xc, yc), accum (xc is set, yc)=accum (xc, yc)+1, then with doubtful centre point p (xc, yc) be starting point, along some p (xi, yi) normal direction, continue to navigate to a p (xr, yr) after skew Rmin distance.
5) if fruit dot p (xr, yr) respective pixel value in ROI pretreatment image is not 255, perform step 6), otherwise R=R+1 returns to step 4).
6) according to step 3) ~ 5) process another marginal point in present frame ROI pretreatment image; Until all marginal points are handled in present frame ROI pretreatment image.
7) ROI accumulative total matrix accum is saved as to present frame ROI and strengthen image.
The step that RegionalMax described in the technical program detects is:
Two-dimensional array tmpCtr[2] [100], for preserving x axle and the y axial coordinate value of the doubtful observation central point of present frame, it is 0 that doubtful observation central point counting variable tmpNum initial value is set.
1) each pixel that present frame ROI strengthens in image all carries out RegionalMax detection as follows:
If present frame ROI strengthens the pixel value of a certain pixel p (xi, yi) in image, be less than thres, thres gets any one value in [2 ~ 10], and the pixel value of this pixel p (xi, yi) is maximal value in its 8 neighborhood simultaneously;
Assert that this pixel p (xi, yi) is the doubtful observation central point of present frame bar section;
TmpCtr[0 is set] [tmpNum]=yi; TmpCtr[1] [tmpNum]=xi; TmpNum=tmpNum+1.
2) the doubtful observation central point of all bar sections of storing in two-dimensional array tmpCtr is all carried out to RegionalMax detection as follows:
If the doubtful observation central point of a certain bar section t meets any in following relation:
tmpCtr[0][t]=ROI.width-1;
tmpCtr[0][t]=0;
tmpCtr[1][t]=ROI.Height-1;
tmpCtr[1][t]=0。
tmpCtr[0][t]=0;
tmpCtr[1][t]=0;
tmpNum=tmpNum-1。
Otherwise the doubtful observation central point of this bar section t of take is starting point, in present frame ROI enhancing image, find pixel point set identical with this doubtful observation central point t pixel value and that be interconnected.
Then take out arbitrary pixel q that pixel is concentrated, if the pixel value of certain pixel of the interior existence of 8 neighborhoods of arbitrary pixel q is greater than the pixel value of this doubtful observation central point t,
tmpCtr[1][t]=0;
tmpCtr[0][t]=0;
tmpNum=tmpNum-1。
The judgement of the rest of pixels that pixel is concentrated is with described arbitrary pixel q.
Parameter described in the technical program determines that the step that the distance in stage detects is:
Get i and two doubtful observation central points of j in two-dimensional array tmpCtr, the respective pixel value that described two doubtful observation central points strengthen in image at present frame ROI is respectively:
P(tmpCtr[1][i],tmpCtr[0][i]),P(tmpCtr[1][j],tmpCtr[0][j])。
The distance of described two doubtful observation central points is R, and parameter determines that the step that the distance in stage detects is:
If R meets any in following relation:
R<P (tmpCtr[1] [i], tmpCtr[0] [i]), R<P (tmpCtr[1] [j], tmpCtr[0] [j]) time
If P (tmpCtr[1] [i], tmpCtr[0] [i])≤P (tmpCtr[1] [j], tmpCtr[0] [j])
tmpCtr[1][i]=0;tmpCtr[0][i]=0;tmpNum=tmpNum-1。
Otherwise
tmpCtr[1][j]=0;tmpCtr[0][j]=0;tmpNum=tmpNum-1。
In two-dimensional array tmpCtr, the parameter of any two doubtful observation central points determines that the distance in stage detects the same.
The step that the distance of the counting stage described in the technical program detects is:
Get in two-dimensional array tmpCtr i and two doubtful observation central points of j arbitrarily, the respective pixel value that described two doubtful observation central points strengthen in image at present frame ROI is respectively:
P(tmpCtr[1][i],tmpCtr[0][i]);P(tmpCtr[1][j],tmpCtr[0][j])。
The distance of described two doubtful observation central points is R, and the step that the distance of counting stage detects is:
If 1. during R<Rcmb
If P (tmpCtr[1] [i], tmpCtr[0] [i])≤P (tmpCtr[1] [j], tmpCtr[0] [j]),
tmpCtr[1][i]=0;tmpCtr[0][i]=0;tmpNum=tmpNum-1。
If P (tmpCtr[1] [i], tmpCtr[0] [i]) >P (tmpCtr[1] [j], tmpCtr[0] [j]),
tmpCtr[1][j]=0;tmpCtr[0][j]=0;tmpNum=tmpNum-1。
If 2. present frame is not the 1st frame, when R>Rcmb and R<1.5 * Rcmb, set up the association pair relationhip between the doubtful observation central point of former frame bar section actual observation central point and present frame bar section; If in present frame, two doubtful observation central points of i and j mate with same actual observation central point in former frame,
If P (tmpCtr[1] [i], tmpCtr[0] [i])≤P (tmpCtr[1] [j], tmpCtr[0] [j]),
tmpCtr[1][i]=0;tmpCtr[0][i]=0;tmpNum=tmpNum-1。
If P (tmpCtr[1] [i], tmpCtr[0] [i]) >P (tmpCtr[1] [j], tmpCtr[0] [j]),
tmpCtr[1][j]=0;tmpCtr[0][j]=0;tmpNum=tmpNum-1。
In two-dimensional array tmpCtr, the distance of the counting stage of any two doubtful observation central points detects the same.
Definite present frame bar section actual observation central point described in this art scheme is:
Get r column element in two-dimensional array tmpCtr, if tmpCtr[0] [r] and tmpCtr[1] [r] be not equal to 0 simultaneously,
Pixel p in present frame ROI enhancing image (tmpCtr[1] [r], tmpCtr[0] [r]) be a bar section actual observation central point in present frame.
All the other each column elements in two-dimensional array tmpCtr, all determine all the other the bar section actual observation central points in present frame as stated above.
The step of estimation bar integral level movement velocity G_Speed described in the technical program is:
1) tangential movement speed exploration scope is set for [MaxSpeed, MaxSpeed], MaxSpeed is (1/6~1/4) * ROI.Width.
2) arrange in former frame ROI pretreatment image vertical projection and start from MaxSpeed, a part of projection result that width is ROI.Width-2 * MaxSpeed is designated as former frame observation vertical projection.
3) based on former frame observation vertical projection, get in order exploration scope [MaxSpeed, MaxSpeed] in each round values, successively by its assignment to speed variable i _ speed, every assignment once estimates that a corresponding present frame estimates vertical projection, a part of projection that this estimations vertical projection is is ROI.Width-2 * MaxSpeed from the width of MaxSpeed-i_speed beginning in present frame ROI pre-service vertical projection.
4) present frame that calculates respectively each estimation is estimated the distance between vertical projection and former frame observation vertical projection, when speed variable i _ speed gets a certain value, the present frame of corresponding estimation estimates that the distance between vertical projection and former frame observation vertical projection is minimum, and described a certain value is bar integral level movement velocity G_Speed.
Described in the technical program, the establishment step of an associated pair relationhip is:
Former frame bar section actual observation central point is designated as to former frame central point to be matched, and present frame bar section actual observation central point or doubtful observation central point are designated as present frame central point to be matched.
1) the equal level of x axial coordinate of all central points to be matched in former frame is offset to G_Speed pixel left, obtains respectively former frame central point to be matched and in ,Gai position, the estimated position of present frame, be designated as present frame estimation center position.
2) ask in present frame each estimate center position respectively with the distance of each center position to be matched, set up as follows more associated coupling right: if the estimation central point of former frame center point P ipos to be matched in present frame is Pipos_pre, this estimates in center point P ipos_pre and present frame that certain center point P temp_pos to be matched is apart from minimum, thinks certain center point P ipos to be matched described in former frame and associated pair relationhip of foundation between certain center point P temp_pos to be matched described in present frame.
Owing to adopting technique scheme, tool of the present invention has the following advantages:
First, consider the high feature of system operation requirement of real-time, the present invention is on the basis of traditional Grads Hough Transformation circle detection method, adopt and improve gradient Hough circle transformation method acquisition present frame ROI enhancing image, further dwindle the search volume of algorithm, guaranteed the real-time of algorithm operation:
1. abandon and adopt Canny operator to ask for edge gradient, adopt all pixel horizontal and vertical direction gradients in Sobel operator computed image, make Riming time of algorithm improve 10ms left and right.
When 2. all image edge pixels points strengthen bar section central point along edge normal, no longer from Rmin to Rmax, search for successively the doubtful centre point of different radii, but based on circular symmetry principle, the doubtful centre point at every turn having searched is advanced to Rmin pixel again along the direction of search.When if this pixel being detected and not being the point on bar section, can stop along the doubtful centre point search in this normal direction.
Secondly, the present invention has adopted the multi-filtering detection means that RegionalMax detects and distance detects, and has effectively guaranteed counting precision.
Finally, the present invention has adopted bar counting center reference line method effectively to realize two-way counting, has solved the inaccurate problem of on-line counting causing because of inertia motion before and after bar.
Therefore that, the present invention has is real-time, counting precision is high, can effectively realize the features such as two-way counting, meets industry spot demand.
Accompanying drawing explanation
Fig. 1 is the 1st frame bar section image of a certain scale rod bar of the present invention;
Fig. 2 is the bar radius statistics figure of Fig. 1;
Fig. 3 is the present frame ROI pretreatment image of on-line automatic counting stage;
Fig. 4 is that the present frame ROI of on-line automatic counting stage strengthens image;
Fig. 5 is the definite present frame bar section actual observation central point of on-line automatic counting stage;
Fig. 6 is a kind of on-line automatic counting schematic diagram of the present invention;
Fig. 7 is for working as the on-line automatic counting schematic diagram of another kind of the present invention.
Embodiment
Below in conjunction with embodiment, the present invention will be further described, is not limiting the scope of the invention.
A kind of bar on-line automatic counting method based on improving gradient Hough circle transformation.
The bar specification that certain Bar Plant is produced has tri-kinds of 12mm, 14mm, 16mm, and the bar that wherein specification is 16mm is carried out to on-line automatic counting, and the step of method of counting is:
The first step, bar threshold parameter are determined
This step is to the corresponding standard radius Rnom of different size bar, least radius Rmin, maximum radius Rmax and merges determining of radius R cmb threshold parameter, and concrete steps are:
1) four parameter: ROI.X that rectangular area ROI are set represent upper left, ROI region angle point x axial coordinate, and ROI.Y represents upper left, ROI region angle point y axial coordinate, and ROI.Width represents ROI peak width, and ROI.Height represents ROI region height.In the present embodiment, establish: ROI.X=322, ROI.Y=250, ROI.Height=250, ROI.Width=313.
2) gather the 1st frame bar section image of 16mm scale rod bar.
3) gathered the 1st frame bar section image is as shown in Figure 1 designated as to present frame parameter and determines image, in present frame parameter is determined image, selected ROI area image is present frame ROI image, and in Fig. 1, rectangular area image is present frame ROI image.Binaryzation present frame ROI image again.
4) the present frame ROI image of binaryzation is carried out to range conversion and Gaussian Blur processing, generate present frame ROI and strengthen image; Then present frame ROI is strengthened to image carries out that RegionalMax detects and parameter is determined the distance detection in stage.The step that RegionalMax detects is:
Two-dimensional array tmpCtr[2] [100], for preserving x axle and the y axial coordinate value of the doubtful observation central point of present frame, it is 0 that doubtful observation central point counting variable tmpNum initial value is set.
1. each pixel that present frame ROI strengthens in image all carries out RegionalMax detection as follows:
If present frame ROI strengthens the pixel value of a certain pixel p (xi, yi) in image, be less than thres, get thres=3, the pixel value of this pixel p (xi, yi) is maximal value in its 8 neighborhood simultaneously;
Assert that this pixel p (xi, yi) is the doubtful observation central point of present frame bar section;
TmpCtr[0 is set] [tmpNum]=yi; TmpCtr[1] [tmpNum]=xi; TmpNum=tmpNum+ 1.
2. the doubtful observation central point of all bar sections of storing in two-dimensional array tmpCtr is all carried out to RegionalMax detection as follows:
If the doubtful observation central point of a certain bar section t meets any in following relation:
tmpCtr[0][t]=ROI.width-1;
tmpCtr[0][t]=0;
tmpCtr[1][t]=ROI.Height-1;
tmpCtr[1][t]=0。
tmpCtr[0][t]=0;
tmpCtr[1][t]=0;
tmpNum=tmpNum-1。
Otherwise the doubtful observation central point of this bar section t of take is starting point, in present frame ROI enhancing image, find pixel point set identical with this doubtful observation central point t pixel value and that be interconnected.
Then take out arbitrary pixel q that pixel is concentrated, if the pixel value of certain pixel of the interior existence of 8 neighborhoods of arbitrary pixel q is greater than the pixel value of this doubtful observation central point t,
tmpCtr[1][t]=0;
tmpCtr[0][t]=0;
tmpNum=tmpNum-1。
The judgement of the rest of pixels that pixel is concentrated is with described arbitrary pixel q.
Parameter determines that the value of the two-dimensional array tmpCtr after the RegionalMax in stage detects is as described in Table 1.
Table 1
334 | 351 | 358 | 360 | 367 | 380 | 387 | 397 | 402 | 422 | 430 | 454 | 455 | 459 | 467 | 477 | 480 | 486 |
358 | 334 | 335 | 356 | 311 | 350 | 351 | 305 | 327 | 348 | 314 | 387 | 338 | 339 | 312 | 376 | 376 | 342 |
498 | 509 | 511 | 531 | 535 | 550 | 554 | 557 | 575 | 582 | 589 | 600 | 607 | 624 | 634 | 634 |
364 | 339 | 340 | 368 | 340 | 386 | 357 | 358 | 334 | 378 | 314 | 339 | 372 | 351 | 319 | 378 |
Described parameter determines that the step that the distance in stage detects is:
Get i and two doubtful observation central points of j in two-dimensional array tmpCtr, the respective pixel value that described two doubtful observation central points strengthen in image at present frame ROI is respectively:
P(tmpCtr[1][i],tmpCtr[0][i]),P(tmpCtr[1][j],tmpCtr[0][j])。
The distance of described two doubtful observation central points is R, and parameter determines that the step that the distance in stage detects is:
If R meets any in following relation:
R<P (tmpCtr[1] [i], tmpCtr[0] [i]), R<P (tmpCtr[1] [j], tmpCtr[0] [j]) time
If P (tmpCtr[1] [i], tmpCtr[0] [i])≤P (tmpCtr[1] [j], tmpCtr[0] [j]),
tmpCtr[1][i]=0;tmpCtr[0][i]=0;tmpNum=tmpNum-1。
Otherwise
tmpCtr[1][j]=0;tmpCtr[0][j]=0;tmpNum=tmpNum-1。
In two-dimensional array tmpCtr, the parameter of any two doubtful observation central points determines that the distance in stage detects the same.
Parameter determines that the value of the two-dimensional array tmpCtr after the distance in stage detects is as described in Table 2.
Table 2
334 | 351 | 358 | 360 | 367 | 380 | 0 | 397 | 402 | 422 | 430 | 454 | 455 | 0 | 467 | 0 | 480 | 486 |
358 | 334 | 335 | 356 | 311 | 350 | 0 | 305 | 327 | 348 | 314 | 387 | 338 | 0 | 312 | 0 | 376 | 342 |
498 | 0 | 511 | 531 | 535 | 550 | 0 | 557 | 575 | 582 | 589 | 600 | 607 | 624 | 634 | 634 |
364 | 0 | 340 | 368 | 340 | 386 | 0 | 358 | 334 | 378 | 314 | 339 | 372 | 351 | 319 | 378 |
Finally determine that present frame bar section actual observation central point is:
Get r column element in two-dimensional array tmpCtr, if tmpCtr[0] [r] and tmpCtr[1] [r] be not equal to 0 simultaneously,
Pixel p in present frame ROI enhancing image (tmpCtr[1] [r], tmpCtr[0] [r]) be a bar section actual observation central point in present frame.
All the other each column elements in two-dimensional array tmpCtr, all determine all the other the bar section actual observation central points in present frame as stated above.
Determined present frame bar section actual observation central point strengthens at present frame ROI the radius that the pixel value in image is corresponding bar.In the ROI area image of Fig. 1, solid black point, for each bar section actual observation central point in present frame ROI image, has 29 solid black points in Fig. 1, and representative detects 29 bars in present frame.
5) every kind of corresponding bar number of radius value in statistics present frame ROI image, is saved in the radius value of maximum probability wherein in a line of R array.
Fig. 2 is the bar radius statistics figure of present frame.Fig. 2 has provided the statistical information of every kind of radius value in present frame ROI image, wherein: radius is 3 of the bars of 6 pixels; Radius is that the bar of 7 pixels has 2; Radius is that the bar of 8 pixels has 7; Radius is that the bar of 9 pixels has 11; Radius is that the bar of 10 pixels has 5; Radius is that the bar of 11 pixels has 1; All the other radius value bar numbers are 0.Statistics from Fig. 2: radius is that the bar of 9 pixels is maximum, radius value 9 is stored in a line of R array.
6) gather the 2nd to the 50th two field picture of this kind of specification, wherein f_thes gets 50 in [50 ~ 200], respectively to every two field picture according to step 3) ~ 5) process, the radius value that is saved in the maximum probability in R array after processing is as described in Table 3 respectively:
Table 3
9 | 9 | 7 | 8 | 8 | 8 | 9 | 8 | 7 | 9 | 8 | 8 | 8 | 7 | 7 | 8 | 8 | 8 |
9 | 9 | 9 | 9 | 9 | 9 | 9 | 8 | 7 | 8 | 8 | 8 | 8 | 9 | 9 | 7 | 8 | 7 |
9 | 8 | 7 | 8 | 8 | 7 | 9 | 9 | 9 | 8 | 9 | 7 | 7 | 9 |
7) mean value of asking in R array is 8, by the 8 bar standard radius Rnom that are set to this kind of specification, then obtain respectively Rmin=3, Rmax=10 and the Rcmb=12 of this kind of scale rod bar, finally above parameter is saved in threshold parameter file ParameterSet.txt.
8) to 14mm and 12mm scale rod bar all according to step 2) ~ 7) carry out threshold parameter and determine, consequently:
16mm:Rmin=3,Rnom=8,Rmax=10,Rcmb=12;
14mm:Rmin=3,Rnom=6,Rmax=9,Rcmb=12;
12mm:Rmin=2,Rnom=4,Rmax=7,Rcmb=10。
Second step, bar on-line Auto-counting
According to the specification of the bar to be counted of selecting, be 16mm, corresponding standard radius Rnom=8, least radius Rmin=3, maximum radius Rmax=10 and merging radius R cmb=12 in read threshold Parameter File ParameterSet.txt, gather the 1st online frame bar section original image, be designated as the online bar section original image of present frame, then according to following steps, carry out bar on-line Auto-counting, count results is stored in counting variable barCount, and the initial value of counting variable barCount is set to 0.
1) the online bar section original image of present frame is successively carried out to ROI region division, binaryzation, corrosion and Gaussian Blur pre-service, generate present frame ROI pretreatment image as shown in Figure 3, obtain and preserve the vertical projection of present frame ROI pretreatment image.
2) adopt and improve gradient Hough circle transformation method acquisition present frame ROI enhancing image, step is:
1. definition and initialization ROI add up matrix accum, and in ROI pretreatment image, the corresponding accumulative total of any one pixel p (xi, yi) variable is accum (xi, yi), and its initial value is 0.
2. adopt the horizontal and vertical direction gradient of all pixels in Sobel operator calculating present frame ROI pretreatment image, ask for the edge of present frame ROI pretreatment image.
3. take out a certain marginal point p (xi, yi) in present frame ROI pretreatment image, and R=Rmin is set.
If 4. R≤Rmax, a p (xi, yi) of first take is starting point, after some p (xi, yi) normal direction skew R distance, navigate to doubtful centre point p (xc, yc), accum (xc is set, yc)=accum (xc, yc)+1, then with doubtful centre point p (xc, yc) be starting point, along some p (xi, yi) normal direction, continue to navigate to a p (xr, yr) after skew Rmin distance.
5. if fruit dot p (xr, yr) respective pixel value in ROI pretreatment image is not 255, perform step 6., otherwise 4. R=R+1 returns to step.
6. according to step 3. ~ 5. process another marginal point in present frame ROI pretreatment image; Until all marginal points are handled in present frame ROI pretreatment image.
7. present frame ROI ROI accumulative total matrix accum being saved as shown in Figure 4 strengthens image.
Again present frame ROI is strengthened to the distance detection that image carries out RegionalMax detection and counting stage.
The RegionalMax that RegionalMax detects with the first step detects.
The value of two-dimensional array tmpCtr after RegionalMax detects is as described in Table 4.
Table 4
11 | 34 | 36 | 37 | 43 | 43 | 48 | 64 | 75 | 78 | 99 | 107 | 130 | 135 | 144 | 155 | 157 | 164 | 175 | 188 | 209 |
107 | 84 | 84 | 104 | 60 | 104 | 104 | 99 | 53 | 76 | 98 | 63 | 136 | 88 | 61 | 125 | 125 | 90 | 113 | 89 | 117 |
212 | 213 | 228 | 233 | 252 | 259 | 266 | 276 | 285 | 301 | 306 |
102 | 89 | 133 | 106 | 83 | 127 | 63 | 88 | 121 | 99 | 128 |
The step that the distance of the counting stage described in the present embodiment detects is:
Get in two-dimensional array tmpCtr i and two doubtful observation central points of j arbitrarily, the respective pixel value that described two doubtful observation central points strengthen in image at present frame ROI is respectively:
P(tmpCtr[1][i],tmpCtr[0][i]);P(tmpCtr[1][j],tmpCtr[0][j])。
The distance of described two doubtful observation central points is R, and the step that the distance of counting stage detects is:
If 1. during R<Rcmb
If P (tmpCtr[1] [i], tmpCtr[0] [i])≤P (tmpCtr[1] [j], tmpCtr[0] [j]),
tmpCtr[1][i]=0;tmpCtr[0][i]=0;tmpNum=tmpNum-1。
If P (tmpCtr[1] [i], tmpCtr[0] [i]) >P (tmpCtr[1] [j], tmpCtr[0] [j]),
tmpCtr[1][j]=0;tmpCtr[0][j]=0;tmpNum=tmpNum-1。
If 2. present frame is not the 1st frame, when R>Rcmb and R<1.5 * Rcmb, set up the association pair relationhip between the doubtful observation central point of former frame bar section actual observation central point and present frame bar section, establishment step is:
Former frame bar section actual observation central point is designated as to former frame central point to be matched, and the doubtful observation central point of present frame bar section is designated as present frame central point to be matched.
● the equal level of x axial coordinate of all central points to be matched in former frame is offset to G_Speed pixel left, obtains respectively former frame central point to be matched and in ,Gai position, the estimated position of present frame, be designated as present frame estimation center position.
● ask in present frame each estimate center position respectively with the distance of each center position to be matched, set up as follows more associated coupling right: if the estimation central point of former frame center point P ipos to be matched in present frame is Pipos_pre, this estimates in center point P ipos_pre and present frame that certain center point P temp_pos to be matched is apart from minimum, thinks certain center point P ipos to be matched described in former frame and associated pair relationhip of foundation between certain center point P temp_pos to be matched described in present frame.
If in present frame, two doubtful observation central points of i and j mate with same actual observation central point in former frame,
If P (tmpCtr[1] [i], tmpCtr[0] [i])≤P (tmpCtr[1] [j], tmpCtr[0] [j]),
tmpCtr[1][i]=0;tmpCtr[0][i]=0;tmpNum=tmpNum-1。
If P (tmpCtr[1] [i], tmpCtr[0] [i]) >P (tmpCtr[1] [j], tmpCtr[0] [j]),
tmpCtr[1][j]=0;tmpCtr[0][j]=0;tmpNum=tmpNum-1。
In two-dimensional array tmpCtr, the distance of the counting stage of any two doubtful observation central points detects the same.
After the distance of counting stage detects, the value of two-dimensional array tmpCtr is as described in Table 5.
Table 5
11 | 34 | 0 | 37 | 43 | 0 | 0 | 64 | 75 | 78 | 99 | 107 | 130 | 135 | 144 | 155 | 0 | 164 | 175 | 188 | 209 |
107 | 84 | 0 | 104 | 60 | 0 | 0 | 99 | 53 | 76 | 98 | 63 | 136 | 88 | 61 | 125 | 0 | 90 | 113 | 89 | 117 |
0 | 213 | 228 | 233 | 252 | 259 | 266 | 276 | 285 | 301 | 306 |
0 | 89 | 133 | 106 | 83 | 127 | 63 | 88 | 121 | 99 | 128 |
Finally determine present frame bar section actual observation central point, the solid black point in Fig. 5 is definite present frame bar section actual observation central point.
3) the online bar section original image of present frame is designated as to the online bar section original image of former frame, present frame ROI pretreatment image is designated as former frame ROI pretreatment image, present frame bar section actual observation central point is designated as former frame bar section actual observation central point, gather afterwards online next frame bar section original image, be designated as the online bar section original image of present frame.
4) with the step 1) of second step.
5) with the step 2 of second step).
The value of two-dimensional array tmpCtr after RegionalMax detects is as described in Table 6.
Table 6
20 | 21 | 23 | 29 | 30 | 31 | 33 | 50 | 61 | 65 | 85 | 93 | 117 | 120 | 130 | 144 | 149 | 161 | 175 | 196 | 200 |
81 | 102 | 102 | 101 | 57 | 101 | 101 | 97 | 51 | 74 | 95 | 61 | 134 | 85 | 58 | 122 | 88 | 111 | 87 | 114 | 87 |
214 | 220 | 238 | 246 | 252 | 263 | 272 | 289 | 295 | 302 |
130 | 104 | 82 | 124 | 59 | 85 | 119 | 97 | 124 | 64 |
After the distance of counting stage detects, the value of two-dimensional array tmpCtr is as described in Table 7.
Table 7
20 | 21 | 0 | 0 | 30 | 0 | 0 | 50 | 61 | 65 | 85 | 93 | 117 | 120 | 130 | 144 | 149 | 161 | 175 | 196 | 200 |
81 | 102 | 0 | 0 | 57 | 0 | 0 | 97 | 51 | 74 | 95 | 61 | 134 | 85 | 58 | 122 | 88 | 111 | 87 | 114 | 87 |
214 | 220 | 238 | 246 | 252 | 263 | 272 | 289 | 295 | 302 |
130 | 104 | 82 | 124 | 59 | 85 | 119 | 97 | 124 | 64 |
6) vertical projection based on former frame and present frame ROI pretreatment image, estimation bar integral level movement velocity G_Speed, step is:
1. tangential movement speed exploration scope is set for [MaxSpeed, MaxSpeed], MaxSpeed is 1/6 * ROI.Width.
2. arrange in former frame ROI pretreatment image vertical projection and start from MaxSpeed, a part of projection result that width is ROI.Width-2 * MaxSpeed is designated as former frame observation vertical projection.
3. based on former frame observation vertical projection, get in order exploration scope [MaxSpeed, MaxSpeed] in each round values, successively by its assignment to speed variable i _ speed, every assignment once estimates that a corresponding present frame estimates vertical projection, a part of projection that this estimations vertical projection is is ROI.Width-2 * MaxSpeed from the width of MaxSpeed-i_speed beginning in present frame ROI pre-service vertical projection.
4. calculate respectively the present frame of each estimation and estimate the distance between vertical projection and former frame observation vertical projection, when speed variable i _ speed gets 14, the present frame of corresponding estimation estimates that the distance between vertical projection and former frame observation vertical projection is minimum, and 14 is bar integral level movement velocity G_Speed.
7) first utilize described bar integral level movement velocity G_Speed, set up associated pair relationhip of former frame and present frame bar section actual observation central point based on bee-line criterion, establishment step is:
Former frame bar section actual observation central point is designated as to former frame central point to be matched, and present frame bar section actual observation central point is designated as present frame central point to be matched.
1. the equal level of x axial coordinate of all central points to be matched in former frame is offset to G_Speed pixel left, obtains respectively former frame central point to be matched and in ,Gai position, the estimated position of present frame, be designated as present frame estimation center position.
2. ask in present frame each estimate center position respectively with the distance of each center position to be matched, set up as follows more associated coupling right: if the estimation central point of former frame center point P ipos to be matched in present frame is Pipos_pre, this estimates in center point P ipos_pre and present frame that certain center point P temp_pos to be matched is apart from minimum, thinks certain center point P ipos to be matched described in former frame and associated pair relationhip of foundation between certain center point P temp_pos to be matched described in present frame.In Fig. 6, provided an association pair relationhip of setting up in 0.25 * ROI.X to 0.75 * ROI.X horizontal zone, solid black point is wherein present frame actual observation central point, black circles is former frame actual observation central point, and each associated coupling is to connecting with straight line.
In conjunction with each bar section actual observation central point coupling in former frame and present frame, to the distribution situation in bar counting central datum line horizontal direction, according to following counting rule, carry out bar on-line Auto-counting again:
This rule supposition bar integrated moving direction is right-to-left, if bar integrated moving direction is from left to right, and the collection image that camera can be reversed, counting rule remains unchanged, and the vertical center line of selecting in addition ROI region is bar counting central datum line.
If the x axial coordinate of certain the bar section actual observation central point 1. in former frame is on the right of bar counting central datum line, in present frame, the x axial coordinate of the actual observation central point of associated coupling, on the left side of bar counting central datum line, adds 1 to counting variable barCount value.In Fig. 6, perpendicular line in the middle of ROI region is bar counting central datum line, there is 1 associated coupling to passing bar counting central datum line, and this association coupling centering, the x axial coordinate of certain bar section actual observation central point of former frame is on the right of bar counting central datum line, in present frame, the x axial coordinate of the actual observation central point of associated coupling is on the left side of bar counting central datum line, so barCount counting variable adds up 1, the currency of counting variable barCount is 1.
If the x axial coordinate of certain the bar section actual observation central point 2. in former frame is on the left side of bar counting central datum line, in present frame, the x axial coordinate of the actual observation central point of associated coupling is on the right of bar counting central datum line, counting variable barCount value is subtracted to 1, in Fig. 6, there is not this situation, therefore counting variable barCount value is constant.
The bar on-line Auto-counting of present frame finishes.
8) according to step 3) ~ 7) successively the bar of every frame is carried out to on-line automatic counting, until this batch of whole countings of bar to be counted are complete, last counting variable batCount value is 858, this batch of on-line automatic counting of bar to be counted adds up to 858.
A kind of bar on-line automatic counting method based on improving gradient Hough circle transformation.
The bar specification that certain Bar Plant is produced is with embodiment 1, and the step of method of counting is:
The first step, bar threshold parameter are determined
Except without accompanying drawing, all the other are with embodiment 1.
Second step, bar on-line Auto-counting
According to the specification of the bar to be counted of selecting, be 14mm, corresponding standard radius Rnom=6, least radius Rmin=3, maximum radius Rmax=9 and merging radius R cmb=12 in read threshold Parameter File ParameterSet.txt, gather the 1st online frame bar section original image, be designated as the online bar section original image of present frame, then according to following steps, carry out bar on-line Auto-counting, count results is stored in counting variable barCount, and the initial value of counting variable barCount is set to 0.
1), except without accompanying drawing, all the other are with the step 1) of second step in embodiment 1.
2), except following testing result with without accompanying drawing, all the other are with the step 2 of second step in embodiment 1):
The value of two-dimensional array tmpCtr after RegionalMax detects is as described in Table 8.
Table 8
26 | 50 | 66 | 86 | 91 | 122 | 128 | 131 | 147 | 154 | 178 | 180 | 185 | 203 | 210 | 212 |
207 | 196 | 154 | 170 | 201 | 209 | 179 | 155 | 207 | 163 | 175 | 149 | 196 | 140 | 182 | 183 |
215 | 221 | 226 | 246 | 256 | 285 |
202 | 165 | 166 | 170 | 216 | 199 |
After the distance of counting stage detects, the value of two-dimensional array tmpCtr is as described in Table 9.
Table 9
26 | 50 | 66 | 86 | 91 | 122 | 128 | 131 | 147 | 154 | 178 | 180 | 185 | 203 | 210 | 0 |
207 | 196 | 154 | 170 | 201 | 209 | 179 | 155 | 207 | 163 | 175 | 149 | 196 | 140 | 182 | 0 |
215 | 221 | 0 | 246 | 256 | 285 |
202 | 165 | 0 | 170 | 216 | 199 |
3) ~ 5) except following testing result, with step 3) ~ 5 of second step in embodiment 1):
The value of two-dimensional array tmpCtr after RegionalMax detects is as described in Table 10.
Table 10
9 | 40 | 63 | 76 | 98 | 104 | 135 | 139 | 144 | 161 | 167 | 192 | 193 | 198 | 216 | 217 |
183 | 208 | 197 | 153 | 171 | 202 | 210 | 180 | 156 | 208 | 164 | 175 | 151 | 198 | 141 | 181 |
223 | 225 | 235 | 259 | 268 | 296 |
184 | 184 | 166 | 170 | 217 | 198 |
After the distance of counting stage detects, the value of two-dimensional array tmpCtr is as described in Table 11.
Table 11
9 | 40 | 63 | 76 | 98 | 104 | 135 | 139 | 144 | 161 | 167 | 192 | 193 | 198 | 216 | 0 |
183 | 208 | 197 | 153 | 171 | 202 | 210 | 180 | 156 | 208 | 164 | 175 | 151 | 198 | 141 | 0 |
223 | 0 | 235 | 259 | 268 | 296 |
184 | 0 | 166 | 170 | 217 | 198 |
6) except following step 4., all the other are with the step 6) of second step in embodiment 1:
4. calculate respectively the present frame of each estimation and estimate the distance between vertical projection and former frame observation vertical projection, when speed variable i _ speed gets ﹣ 13, the present frame of corresponding estimation estimates that the distance between vertical projection and former frame observation vertical projection is minimum, and ﹣ 13 is bar integral level movement velocity G_Speed.
7) first utilize described bar integral level movement velocity G_Speed, set up associated pair relationhip of former frame and present frame bar section actual observation central point based on bee-line criterion, establishment step is:
Former frame bar section actual observation central point is designated as to former frame central point to be matched, and present frame bar section actual observation central point is designated as present frame central point to be matched.
1. the equal level of x axial coordinate of all central points to be matched in former frame is offset to G_Speed pixel left, obtains respectively former frame central point to be matched and in ,Gai position, the estimated position of present frame, be designated as present frame estimation center position.
2. ask in present frame each estimate center position respectively with the distance of each center position to be matched, set up as follows more associated coupling right: if the estimation central point of former frame center point P ipos to be matched in present frame is Pipos_pre, this estimates in center point P ipos_pre and present frame that certain center point P temp_pos to be matched is apart from minimum, thinks certain center point P ipos to be matched described in former frame and associated pair relationhip of foundation between certain center point P temp_pos to be matched described in present frame.In Fig. 7, provided an association pair relationhip of setting up in 0.25 * ROI.X to 0.75 * ROI.X horizontal zone, solid black point is wherein present frame actual observation central point, black circles is former frame actual observation central point, and each associated coupling is to connecting with straight line.
In conjunction with each bar section actual observation central point coupling in former frame and present frame, to the distribution situation in bar counting central datum line horizontal direction, according to following counting rule, carry out bar on-line Auto-counting again:
This rule supposition bar integrated moving direction is right-to-left, if bar integrated moving direction is from left to right, and the collection image that camera can be reversed, counting rule remains unchanged, and the vertical center line of selecting in addition ROI region is bar counting central datum line.
If the x axial coordinate of certain the bar section actual observation central point 1. in former frame is on the right of bar counting central datum line, in present frame, the x axial coordinate of the actual observation central point of associated coupling, on the left side of bar counting central datum line, adds 1 to counting variable barCount value.In Fig. 7, there is not this situation, therefore counting variable barCount value is constant.
If the x axial coordinate of certain the bar section actual observation central point 2. in former frame is on the left side of bar counting central datum line, in present frame, the x axial coordinate of the actual observation central point of associated coupling, on the right of bar counting central datum line, subtracts 1 to counting variable barCount value.In Fig. 7, perpendicular line in the middle of ROI region is bar counting central datum line, there are 2 associated couplings to passing bar counting central datum line, and this association coupling centering, the x axial coordinate of certain bar section actual observation central point of former frame is on the left side of bar counting central datum line, in present frame, the x axial coordinate of the actual observation central point of associated coupling is on the right of bar counting central datum line, so counting variable barCount subtracts 2, the currency of counting variable barCount is ﹣ 2.
The bar on-line Auto-counting of present frame finishes.
8) according to step 3) ~ 7) successively the bar of every frame is carried out to on-line automatic counting, until this batch of whole countings of bar to be counted are complete, last counting variable batCount value is 756, this batch of on-line automatic counting of bar to be counted adds up to 756.
This embodiment, on the basis of traditional Grads Hough Transformation circle detection method, adopts and improves gradient Hough circle transformation method and obtain present frame ROI and strengthen image,, further dwindled the search volume of algorithm, guaranteed the real-time of algorithm operation:
1. abandon and adopt Canny operator to ask for edge gradient, adopt all pixel horizontal and vertical direction gradients in Sobel operator computed image, make Riming time of algorithm improve 10ms left and right.
When 2. all image edge pixels points strengthen bar section central point along edge normal, no longer from Rmin to Rmax, search for successively the doubtful centre point of different radii, but based on circular symmetry principle, the doubtful centre point at every turn having searched is advanced to Rmin pixel again along the direction of search.When if this pixel being detected and not being the point on bar section, can stop along the doubtful centre point search in this normal direction.
Secondly, this embodiment has adopted the multi-filtering detection means that RegionalMax detects and distance detects, and has effectively guaranteed counting precision.
Finally, this embodiment has adopted bar counting center reference line method effectively to realize two-way counting, has solved the inaccurate problem of on-line counting causing because of inertia motion before and after bar.
Therefore that, this embodiment has is real-time, counting precision is high, can effectively realize the features such as two-way counting, meets industry spot demand.
Claims (7)
1. the bar on-line automatic counting method based on improving gradient Hough circle transformation, is characterized in that the step of described bar on-line automatic counting method is:
The first step, bar threshold parameter are determined
This step is to the corresponding standard radius Rnom of different size bar, least radius Rmin, maximum radius Rmax and merges determining of radius R cmb threshold parameter, and concrete steps are:
1) four parameter: ROI.X that rectangular area ROI are set represent upper left, ROI region angle point x axial coordinate, and ROI.Y represents upper left, ROI region angle point y axial coordinate, and ROI.Width represents ROI peak width, and ROI.Height represents ROI region height;
2) gather the 1st frame bar section image of a certain scale rod bar;
3) gathered bar section image is designated as to present frame parameter and determines image, in present frame parameter is determined image, selected ROI area image is present frame ROI image, then binaryzation present frame ROI image;
4) the present frame ROI image of binaryzation is carried out to range conversion and Gaussian Blur processing, generate present frame ROI and strengthen image; Then present frame ROI is strengthened to image carries out that RegionalMax detects and parameter is determined the distance detection in stage, finally determine present frame bar section actual observation central point, determined present frame bar section actual observation central point strengthens at present frame ROI the radius that the pixel value in image is corresponding bar;
5) every kind of corresponding bar number of radius value in statistics present frame ROI image, is saved in the radius value of maximum probability wherein in a line of R array;
6) gather this kind of specification the 2nd to f_thres two field picture, wherein f_thres gets any one value in 50 ~ 200, respectively to every two field picture according to step 3) ~ 5) process;
7) ask for the mean value in R array, this mean value is set to the standard radius Rnom of this kind of scale rod bar, then obtain respectively Rmin=(0.3 ~ 0.6 of this kind of scale rod bar) * Rnom, Rmax=(1.2 ~ 1.8) * Rnom and Rcmb=(1.5 ~ 2.5) * Rnom, finally above parameter is saved in threshold parameter file ParameterSet.txt;
8) to every kind of scale rod bar respectively according to step 2) ~ 7) carry out determining of threshold parameter;
Second step, bar on-line Auto-counting
According to the specification of the bar to be counted of selecting, corresponding standard radius Rnom, least radius Rmin, maximum radius Rmax and merging radius R cmb threshold parameter in read threshold Parameter File ParameterSet.txt, gather the 1st online frame bar section original image, be designated as the online bar section original image of present frame, then according to following steps, carry out bar on-line Auto-counting, count results is stored in counting variable barCount, and the initial value of counting variable barCount is set to 0:
1) the online bar section original image of present frame is successively carried out to ROI region division, binaryzation, corrosion and Gaussian Blur pre-service, generate present frame ROI pretreatment image, obtain and preserve the vertical projection of present frame ROI pretreatment image;
2) adopt and improve gradient Hough circle transformation method acquisition present frame ROI enhancing image, step is:
1. definition and initialization ROI add up matrix accum, and in ROI pretreatment image, the corresponding accumulative total of any one pixel p (xi, yi) variable is accum (xi, yi), and its initial value is 0;
2. adopt the horizontal and vertical direction gradient of all pixels in Sobel operator calculating present frame ROI pretreatment image, ask for the edge of present frame ROI pretreatment image;
3. take out a certain marginal point p (xi, yi) in present frame ROI pretreatment image, and R=Rmin is set;
If 4. R≤Rmax, a p (xi, yi) of first take is starting point, after some p (xi, yi) normal direction skew R distance, navigate to doubtful centre point p (xc, yc), accum (xc is set, yc)=accum (xc, yc)+1, then with doubtful centre point p (xc, yc) be starting point, along some p (xi, yi) normal direction, continue to navigate to a p (xr, yr) after skew Rmin distance;
5. if fruit dot p (xr, yr) respective pixel value in ROI pretreatment image is not 255, perform step 6., otherwise 4. R=R+1 returns to step;
6. according to step 3. ~ 5. process another marginal point in present frame ROI pretreatment image; Until all marginal points are handled in present frame ROI pretreatment image;
7. ROI accumulative total matrix accum is saved as to present frame ROI and strengthen image;
Again present frame ROI is strengthened to the distance detection that image carries out RegionalMax detection and counting stage, finally determine present frame bar section actual observation central point;
3) the online bar section original image of present frame is designated as to the online bar section original image of former frame, present frame ROI pretreatment image is designated as former frame ROI pretreatment image, and present frame bar section actual observation central point is designated as former frame bar section actual observation central point; Gather afterwards online next frame bar section original image, be designated as the online bar section original image of present frame;
4) with the step 1) of second step;
5) with the step 2 of second step);
6) vertical projection based on former frame and present frame ROI pretreatment image, estimation bar integral level movement velocity G_Speed;
7) first utilize described bar integral level movement velocity G_Speed, based on bee-line criterion, set up associated pair relationhip of former frame and present frame bar section actual observation central point; In conjunction with each bar section actual observation central point coupling in former frame and present frame, to the distribution situation in bar counting central datum line horizontal direction, according to following counting rule, carry out bar on-line Auto-counting again:
This rule supposition bar integrated moving direction is right-to-left, if bar integrated moving direction is from left to right, and the collection image that camera can be reversed, counting rule remains unchanged, and the vertical center line of selecting in addition ROI region is bar counting central datum line;
(1) if the x axial coordinate of certain the bar section actual observation central point in former frame on the right of bar counting central datum line, in present frame, the x axial coordinate of the actual observation central point of associated coupling, on the left side of bar counting central datum line, adds 1 to counting variable barCount value;
(2) if the x axial coordinate of certain the bar section actual observation central point in former frame on the left side of bar counting central datum line, in present frame, the x axial coordinate of the actual observation central point of associated coupling, on the right of bar counting central datum line, subtracts 1 to counting variable barCount value;
The bar on-line Auto-counting of present frame finishes;
8) according to step 3) ~ 7) successively the bar of every frame is carried out to on-line automatic counting, until this batch of whole countings of bar to be counted are complete, last counting variable batCount value is the sum of this batch of bar to be counted.
2. the bar on-line automatic counting method based on improving gradient Hough circle transformation according to claim 1, is characterized in that the step that described RegionalMax detects is:
Two-dimensional array tmpCtr[2] [100], for preserving x axle and the y axial coordinate value of the doubtful observation central point of present frame, it is 0 that doubtful observation central point counting variable tmpNum initial value is set;
1) each pixel that present frame ROI strengthens in image all carries out RegionalMax detection as follows:
If present frame ROI strengthens the pixel value of a certain pixel p (xi, yi) in image, be less than thres, thres gets any one value in [2 ~ 10], and the pixel value of this pixel p (xi, yi) is maximal value in its 8 neighborhood simultaneously;
Assert that this pixel p (xi, yi) is the doubtful observation central point of present frame bar section,
TmpCtr[0 is set] [tmpNum]=yi, tmpCtr[1] [tmpNum]=xi, tmpNum=tmpNum+1;
2) the doubtful observation central point of all bar sections of storing in two-dimensional array tmpCtr is all carried out to RegionalMax detection as follows:
If the doubtful observation central point of a certain bar section t meets any in following relation:
tmpCtr[0][t]=ROI.width-1,
tmpCtr[0][t]=0, tmpCtr[1][t]=ROI.Height-1,
tmpCtr[1][t]=0;
tmpCtr[0][t]=0,
tmpCtr[1][t]=0,
tmpNum=tmpNum-1;
Otherwise the doubtful observation central point of this bar section t of take is starting point, in present frame ROI enhancing image, find pixel point set identical with this doubtful observation central point t pixel value and that be interconnected;
Then take out arbitrary pixel q that pixel is concentrated, if the pixel value of certain pixel of the interior existence of 8 neighborhoods of arbitrary pixel q is greater than the pixel value of this doubtful observation central point t, tmpCtr[1] [t]=0,
tmpCtr[0][t]=0,
tmpNum=tmpNum-1;
The judgement of the rest of pixels that pixel is concentrated is with described arbitrary pixel q.
3. the bar on-line automatic counting method based on improving gradient Hough circle transformation according to claim 1, is characterized in that the step that described parameter determines that the distance in stage detects is:
Get i and two doubtful observation central points of j in two-dimensional array tmpCtr, the respective pixel value that described two doubtful observation central points strengthen in image at present frame ROI is respectively:
P(tmpCtr[1][i],tmpCtr[0][i]),P(tmpCtr[1][j],tmpCtr[0][j]);
The distance of described two doubtful observation central points is R, and parameter determines that the step that the distance in stage detects is:
If R meets any in following relation:
R< P (tmpCtr[1] [i], tmpCtr[0] [i]), R< P (tmpCtr[1] [j], tmpCtr[0] [j]) time
If P (tmpCtr[1] [i], tmpCtr[0] [i])≤P (tmpCtr[1] [j], tmpCtr[0] [j])
tmpCtr[1][i]=0,tmpCtr[0][i]=0,tmpNum=tmpNum-1;
Otherwise
tmpCtr[1][j]=0,tmpCtr[0][j]=0,tmpNum=tmpNum-1;
In two-dimensional array tmpCtr, the parameter of any two doubtful observation central points determines that the distance in stage detects the same.
4. the bar on-line automatic counting method based on improving gradient Hough circle transformation according to claim 1, is characterized in that the step that the distance of described counting stage detects is:
Get in two-dimensional array tmpCtr i and two doubtful observation central points of j arbitrarily, the respective pixel value that described two doubtful observation central points strengthen in image at present frame ROI is respectively:
P(tmpCtr[1][i],tmpCtr[0][i]),P(tmpCtr[1][j],tmpCtr[0][j]);
The distance of described two doubtful observation central points is R, and the step that the distance of counting stage detects is:
If if 1. P during R<Rcmb (tmpCtr[1] [i], tmpCtr[0] [i])≤P (and tmpCtr[1] [j], tmpCtr[0] [j]), tmpCtr[1] [i]=0, tmpCtr[0] [i]=0, tmpNum=tmpNum-1;
If P (tmpCtr[1] [i], tmpCtr[0] [i]) >P (tmpCtr[1] [j], tmpCtr[0] [j]), tmpCtr[1] [j]=0, tmpCtr[0] [j]=0, tmpNum=tmpNum-1;
If 2. present frame is not the 1st frame, when R>Rcmb and R<1.5 * Rcmb, set up the association pair relationhip between the doubtful observation central point of former frame bar section actual observation central point and present frame bar section; If in present frame, two doubtful observation central points of i and j mate with same actual observation central point in former frame,
If P (tmpCtr[1] [i], tmpCtr[0] [i])≤P (tmpCtr[1] [j], tmpCtr[0] [j]), tmpCtr[1] [i]=0, tmpCtr[0] [i]=0, tmpNum=tmpNum-1;
If P (tmpCtr[1] [j], tmpCtr[0] [j]) >P (tmpCtr[1] [j], tmpCtr[0] [j]),
tmpCtr[1][j]=0,tmpCtr[0][j]=0,tmpNum=tmpNum-1;
In two-dimensional array tmpCtr, the distance of the counting stage of any two doubtful observation central points detects the same.
5. the bar on-line automatic counting method based on improving gradient Hough circle transformation according to claim 1, is characterized in that described definite present frame bar section actual observation central point is:
Get r column element in two-dimensional array tmpCtr, if tmpCtr[0] [r] and tmpCtr[1] [r] be not equal to 0 simultaneously,
Pixel p in present frame ROI enhancing image (tmpCtr[1] [r], tmpCtr[0] [r]) be a bar section actual observation central point in present frame;
All the other each column elements in two-dimensional array tmpCtr, all determine all the other the bar section actual observation central points in present frame as stated above.
6. the bar on-line automatic counting method based on improving gradient Hough circle transformation according to claim 1, is characterized in that the step of described estimation bar integral level movement velocity G_Speed is:
1) tangential movement speed exploration scope is set for [MaxSpeed, MaxSpeed], MaxSpeed be (1/6~1/4) *
ROI.Width;
2) arrange in former frame ROI pretreatment image vertical projection and start from MaxSpeed, a part of projection result that width is ROI.Width-2 * MaxSpeed is designated as former frame observation vertical projection;
3) based on former frame observation vertical projection, get in order exploration scope [MaxSpeed, MaxSpeed] in each round values, successively by its assignment to speed variable i _ speed, every assignment once estimates that a corresponding present frame estimates vertical projection, a part of projection that this estimations vertical projection is is ROI.Width-2 * MaxSpeed from the width of MaxSpeed-i_speed beginning in present frame ROI pre-service vertical projection;
4) present frame that calculates respectively each estimation is estimated the distance between vertical projection and former frame observation vertical projection, when if speed variable i _ speed gets a certain value, the present frame of corresponding estimation estimates that the distance between vertical projection and former frame observation vertical projection is minimum, and described a certain value is bar integral level movement velocity G_Speed.
7. according to the bar on-line automatic counting method based on improving gradient Hough circle transformation described in claim 1 or 4, it is characterized in that the establishment step of a described association pair relationhip is:
Former frame bar section actual observation central point is designated as to former frame central point to be matched, and present frame bar section actual observation central point or doubtful observation central point are designated as present frame central point to be matched;
1) the equal level of x axial coordinate of all central points to be matched in former frame is offset to G_Speed pixel left, obtains respectively former frame central point to be matched and in ,Gai position, the estimated position of present frame, be designated as present frame estimation center position;
2) ask in present frame each estimate center position respectively with the distance of each center position to be matched, set up as follows more associated coupling right: if the estimation central point of former frame center point P ipos to be matched in present frame is Pipos_pre, this estimates in center point P ipos_pre and present frame that certain center point P temp_pos to be matched is apart from minimum, thinks certain center point P ipos to be matched described in former frame and associated pair relationhip of foundation between certain center point P temp_pos to be matched described in present frame.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210203505.9A CN102774539B (en) | 2012-06-19 | 2012-06-19 | Bar on-line automatic counting method based on modified gradient Hough circle transformation |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210203505.9A CN102774539B (en) | 2012-06-19 | 2012-06-19 | Bar on-line automatic counting method based on modified gradient Hough circle transformation |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102774539A CN102774539A (en) | 2012-11-14 |
CN102774539B true CN102774539B (en) | 2014-02-26 |
Family
ID=47119692
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210203505.9A Expired - Fee Related CN102774539B (en) | 2012-06-19 | 2012-06-19 | Bar on-line automatic counting method based on modified gradient Hough circle transformation |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102774539B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106529551B (en) * | 2016-11-02 | 2020-01-17 | 南通大学 | Intelligent recognition counting detection method for round-like objects in packaging industry |
CN108010076B (en) * | 2017-11-23 | 2020-03-31 | 南通大学 | End face appearance modeling method for intensive industrial bar image detection |
CN108734260B (en) * | 2018-05-17 | 2022-07-05 | 自贡中兴耐磨新材料有限公司 | Part counting device and system |
CN116823820B (en) * | 2023-08-29 | 2023-11-07 | 青岛东冶耐火材料有限公司 | Aluminum-carbon integral stopper rod contour bending detection method |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP3208657B2 (en) * | 1997-03-24 | 2001-09-17 | 三菱電機株式会社 | Radio source location device |
CN101912899A (en) * | 2010-06-21 | 2010-12-15 | 中冶京诚工程技术有限公司 | Bar counting method and device |
CN102254222A (en) * | 2011-07-07 | 2011-11-23 | 合肥市百胜科技发展股份有限公司 | Method and device for counting bar materials |
CN202174129U (en) * | 2011-07-07 | 2012-03-28 | 合肥市百胜科技发展股份有限公司 | Bar counting device |
-
2012
- 2012-06-19 CN CN201210203505.9A patent/CN102774539B/en not_active Expired - Fee Related
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP3208657B2 (en) * | 1997-03-24 | 2001-09-17 | 三菱電機株式会社 | Radio source location device |
CN101912899A (en) * | 2010-06-21 | 2010-12-15 | 中冶京诚工程技术有限公司 | Bar counting method and device |
CN102254222A (en) * | 2011-07-07 | 2011-11-23 | 合肥市百胜科技发展股份有限公司 | Method and device for counting bar materials |
CN202174129U (en) * | 2011-07-07 | 2012-03-28 | 合肥市百胜科技发展股份有限公司 | Bar counting device |
Non-Patent Citations (3)
Title |
---|
基于数字图像处理技术的棒材计数问题的研究与分析;高民等;《河南冶金》;20070615;第15卷(第3期);第28-29页,第32页 * |
苏志祁,尉宇,王涛.《改进hough变换的算法实现》.《现代电子技术》.2009,(第10期),第42-44页. * |
高民等.基于数字图像处理技术的棒材计数问题的研究与分析.《河南冶金》.2007,第15卷(第3期),第28-29页,32页--------------------------------------. |
Also Published As
Publication number | Publication date |
---|---|
CN102774539A (en) | 2012-11-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102774539B (en) | Bar on-line automatic counting method based on modified gradient Hough circle transformation | |
CN100513997C (en) | Multiple angle movement target detection, positioning and aligning method | |
CN104200212B (en) | A kind of building external boundary line drawing method based on airborne LiDAR data | |
CN109272523B (en) | Random stacking piston pose estimation method based on improved CVFH (continuously variable frequency) and CRH (Crh) characteristics | |
CN102779345B (en) | A kind of some cloud Precision Registration based on center of gravity Euclidean distance | |
CN102829735B (en) | Machine vision based detection method of defect of geometrical shape of back surface of E type magnet | |
CN101930594B (en) | Rapid correction method for scanning document image | |
CN111062915A (en) | Real-time steel pipe defect detection method based on improved YOLOv3 model | |
CN105654097A (en) | Method for detecting quadrangular marker in image | |
CN103292701A (en) | Machine-vision-based online dimensional measurement method of precise instrument | |
CN105865344A (en) | Workpiece dimension measuring method and device based on machine vision | |
CN102441581A (en) | Machine vision-based device and method for online detection of structural steel section size | |
CN109060836A (en) | High-pressure oil pipe joint external screw thread detection method based on machine vision | |
CN107742289A (en) | One kind is based on machine vision revolving body workpieces detection method | |
CN100520811C (en) | Method for recognizing outline shape of digital image | |
CN105096299A (en) | Polygon detection method and device | |
CN104076743B (en) | A kind of interpolation control method of self-identifying interpolation kind | |
CN104537342B (en) | A kind of express lane line detecting method of combination ridge border detection and Hough transformation | |
CN105678768A (en) | Machine vision-based tire tread detection method | |
CN104408772A (en) | Grid projection-based three-dimensional reconstructing method for free-form surface | |
CN111353985A (en) | Airport self-service consignment luggage detection method based on depth camera | |
CN102254222A (en) | Method and device for counting bar materials | |
CN114119488A (en) | Intelligent size and quality detection method for prefabricated laminated plate facing factory | |
CN103714547A (en) | Image registration method combined with edge regions and cross-correlation | |
CN102074011B (en) | Method for detecting oblique triangle in digital image |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20140226 Termination date: 20150619 |
|
EXPY | Termination of patent right or utility model |