CN109886265B - Vehicle door limiter detection method based on Adaboost and template matching - Google Patents
Vehicle door limiter detection method based on Adaboost and template matching Download PDFInfo
- Publication number
- CN109886265B CN109886265B CN201910027016.4A CN201910027016A CN109886265B CN 109886265 B CN109886265 B CN 109886265B CN 201910027016 A CN201910027016 A CN 201910027016A CN 109886265 B CN109886265 B CN 109886265B
- Authority
- CN
- China
- Prior art keywords
- picture
- template
- character
- matching
- num
- 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.)
- Active
Links
Images
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/30—Computing systems specially adapted for manufacturing
Landscapes
- Image Analysis (AREA)
Abstract
The invention provides a car door limiter detection method based on Adaboost and template matching, which comprises the steps of identifying and positioning nut features in a picture of a car door limiter to be detected by using an Adaboost classifier; roughly positioning a character area on the picture of the vehicle door limiter to be detected preliminarily according to the positioning result of the nut characteristics in the picture of the vehicle door limiter to be detected and the position relation between the upper nut of the picture of the vehicle door limiter to be detected and the character characteristics; making an optimal template library of the characters by using a double iteration method, and simultaneously solving an optimal threshold value of template matching; extracting the edge characteristics of the picture and the template of the vehicle door limiter to be detected, identifying the characters by utilizing an improved rapid template matching method, and completing the steps of detecting and identifying the vehicle door limiter to be detected; the detection speed and the accuracy of the detection of the door stopper are improved.
Description
Technical Field
The invention belongs to the technical field of industrial part detection, and particularly relates to a car door limiter detection method based on Adaboost and template matching.
Background
The traditional industrial part detection and identification method judges whether the part has errors or not by means of manual visual observation, and the like, and probably has great accuracy in a short time, but along with the large-scale production of modern factories, the human eyes cannot avoid fatigue under long-time work, so that the accuracy is greatly reduced, and the current industrial production requirements cannot be met.
At present, machine vision-based industrial part detection at home and abroad mainly takes a template matching-based identification method and a statistical pattern-based identification method as main parts. The template matching method is also called a neighbor method, is the most important method in pattern recognition nonparametric, is the most common method, is widely used for character detection and recognition algorithms, and has the characteristics of simple algorithm, visual classification, quick calculation and easy understanding and realization. The template matching method can be roughly divided into three categories: the first category is grayscale image-based template matching methods, the second category is feature-based template matching methods, and the third category is matching methods based on understanding and interpretation of images. At present, the research on template matching at home and abroad mainly focuses on the matching speed and precision, and more researched methods are also concentrated on the first two matching methods. The first type of template matching method based on grayscale images is a process of using one image as a template and searching the corresponding position of the template on the other image by a pixel-by-pixel comparison method. Because the image information provided by the template is more complete, the template matching algorithm based on the gray level image can better adapt to the adverse factors such as weak features, image noise, imaging blur and the like than the template matching algorithm based on the features. However, for some real-time image matching tasks or heterogeneous image matching tasks with serious noise and gray distortion interference, the existing template matching algorithm often has the problems of low operation efficiency, insufficient reliability when preprocessing is not performed and the like. Therefore, the method has very important significance in researching the template matching algorithm with high calculation speed and good reliability. A second class of feature-based template matching includes template matching of globally invariant features and locally invariant features. Algorithms that utilize global invariant features are rarely used because they are not easily obtained and cannot distinguish between foreground and background. The local invariant feature of an image refers to a local feature that remains invariant under various transformations such as a change in a viewing angle of the image, a change in rotation, a change in scale, a change in illumination, an image blur, and an image compression. The calculation complexity of image matching based on local invariant features is reduced compared with an algorithm based on gray level correlation, and the anti-noise and anti-interference capability is strong. The current local feature-based template matching algorithm is widely applied due to high robustness, and mainly comprises two aspects of feature detection and feature description. At present, methods widely used in the field of feature detection include a Harris affine method, a Hessian affine method, a MSER method, a DOG method, an IBR method, an EBR method and the like. And comprehensively analyzing the performances of the feature detection algorithms, then carrying out feature description, and carrying out feature description by using a local invariant feature descriptor on the region obtained by feature detection. Among the most classical local invariant feature descriptors are SIFT and DAISY descriptors, while MROGH, MRRID, LIOP and HRI-CSLTP descriptors are the most popular and interesting descriptors in recent years. A third type of recognition algorithm based on a statistical mode needs to establish a sample library, then sample characteristics are extracted through a series of methods, finally a classifier is trained through a machine learning method, and finally the recognition process is completed. The algorithm has the advantage of being very robust compared to a template matching algorithm.
Disclosure of Invention
In order to solve the technical problems in the prior art, the invention provides a car door limiter detection method based on Adaboost and template matching, which is different from the template matching method in the traditional industrial part detection, firstly, the front light source is used for illuminating the car door limiter, then the picture of the car door limiter is collected, then the classifier obtained by Adaboost training is used for positioning and identifying the nut on the car door limiter, then the character features on the vehicle door limiter are roughly positioned by utilizing the position relation between the nut on the vehicle door limiter and the characters, extracting edge information of character features on the car door limiter on the basis of rough positioning, finally adopting an improved rapid template matching method to identify the type of the car door limiter, the corresponding method well solves the problem that the type of the door limiter is difficult to judge because the hollow characters are arranged on the door limiter and the character information is difficult to detect.
The technical problem to be solved by the invention is realized by the following technical scheme:
a car door limiter detection method based on Adaboost and template matching comprises the following steps:
s1, acquiring a picture of the waiting door stopper, and identifying and positioning nuts in the acquired picture of the waiting door stopper by using an Adaboost classifier;
step S2, according to the recognition result of the nuts in the car door limiter picture obtained in the step S1, and in combination with the position relation between the nuts on the car door limiter and the characters on the car door limiter in the standard database, carrying out coarse positioning on the character area on the car door limiter to be detected;
s3, making an optimal template library of the characters on the car door limiter by using a double iteration method, and simultaneously obtaining an optimal threshold value of the characters on the car door limiter matched with the template;
and S4, after the step S3 is completed, extracting the picture of the vehicle door limiter to be detected and the edge characteristics of the character template used in the optimal template library, identifying the characters in the picture of the vehicle door limiter to be detected by using a rapid template matching method, and completing the detection and identification of the vehicle door limiter to be detected.
Further, in the step S1, the preparation process of the Adaboost classifier includes firstly preparing positive and negative samples required for training, where the number ratio of the positive and negative samples is 1:2 to 1:4, the positive sample is a positive image of a nut on the vehicle door check device to be tested, and the negative sample is composed of a negative image of the nut on the vehicle door check device to be tested, an image in which the nut is not shot in the production process, and an image in which only a part of the nut is shot, and creating a vector description file of the positive and negative samples required for training; and training a plurality of weak classifiers by using local binary pattern characteristics through an OpenCV open source library, and forming the Adaboost strong classifier.
Further, in step S3, the method for calculating the optimal template library of the characters on the car door check and the optimal threshold of the template matching characters by using the double iteration method specifically includes the following steps:
s3.1, obtaining L pictures of the ith character picture as many as possible to form a picture set Pic i For each picture, a template matching method is utilized to match the picture set Pic i The other pictures are matched one by one, and the obtained L-1 similarity is added to obtain the sum of the similarities, namely the sum { sim ] of the L similarities is obtained 1 ,sim 2 ,sim 3 ,…,sim L };
Step (ii) ofS3.2, taking { sim ] in the step S3.1 1 ,sim 2 ,sim 3 ,…,sim L The front Num where the sum of similarity degrees is minimum spe Each picture forms a picture set spe, and the front Num with the maximum sum of similarity gen The pictures form a picture set gen, and the picture set spe and gen are combined into an initial template library Temp of the corresponding type of car door stop i ;
Step S3.3, respectively using the initial template library Temp obtained in the step S3.2 i All templates and picture sets Pic in i Each picture in (1) is matched with a template due to Temp i Chinese character of Num gen +Num spe A template, therefore Pic i Each picture in the picture can obtain Num gen +Num spe Taking the maximum value of the similarity value as a template library Temp i And picture set Pic i The similar reliability of the picture, then Pic i L similar credibility can be obtained from the middle L pictures to form a credibility setThis confidence level represents Pic i The character on the middle L pictures is the credibility of the ith character;
step S3.4, obtaining a template library Temp of characters on the stoppers of other vehicle types by using the methods of the step S3.1 and the step S3.2 j (j ≠ i and j ≠ 1, 2, 3, …), will Temp j Instead of Temp in said step S3.3 i Method and picture set Pic according to step S3.3 i All pictures in the picture list are matched by templates to obtain a picture set Pic i Each character picture in (1) is a reliability set of the jth character
Step S3.5, if the template library Temp of the step S3.2 i And Temp i (j ≠ i and j ≠ 1, 2, 3, …) can be used to collect Pic pictures i Is recognized as the correct character type, i.e. the ith character, then the reliability setIs greater than the set(j ≠ i and j ≠ 1, 2, 3, …) and further sets the picture set Pic i Match error rate ofWherein NumWrong i For a picture set Pic i The number of pictures in the text that are identified as non-ith characters, i.e. the confidence level setLess than the matching threshold T of the template i Number of elements (NumWrong) j For character picture set Pic i The number of pictures in which the character of the type j (j ≠ i and j ═ 1, 2, 3, …) is identified, i.e., the reliability set(j ≠ i and j ≠ 1, 2, 3, …) greater than the match threshold T for the template i The number of elements of (2) to obtain the best template library Temp i The process of (1) is to find the optimum threshold value T i And the optimum Num gen 、Num spe So that the matching error rate W i A minimal process;
step S3.6, firstly fixing Num in step S3.5 gen 、Num spe To find the threshold value T i Make the template library Temp i Match error rate ofMinimum, finally by the threshold value T obtained i The middle point of the section is used as the optimal threshold value, and after the optimal threshold value is obtained, if the template library Temp is at the moment i Matching error rate W of i Is equal to or less than 0.0001, then Num gen 、Num spe If the template library is optimal, the template library is manufactured, and the optimal threshold value T is i Has also been found, otherwise the threshold value T is fixed i If the reliability is setIs less than the optimum threshold value T i If the reliability number of (2) is more than 0.2 x L, the generality of the template is not sufficient, and Num is increased gen Then continuously calculating the matching error rate W i If the reliability is setIs less than the optimum threshold value T i If the reliability number of (2) is less than 0.02 x L, it means that the specificity of the template is insufficient, and Num is increased spe Then continuously calculating the matching error rate W i If the matching error rate W is the same as the previous matching error rate i Is equal to zero or less than 0.0001, then Num gen 、Num spe If the template library is optimal, the template library is manufactured, and the optimal threshold value T is i Also found, otherwise repeat this step until W i Equal to zero or less than 0.0001;
step S3.7, the final Num obtained according to the step S3.6 gen 、Num spe For the ith character picture set Pic in step S3.1 i Sum of similarity { sim 1 ,sim 2 ,sim 3 ,…,sim L Minimum front Num in spe The character pictures form a picture set spe, and the front Num with the maximum sum of the similarity gen Composing picture set gen by character pictures, merging picture set spe and gen into Temp i ,Temp i I.e. the template library of the i-th character finally formed, and the T finally obtained in said step S3.6 i I.e. the best threshold for template matching for the ith character.
Further, the step S4 specifically includes the following steps:
s4.1, obtaining the position of the nut on the car door limiter according to the step S3, obtaining the position of the character on the car door limiter according to the position relation between the nut on the car door limiter and the character, and intercepting the area where the character is located;
s4.2, calculating a gradient map of the character region picture, and extracting edge information by using a dual-threshold method;
and S4.3, setting the number of the characters on the vehicle door limiter to be tested to be numofcha, wherein the characters on all the vehicle door limiters are numofkind, extracting edges of the template library of the numofkind characters obtained in the step S3 by using the method in the step S4.2, then respectively performing template matching with the character regional gradient map obtained in the step S4.2, and selecting the most appropriate numofcha character in the matching results of the template library as the identification result of the model of the vehicle door limiter to be tested.
Preferably, the creating of the vector description file for training the positive and negative samples comprises the following specific steps:
the training samples are divided into positive samples and negative samples, the number proportion of the positive samples and the negative samples is 1:2-1:4 in the training process, the negative samples are composed of two parts, namely a nut reverse side picture of the vehicle door check device to be tested, a picture in which a nut is not shot in the production process and a picture in which only a part of the nut is shot, the proportion of corresponding characteristic pictures on other types of vehicle door check devices and error pictures possibly appearing in the production process is ensured to be 2:1-4:1, the formats of all the pictures are converted into bmp formats, and the pictures of all the positive samples are sized into 65 pixels long and 65 pixels wide.
Further, the specific process of step S4.2 is as follows:
calculating the gradient of the character region picture by using a Sobel operator to obtain the gradient value and the direction of each pixel point on the character region picture, and setting two threshold values theta 1 And theta 2 Making the gradient value less than theta 1 Setting the gradient value of the pixel point to be zero, and enabling the gradient value to be larger than theta 2 The gradient value of the pixel point is reserved, when the gradient value is between theta 1 And theta 2 The gradient value existing in the peripheral 80 connected region of the pixel point is larger than theta 1 The number of the pixel points exceeds 24, namely the gradient value around the corresponding point is larger than theta 1 If the density of the pixel points is more than 0.3, the gradient value is reserved, otherwise, the gradient value is set to be zero.
Further, in the step S4.3, the specific process is as follows:
setting a plurality of possibilities for a first character of a car door stopper to be detected, respectively matching gradient graphs of a plurality of character template libraries with gradient graphs of character areas of the car door stopper to be detected as templates, matching an ith template graph with a picture to be detected by continuously sliding a window with a step length of 1 on the picture to be detected by using the template graphs, and correspondingly calculating front r edge pixel points of the template and pixel points of corresponding positions on the picture to be detected to obtain the similarity value of the corresponding template on the picture to be detected in a jth window, wherein the calculation formula is that
WhereinWhen the ith template is represented on the jth window of the picture to be detected, the similarity value obtained by corresponding calculation of the first r edge pixel points of the template and the pixel points at the corresponding positions on the picture to be detected is used,is the size of the transverse gradient value of the mth edge pixel point of the ith template,is the longitudinal gradient value Px of the mth edge pixel point of the ith template m Is the transverse gradient value Py of the pixel point at the corresponding position on the picture to be measured m The vertical gradient value of the pixel point at the corresponding position on the picture to be detected is obtained; r starts iteration from 1, if the ith template picture obtains the similarity value of the first r edge pixel points on the jth window of the picture to be testedIf a predetermined condition is satisfied, r is r +1, and the calculation is continuedOtherwise, the position to be measured is abandoned, the ith template picture is slid to the j +1 th window of the picture to be measured, and the calculation is continued from the condition that r is equal to 1 The predetermined condition is required to be satisfied as
Where T is the optimal threshold for the template matching obtained in step S3,initializing the minimum confidence coefficient of the character represented by the ith window of the picture to be detected, namely the ith template, to be T, namely Continuously iterating to generate Numofpix, wherein Numofpix is the total number of the edge pixels of the ith template, rmax is the total number of the edge pixels of the template actually added to the last matching window or the last matching window of the last template, and jmax is the serial number of the last matching window of the last template; and for the first character, obtaining a final matching similarity for each possible character template library, taking the maximum value of the similarities, taking the maximum value as the recognition result of the character if the maximum value is greater than T, otherwise, considering that no matching result exists, and processing each character on the car door limiter one by one so as to obtain the recognition results of all characters on the car door limiter.
Further, the threshold value θ 1 、θ 2 Is calculated by theta at the initial state 1 =50、θ 2 After extracting edge information by using the double threshold method, calculating the number numofoixel of edge pixel points, falseIf the total number of pixels of the character area picture is S, the density of edge pixel points in the picture after the edge information is extracted is SIf rho is less than 0.03, the gradient value of partial edge pixel points is set to zero, and theta is correspondingly reduced 2 If rho is more than 0.1, part of non-edge pixel points are identified as edge pixel points, so that theta is correspondingly increased 2 Until rho is more than or equal to 0.03 and less than or equal to 0.1, the theta is 1 And theta 2 Is the final theta 1 And theta 2 。
Compared with the prior art, the invention has the following beneficial effects:
(1) according to the invention, because the problems that the single template is difficult to solve in actual production such as illumination change, shooting angle change and the like are very likely to occur, template matching is carried out by adopting a template library method, and based on the researched method for manufacturing the optimal template library by utilizing double iteration, the optimal threshold value of template matching is simultaneously obtained, so that the detection accuracy of the car door limiter is improved.
(2) When the template library is used for template matching of the pictures of the car door limiter to be detected, the program running time can be linearly increased along with the increase of the number of the templates, so that the matching speed is greatly improved by the method provided by the invention, and the detection speed of the car door limiter is improved.
Drawings
FIG. 1 is a flow chart of the present invention;
FIG. 2 is a flowchart of step S3 of creating an optimal template library according to the present invention;
fig. 3 is a flowchart of the template matching of step S4 of the present invention.
Detailed Description
The present invention is further illustrated by the following specific examples, which are intended to be illustrative, not limiting and are not intended to limit the scope of the invention.
As shown in fig. 1, the method for detecting a car door stopper based on Adaboost and template matching according to the present invention uses a gray image including the car door stopper, which is acquired in a forward light source lighting manner, as a processing object, and mainly includes three main processes of obtaining an accurate position of a nut on the car door stopper by using an Adaboost classifier, performing rough positioning on character features, making a character template library, performing template matching on characters, and identifying the characters. The specific implementation scheme is as follows:
step 1) preparing a positive sample and a negative sample with the proportion of 1:2-1:4, wherein the positive sample is a picture of the front surface of a nut on a vehicle door limiter to be tested, the negative sample consists of a picture of the back surface of the nut on the vehicle door limiter to be tested, a picture in which the nut is not shot in the production process and a picture in which only part of the nut is shot, and a vector description file of the positive sample and the negative sample required by training is created, and the specific steps are as follows:
training samples are divided into positive samples and negative samples, the proportion of the positive samples to the negative samples is generally kept between 1:2 and 1:4 in the training process, 6247 pieces of complete nut pictures on the car door limiter are prepared to serve as the positive samples, and 21288 pieces of negative samples are prepared. The negative sample consists of two parts, namely a picture of the back surface of the nut of the vehicle door check device to be tested, a picture of the nut which is not shot in the production process and a picture of only shooting part of the nut, and the proportion of corresponding characteristic pictures on other types of vehicle door check devices and error pictures which possibly appear in the production process is ensured to be 2:1-4: 1. All picture formats are converted to bmp format and all positive samples are normalized in picture size to 65 pixel long by 65 pixel wide.
Step 2) training a plurality of weak classifiers by using Local Binary Pattern (LBP) characteristics through an OpenCV open source library to form an Adaboost strong classifier;
and 3) loading the corresponding classifier to position and identify the nut in the picture of the door stopper to be detected.
And 4) according to the recognition result of the nut in the car door limiter picture obtained in the previous step, combining the position relation between the nut on the car door limiter and the characters on the car door limiter in the standard database, preliminarily judging the approximate position of the character area indicating the type on the car door limiter, and recognizing the characters by using an improved efficient template matching method, thereby realizing the purpose of detecting the car door limiter, and the specific process is as follows:
a) as shown in fig. 2, before template matching, a template library is first created, character area pictures of a plurality of pictures of the car door check with the correct model are intercepted, each character is intercepted, a plurality of pictures of a certain character are selected as template pictures of corresponding characters by a double iteration method, and the template pictures are added into the corresponding character template library to create various character template libraries, namely the double iteration method is as follows:
i. the vehicle door limiter has 4 vehicle types, each vehicle type has 4 vehicle doors, each vehicle door has a vehicle door limiter, so 16 vehicle door limiters are provided, and each vehicle door limiter is distinguished by characters. Firstly, obtaining L total pictures of the ith character picture as much as possible to form a picture set Pic i For each picture, a template matching method and a picture set Pic are utilized i The other pictures are matched one by one, and the sum of the similarity is obtained after adding the obtained L-1 similarities, so that the sum { sim ] of the L similarities can be obtained 1 ,sim 2 ,sim 3 ,…,sim L };
ii, take { sim 1 ,sim 2 ,sim 3 ,…,sim L The front Num where the sum of similarity degrees is minimum spe Each picture forms a picture set spe, and the front Num with the maximum sum of similarity gen The pictures form a picture set gen, and the picture set spe and gen are combined into a template library Temp of the corresponding type car door limiter i The image set spe is used for considering the particularity of the images to be detected which are matched with the template library in a template mode, namely, considering that some images to be matched are distinctive, and the image set gen is used for considering the generality of the images to be detected which are matched with the template library in a template mode, namely, most images to be matched are similar;
separately using Temp i All templates and picture sets Pic in the template library i Each picture in (1) is matched with a template due to Temp i Among them is Num gen +Num spe A template, therefore Pic i Each picture in the picture can obtain Num gen +Num spe Taking the maximum value of the similarity value as a template library Temp i And picture set Pic i The similarity confidence of the picture, then Pic i Obtaining L similar credibility from the middle L pictures to form a credibility setThis confidence level represents Pic i The character on the middle L pictures is the credibility of the ith character;
using the same template library Temp obtained from step i and step ii above j (j ≠ i and j ≠ 1, 2, 3, …), will Temp j Instead of Temp in step iii above i Method and picture set Pic according to step iii i All pictures in the picture list are matched by templates to obtain a picture set Pic i Each character picture in (1) is a reliability set of the jth character
v. if template library Temp i And Temp j (j ≠ i and j ≠ 1, 2, 3, …) can be used to collect Pic pictures i Is recognized as the correct character type, i.e. the ith character, then the reliability setIs greater than the set(j ≠ i and j ≠ 1, 2, 3, …) is the maximum value, and the picture set Pic is further set i Match error rate ofWherein NumWrong i For a picture set Pic i The number of pictures in the text that are identified as non-ith characters, i.e. the confidence level setLess than the matching threshold T of the template i Number of elements of (2), NumWrong j For character picture set Pic i The number of pictures in which the character of the type j (j ≠ i and j ═ 1, 2, 3, …) is identified, i.e., the reliability set(j ≠ i and j ≠ 1, 2, 3, …) greater than the match threshold T for the template i The number of elements of (2) to obtain the best template library Temp i The process of (1) is to find the optimum threshold value T i And the optimum Num gen 、Num spe So that the matching error rate W i A minimal process;
fixing Num first gen 、Num spe To find the threshold value T i Make the template library Temp i Match error rate ofMinimum, finally by the threshold value T obtained i The middle point of the section is used as the optimal threshold value, and after the optimal threshold value is obtained, if the template library Temp is at the moment i Matching error rate W of i Is equal to zero or less than 0.0001, then Num gen 、Num spe If the template library is optimal, the template library is manufactured, and the optimal threshold value T is i Has also been found, otherwise the threshold value T is fixed i If the reliability is setIs less than the optimum threshold value T i If the reliability number of (2) is more than 0.2 x L, the generality of the template is not sufficient, and Num is increased gen Then continuously calculating the matching error rate W i If the reliability is setMiddle less than optimum threshold value T i If the reliability number of (2) is less than 0.02 x L, the template specificity is not sufficient, and Num is increased spe Then continuously calculating the matching error rate W i If the matching error rate W is the same as the previous matching error rate i Is equal to zero or less than 0.0001, then Num gen 、Num spe If the template library is optimal, the template library is manufactured, and the optimal threshold value T is i Also found, otherwise repeat this step until W i Equal to zero or less than 0.0001;
vii, the final Num obtained from the previous step gen 、Num spe For the ith character picture set Pic in step i i Sum of similarity { sim 1 ,sim 2 ,sim 3 ,…,sim L Minimum front Num in spe The character pictures form a picture set spe, and the front Num with the maximum sum of the similarity gen Composing picture set gen by character pictures, merging picture set spe and gen into Temp i ,Temp i Is the final template library for the ith character. And T finally obtained in the last step i I.e. the best threshold for template matching for the ith character.
b) Obtaining the position of the nut on the car door limiter according to the step 3), and obtaining the approximate position of the characters on the surface of the car door limiter according to the position relation between the nut on the car door limiter and the characters, so that the region where the characters are located can be intercepted.
c) Calculating a gradient map of the character region picture, and extracting edge information by using a dual-threshold method, wherein the process is as follows:
calculating the gradient of the character region picture by using a Sobel operator to obtain the gradient value and the direction of each pixel point on the picture, and setting two threshold values theta 1 And theta 2 For gradient values less than θ 1 The gradient value of the pixel points is set to be zero when the pixel points are not character edge pixel points, and the gradient value is larger than theta 2 The pixel points of (1) are considered as edge pixel points, the gradient values of the pixel points are reserved, and the gradient values are between theta 1 And theta 2 If the gradient value of the surrounding 80 connected region is larger than theta 1 The number of the pixel points exceeds 24, namely the gradient value around the corresponding point is larger than theta 1 The density of the pixel point is more than 0.3, the pixel point is considered as an edge pixel point, the gradient value of the pixel point is kept unchanged, otherwise, the gradient value is also set to be zero, and the threshold value theta is set to be zero 1 、θ 2 The calculation method of (2) is as follows:
i. at initial state θ 1 =50、θ 2 200, can also be changed according to specific situations;
ii, after extracting the edge information by using the double threshold method, calculating the number n of edge pixel pointsumofpixel, assuming that the total number of pixels of the character area picture is S, the density of edge pixel points in the picture after extracting the edge information is SIf rho is less than 0.03, the gradient value of partial edge pixel point is set to zero, so that theta should be correspondingly reduced 2 If rho is more than 0.1, part of non-edge pixel points are identified as edge pixel points, so that theta should be correspondingly increased 2 ;
The last step is iterated until rho is more than or equal to 0.03 and less than or equal to 0.1, and theta is at the moment 1 And theta 2 Is the final theta 1 And theta 2 。
d) As shown in fig. 3, assuming that the number of characters on the car door checker to be tested is numofcha, and the characters on all car door checkers have numofkin types, extracting edges from the template library of the numofkin types of characters obtained in step a) by using the method in step c), then performing improved template matching with the character area gradient map obtained in step c), and selecting the most appropriate numofcha character in the template library matching result as the identification result of the car door checker model to be tested, the specific process is as follows:
i. supposing that there are several possibilities for the first character of the car door stopper to be tested, we respectively match the gradient maps of several possible character template libraries with the gradient map of the character area of the car door stopper to be tested, when the ith template map is matched with the picture to be tested, because the picture to be tested must be larger than the template map in size, the template map is used to continuously slide the window with step length 1 on the picture to be tested for matching, when the jth window is used, the first r edge pixel points of the template and the pixel points at the corresponding positions on the picture to be tested are correspondingly calculated to obtain the similarity value of the corresponding template at the position of the picture to be tested, and the calculation formula is as follows:
whereinWhen the ith template is represented on the jth window of the picture to be detected, the similarity value obtained by corresponding calculation of the first r edge pixel points of the template and the pixel points at the corresponding positions on the picture to be detected is used,is the size of the transverse gradient value of the mth edge pixel point of the ith template,is the longitudinal gradient value Px of the mth edge pixel point of the ith template m Is the transverse gradient value Py of the pixel point at the corresponding position on the picture to be measured m The vertical gradient value of the pixel point at the corresponding position on the picture to be detected is obtained;
r starting iteration from 1, if the ith template picture obtains the similarity values of the first r edge pixel points on the jth window of the picture to be detectedIf a certain condition is satisfied, r is r +1, and the calculation is continuedOtherwise, the position is abandoned, the position is considered not to be the correct corresponding character area, the ith template picture slides to the j +1 th window of the picture to be measured, and the calculation is continued from the point that r is 1 The conditions to be satisfied are as follows:
wherein T is the optimal threshold value obtained when the template library is manufactured in the step a),initializing the minimum confidence coefficient of the character represented by the ith window of the picture to be detected, namely the ith template, to be T, namelyRear faceAnd (3) continuously iterating and generating through a formula (6), wherein Numofpix is the total number of the edge pixels of the ith template, rmax is the total number of the edge pixels of the template actually added to the last matching window of the last matching window or the last matching window of the last template, and jmax is the serial number of the last matching window of the last template.
And iii, for the first character, obtaining a final matching similarity for each possible character template library, taking the maximum value of the similarities, if the maximum value is greater than T, taking the maximum value as the recognition result of the character, otherwise, considering that no matching result exists, and processing each character on the car door limiter so as to obtain the recognition results of all characters on the car door limiter.
Through the steps, operations such as character positioning and edge extraction on the car door limiter are completed, and the characteristics such as characters used for distinguishing model types on the car door limiter can be efficiently identified, so that the aim of detecting the car door limiter is fulfilled.
It should be noted that, in the following description,the corresponding satisfied conditions are demonstrated as follows: equation (5) demonstrates that:
the parameters are represented as follows:
numofphix: the total number of the edge pixels of the ith template;
the similarity of r edge pixel points in front of the template and pixel points at corresponding positions on the jth window of the picture to be detected;
the similarity of all edge pixel points of the template and pixel points at corresponding positions on the jth window of the picture to be detected is large;
similarity between Numofpix-r marginal pixel points of the template except the first r pixel points and corresponding pixel points on the jth window of the picture to be detected;
the jth window of the picture to be detected is the minimum confidence coefficient of the character represented by the ith template, namely if all edge pixel points of the ith template participate in matching, the minimum confidence coefficient should beOtherwise, the jth window is definitely not the correct character;
1) consider first the case of r < Numofpix:
And because Numofpix-r > 0,
2) then consider the case where r ═ numofoix:
And (5) finishing the certification.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.
Claims (6)
1. A car door limiter detection method based on Adaboost and template matching is characterized by comprising the following steps:
s1, collecting a picture of the vehicle door limiter to be detected, and identifying and positioning nuts in the collected picture of the vehicle door limiter by using an Adaboost classifier;
step S2, according to the recognition result of the nuts in the car door limiter picture obtained in the step S1, and in combination with the position relation between the nuts on the car door limiter and the characters on the car door limiter in the standard database, carrying out coarse positioning on the character area on the car door limiter to be detected;
s3, making an optimal template library of the characters on the car door limiter by using a double iteration method, and simultaneously obtaining an optimal threshold value of the characters on the car door limiter matched with the template;
step S4, after the step S3 is completed, extracting the picture of the vehicle door limiter to be detected and the edge characteristics of the character template used in the optimal template library, identifying the characters in the picture of the vehicle door limiter to be detected by using a rapid template matching method, and completing the detection and identification of the vehicle door limiter to be detected;
in step S3, the method for calculating the optimal template library of the characters on the door check and the optimal threshold of the template matching characters by using the double iteration method specifically includes the following steps:
s3.1, obtaining L pictures of the ith character picture to form a picture set Pic i For each picture, a template matching method is utilized to match the picture set Pic i The other pictures are matched one by one, and the obtained L-1 similarity is added to obtain the sum of the similarities, namely the sum { sim ] of the L similarities is obtained 1 ,sim 2 ,sim 3 ,…,sim L };
Step S3.2, get stepS3.1 { sim 1 ,sim 2 ,sim 3 ,…,sim L The front Num with the smallest sum of similarity spe Each picture forms a picture set spe, and the front Num with the maximum sum of similarity gen The pictures form a picture set gen, and the picture set spe and gen are combined into an initial template library Temp of the corresponding type of car door stop i ;
Step S3.3, respectively using the initial template library Temp obtained in the step S3.2 i All templates and picture sets Pic in i Each picture in (1) is matched with a template due to Temp i Among them is Num gen +Num spe A template, therefore Pic i Each picture in the picture can obtain Num gen +Num spe Taking the maximum value of the similarity value as a template library Temp i And picture set Pic i The similarity confidence of the picture, then Pic i L similar credibility can be obtained from the middle L pictures to form a credibility setThis confidence level represents Pic i The character on the middle L pictures is the credibility of the ith character;
step S3.4, obtaining a template library Temp of characters on the stoppers of other vehicle types by using the methods of the step S3.1 and the step S3.2 j Will Temp j Instead of Temp in said step S3.3 i Method and picture set Pic according to step S3.3 i All pictures in the picture list are matched by templates to obtain a picture set Pic i Each character picture in (1) is a reliability set of the jth character
Step S3.5, if the template library Temp of the step S3.2 i And Temp j Can collect Pic i Is recognized as the correct character type, i.e. the ith character, then the reliability setIs greater than the setSet the picture set Pic as the maximum value of i Match error rate of Wherein NumWrong i For a picture set Pic i The number of pictures in the text that are identified as non-ith characters, i.e. the confidence level setLess than the matching threshold T of the template i Number of elements (NumWrong) j For character picture set Pic i The number of pictures identified as the jth character in the text, i.e., the confidence level setGreater than the matching threshold T of the template i The number of elements of (2) to obtain the best template library Temp i Is to find the optimum threshold value T i And the optimum Num gen 、Num spe So that the matching error rate W i A minimal process;
step S3.6, firstly fixing Num in step S3.5 gen 、Num spe To find the threshold value T i Make template library Temp i Match error rate ofMinimum, finally by the threshold value T obtained i The middle point of the section is used as the optimal threshold value, and after the optimal threshold value is obtained, if the template library Temp is at the moment i Matching error rate W of i Is equal to zero or less than 0.0001, then Num gen 、Num spe If the template library is optimal, the template library is manufactured, and the optimal threshold value T is i Has also been found, otherwise is fixedFixed threshold value T i If the reliability is setIs less than the optimum threshold value T i If the reliability number of (2) is more than 0.2 x L, the generality of the template is not sufficient, and Num is increased gen Then continuously calculating the matching error rate W i If the reliability is setIs less than the optimum threshold value T i If the reliability number of (2) is less than 0.02 x L, the template specificity is not sufficient, and Num is increased spe Then continuously calculating the matching error rate W i If the matching error rate W is the same as the previous matching error rate i Is equal to zero or less than 0.0001, then Num gen 、Num spe If the template library is optimal, the template library is manufactured, and the optimal threshold value T is i Also found, otherwise repeat this step until W i Equal to zero or less than 0.0001;
step S3.7, the final Num obtained according to the step S3.6 gen 、Num spe For the ith character picture set Pic in step S3.1 i Sum of similarity { sim 1 ,sim 2 ,sim 3 ,…,sim L Minimum front Num in spe The character pictures form a picture set spe, and the front Num with the maximum sum of the similarity gen Composing picture set gen by character pictures, merging picture set spe and gen into Temp i ,Temp i I.e. the template library of the i-th character finally formed, and the T finally obtained in said step S3.6 i The optimal threshold value for template matching of the ith character is obtained;
wherein j ≠ i and j ≠ 1, 2, 3, …;
the step S4 specifically includes the following steps:
s4.1, obtaining the position of the nut on the car door limiter according to the step S3, obtaining the position of the character on the car door limiter according to the position relation between the nut on the car door limiter and the character, and intercepting the area where the character is located;
s4.2, calculating a gradient map of the character region picture, and extracting edge information by using a dual-threshold method;
and S4.3, setting the number of the characters on the vehicle door limiter to be tested to be numofcha, wherein the character types on all the vehicle door limiters are numofkind, extracting edges of the template library of the numofkind characters obtained in the step S3 by using the method in the step S4.2, then respectively performing template matching with the character regional gradient map obtained in the step S4.2, and selecting the most suitable numofcha character in the template library matching results as the identification result of the model of the vehicle door limiter to be tested.
2. The method for detecting the car door stop based on the Adaboost and the template matching as claimed in claim 1, wherein in the step S1, the preparation process of the Adaboost classifier comprises the steps of firstly preparing positive and negative samples required by training, wherein the number ratio of the positive and negative samples is 1:2-1:4, the positive sample is a picture of the front surface of the nut on the car door stop to be tested, the negative sample is composed of a picture of the back surface of the nut on the car door stop to be tested, a picture which does not take the nut in the production process and a picture which only takes part of the nut, and a vector description file of the positive and negative samples required by training is created; and training a plurality of weak classifiers by using local binary pattern characteristics through an OpenCV open source library, and forming the Adaboost classifier.
3. The vehicle door limiter detection method based on Adaboost and template matching as claimed in claim 2, wherein a vector description file for training positive and negative samples is created, and the specific steps are as follows:
the training samples are divided into positive samples and negative samples, the number ratio of the positive samples to the negative samples is 1:2-1:4 in the training process, the negative samples are composed of two parts, namely a nut reverse side picture of the vehicle door check device to be tested, a picture of a nut which is not shot in the production process and a picture of only shooting a part of the nut, corresponding characteristic pictures on other types of vehicle door check devices and possible error pictures in the production process are guaranteed to be 2:1-4:1, formats of all the pictures are converted into bmp formats, and the pictures of all the positive samples are sized to be 65 pixels long and 65 pixels wide.
4. The method for detecting the car door stop based on Adaboost and template matching as claimed in claim 1, wherein the specific process of the step S4.2 is as follows:
calculating the gradient of the character region picture by using a Sobel operator to obtain the gradient value and the direction of each pixel point on the character region picture, and setting two threshold values theta 1 And theta 2 Making the gradient value less than theta 1 Setting the gradient value of the pixel point to be zero, and enabling the gradient value to be larger than theta 2 The gradient value of the pixel point is reserved, when the gradient value is between theta 1 And theta 2 The gradient value existing in the peripheral 80 connected region of the pixel point is larger than theta 1 The number of the pixel points exceeds 24, namely the gradient value around the corresponding point is larger than theta 1 If the density of the pixel points is more than 0.3, the gradient value is reserved, otherwise, the gradient value is set to be zero.
5. The vehicle door limiter detection method based on Adaboost and template matching according to claim 1, wherein the step S4.3 is implemented by the following specific processes:
setting a plurality of possibilities for a first character of a car door stopper to be detected, respectively matching gradient graphs of a plurality of character template libraries with gradient graphs of character areas of the car door stopper to be detected as templates, matching an ith template graph with a picture to be detected by continuously sliding a window with a step length of 1 on the picture to be detected by using the template graphs, and correspondingly calculating front r edge pixel points of the template and pixel points of corresponding positions on the picture to be detected to obtain the similarity value of the corresponding template on the picture to be detected in a jth window, wherein the calculation formula is that
WhereinWhen the ith template is represented on the jth window of the picture to be detected, the similarity value obtained by corresponding calculation of the first r edge pixel points of the template and the pixel points at the corresponding positions on the picture to be detected is used,is the size of the transverse gradient value of the mth edge pixel point of the ith template,is the longitudinal gradient value Px of the mth edge pixel point of the ith template m Is the transverse gradient value Py of the pixel point at the corresponding position on the picture to be measured m The vertical gradient value of the pixel point at the corresponding position on the picture to be detected is obtained; r starts iteration from 1, if the ith template picture obtains the similarity value of the first r edge pixel points on the jth window of the picture to be testedIf a predetermined condition is satisfied, r is r +1, and the calculation is continuedOtherwise, abandoning the position to be measured, sliding the ith template picture to the j +1 th window of the picture to be measured, and continuously calculating from r to 1The predetermined condition is required to be satisfied as
Where T is the optimal threshold for the template matching obtained in step S3,initializing the minimum confidence coefficient of the character represented by the ith window of the picture to be detected, namely the ith template, to be T, namely Continuously iterating to generate Numofpix, wherein Numofpix is the total number of the edge pixels of the ith template, rmax is the total number of the edge pixels of the template actually added and matched in the last matching window of the last template or the last matching window of the last template, and jmax is the serial number of the last matching window of the last template; and for the first character, obtaining a final matching similarity for each possible character template library, taking the maximum value of the similarities, taking the maximum value as the recognition result of the character if the maximum value is greater than T, otherwise, considering that no matching result exists, and processing each character on the car door limiter one by one so as to obtain the recognition results of all characters on the car door limiter.
6. The method for detecting the vehicle door stop based on Adaboost and template matching as claimed in claim 4, wherein the threshold value theta is 1 、θ 2 Is calculated by theta at the initial state 1 =50、θ 2 After extracting edge information by using the dual threshold method, calculating the number numofoixel of edge pixels, assuming that the total number of pixels of the character region picture is S, the density of the edge pixels in the picture after extracting the edge information is 200If rho is less than 0.03, the gradient value of partial edge pixel points is set to zero, and theta is correspondingly reduced 2 If rho is more than 0.1, part of non-edge pixel points are identified as edge pixel points, so that theta is correspondingly increased 2 Until rho is more than or equal to 0.03 and less than or equal to 0.1, the theta is 1 And theta 2 Is the final theta 1 And theta 2 。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910027016.4A CN109886265B (en) | 2019-01-11 | 2019-01-11 | Vehicle door limiter detection method based on Adaboost and template matching |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910027016.4A CN109886265B (en) | 2019-01-11 | 2019-01-11 | Vehicle door limiter detection method based on Adaboost and template matching |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109886265A CN109886265A (en) | 2019-06-14 |
CN109886265B true CN109886265B (en) | 2022-08-16 |
Family
ID=66925787
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910027016.4A Active CN109886265B (en) | 2019-01-11 | 2019-01-11 | Vehicle door limiter detection method based on Adaboost and template matching |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109886265B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112818983B (en) * | 2021-01-22 | 2024-08-02 | 常州友志自动化科技有限公司 | Method for judging character inversion by using picture acquaintance |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103870803A (en) * | 2013-10-21 | 2014-06-18 | 北京邮电大学 | Vehicle license plate recognition method and system based on coarse positioning and fine positioning fusion |
CN108615034A (en) * | 2017-12-14 | 2018-10-02 | 燕山大学 | A kind of licence plate recognition method that template matches are combined with neural network algorithm |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2006075594A1 (en) * | 2005-01-11 | 2006-07-20 | Nec Corporation | Template matching method and device, and recording medium where program therefor is recorded |
-
2019
- 2019-01-11 CN CN201910027016.4A patent/CN109886265B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103870803A (en) * | 2013-10-21 | 2014-06-18 | 北京邮电大学 | Vehicle license plate recognition method and system based on coarse positioning and fine positioning fusion |
CN108615034A (en) * | 2017-12-14 | 2018-10-02 | 燕山大学 | A kind of licence plate recognition method that template matches are combined with neural network algorithm |
Also Published As
Publication number | Publication date |
---|---|
CN109886265A (en) | 2019-06-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111401257B (en) | Face recognition method based on cosine loss under non-constraint condition | |
CN105046196B (en) | Front truck information of vehicles structuring output method based on concatenated convolutional neutral net | |
CN101350069B (en) | Computer implemented method for constructing classifier from training data and detecting moving objects in test data using classifier | |
TWI381321B (en) | Method for image recombination of multiple images and identifying image and system for identifying image and outputting identification result | |
Alvarez et al. | Road scene segmentation from a single image | |
CN109101924B (en) | Machine learning-based road traffic sign identification method | |
TWI384408B (en) | Method and system for identifying image and outputting identification result | |
CN110008909B (en) | Real-name system business real-time auditing system based on AI | |
Zhou et al. | Robust vehicle detection in aerial images using bag-of-words and orientation aware scanning | |
US7929728B2 (en) | Method and apparatus for tracking a movable object | |
US10445602B2 (en) | Apparatus and method for recognizing traffic signs | |
CN107316031A (en) | The image characteristic extracting method recognized again for pedestrian | |
TW201926140A (en) | Method, electronic device and non-transitory computer readable storage medium for image annotation | |
CN103824091B (en) | A kind of licence plate recognition method for intelligent transportation system | |
US20110227923A1 (en) | Image synthesis method | |
US11568629B2 (en) | System and method for finding and classifying patterns in an image with a vision system | |
CN105447532A (en) | Identity authentication method and device | |
CN104021375A (en) | Model identification method based on machine learning | |
Ji et al. | Integrating visual selective attention model with HOG features for traffic light detection and recognition | |
WO2013075295A1 (en) | Clothing identification method and system for low-resolution video | |
CN115830359A (en) | Workpiece identification and counting method based on target detection and template matching in complex scene | |
CN109886265B (en) | Vehicle door limiter detection method based on Adaboost and template matching | |
US20120257819A1 (en) | Vision-Based Object Detection by Part-Based Feature Synthesis | |
CN113139946A (en) | Shirt stain positioning device based on vision | |
CN104517300A (en) | Vision judgment tracking method based on statistical characteristic |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |