CN114299502B - Method for correcting and identifying inclination of code-spraying characters on end face of round casting blank and storage medium - Google Patents

Method for correcting and identifying inclination of code-spraying characters on end face of round casting blank and storage medium Download PDF

Info

Publication number
CN114299502B
CN114299502B CN202210213702.2A CN202210213702A CN114299502B CN 114299502 B CN114299502 B CN 114299502B CN 202210213702 A CN202210213702 A CN 202210213702A CN 114299502 B CN114299502 B CN 114299502B
Authority
CN
China
Prior art keywords
image
character
characters
round
gradient
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
Application number
CN202210213702.2A
Other languages
Chinese (zh)
Other versions
CN114299502A (en
Inventor
王筱圃
岳晨
钟智敏
张歌
朱立民
张道亮
刘伟
陈波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hkust Intelligent Internet Of Things Technology Co ltd
Original Assignee
Hkust Intelligent Internet Of Things Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Hkust Intelligent Internet Of Things Technology Co ltd filed Critical Hkust Intelligent Internet Of Things Technology Co ltd
Priority to CN202210213702.2A priority Critical patent/CN114299502B/en
Publication of CN114299502A publication Critical patent/CN114299502A/en
Application granted granted Critical
Publication of CN114299502B publication Critical patent/CN114299502B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Analysis (AREA)
  • Character Discrimination (AREA)
  • Character Input (AREA)

Abstract

The invention relates to a method for correcting and identifying the inclination of code-spraying characters on the end surface of a round casting blank and a storage medium, wherein the method comprises the following steps of positioning an effective area of a round outline; the minimum circumscribed rectangle of each character outline is obtained; solving the character inclination angle; post-processing the character correction result; and identifying the code spraying characters. The method adopts an improved contour gradient template matching algorithm, can accurately position the effective area of the end face contour of the round billet, combines the prior condition information of the row and column distribution characteristics of the code-spraying characters, and adopts a short-side slope mean value method of the circumscribed rectangle and a slope arrangement combination voting method of the connecting line of the central points of the minimum circumscribed rectangles of any two contours to finish the slope correction of the characters; and identifying the characters by taking a model fused by ResNet-18 and inclusion structural paradigms as a classifier. The method for positioning the effective area of the round casting blank and the method for correcting the character inclination can be well suitable for detection in a static or moving state, have strong robustness and can be multiplexed on a square blank.

Description

Method for correcting and identifying inclination of code-spraying characters on end face of round casting blank and storage medium
Technical Field
The invention relates to the technical field of industrial visual character recognition, in particular to a method for correcting and recognizing the inclination of code-spraying characters on the end face of a round casting blank and a storage medium.
Background
At present, in the steel pipe production process of the pipe processing industry, the mode of PLC and manual participation is basically adopted for steel pipe tracking, tracking according to furnace numbers or batch numbers is realized, the tracking is realized less for the tracking of the whole process one by one, the steel pipe production is a discrete and discontinuous processing mode, the phenomena of off-line and rework of unqualified products in the production process are inevitable, the recording is generally input into a computer through manual work, the tracking of the product process quality is realized according to the furnace or batch, and the raw materials and the specific process parameters in the processing process cannot be tracked for a certain steel pipe. The round casting blank is used as a raw material for pipe processing, how to obtain information such as a raw material production place, production time, materials, batch numbers and the like before an upper processing production line is mostly in a form of end face code spraying characters, casting blank information is manually input through visual observation and verification, the automation degree is low, and great manpower is consumed. Therefore, a system and a method capable of automatically acquiring code-sprayed characters on the end face of a casting blank are urgently needed, and the code-sprayed characters can be quickly and efficiently identified.
Disclosure of Invention
The method for correcting and identifying the inclination of the code-sprayed characters on the end surface of the round casting blank can quickly and efficiently finish the inclination correction and identification of the code-sprayed characters on the end surface of the round blank.
In order to achieve the purpose, the invention adopts the following technical scheme:
a method for correcting and identifying the inclination of code-sprayed characters on the end surface of a round casting blank comprises the following steps,
s1, acquiring a circular casting blank end face image, and processing the circular casting blank end face image by adopting an improved contour gradient template matching algorithm to obtain an effective area surrounded by a circular contour;
s2, extracting the outline of the character connected domain after preprocessing the image of the effective area surrounded by the circular outline, and solving the minimum circumscribed rectangle of each character outline;
s3, solving the character inclination angle by adopting a slope average method of the short sides of the external rectangles or a slope arrangement combination voting method of the central connecting line of any two external rectangles to obtain a corrected image;
s4, combining the prior condition information of character row-column distribution, post-processing the correction result to obtain a plurality of single character correction images;
s5, constructing a ResNet-inclusion model fusion classifier by fusing ResNet-18 and inclusion structure normal forms, identifying the single character correction images by using the trained fusion classifier, and summarizing identification results to obtain character identification results;
the improved contour gradient template matching algorithm described in step S1 specifically includes:
s1.1, assuming that the size of the outline radius of the round billet in the collected round billet end surface image accounts for pixels (C)rmin,Crmax) In which C isrmin、CrmaxThe end face image of the round casting blank is constant according to a proportionality coefficient S of 2KZooming, wherein K is a positive integer and takes the value of 3;
s1.2, setting the reference radius of the circular template as
Figure GDA0003615543290000021
The size of the reference circle template image is set to (2C)mr+5.2Cmr+5) and the center coordinates are set to (C)mr+2,Cmr+2), the color of the pixel inside the circular contour of the reference circular template image is set to 0, and the color of the pixel outside the contour is set to 1; the upper and lower deviations of the round template are set as
Figure GDA0003615543290000022
Wherein C ismrRounding off to get an integer ErRounded upwards, thus setting a circleNumber of template images is Nm=2Er+1, radius of the circular template is (C)mr-Er)~(Cmr+Er) Change in between;
s1.3, sequentially aligning the set N by using sobel operatormHorizontal gradient image G is obtained from round template imagemdxAnd vertical gradient image Gmdy(ii) a Similarly, a sobel operator is adopted to obtain a horizontal gradient image G of the zoomed round casting blank end surface imagedxAnd vertical gradient image GdyAt the same time, to GdxAnd GdyThe image is post-processed by
Figure GDA0003615543290000023
Setting the horizontal and vertical gradients of the pixel points to be 0, wherein sigma is a constant, sigma is a value between (0, 1), G is a matrix, and G of all templates and images is subjected to normalization processing;
s1.4, traversing and matching the zoomed circular casting blank end face image by using an image of a certain circular template to obtain a gradient matching image, which specifically comprises the following steps:
s1.4.1 calculation of gradient matching value of single-point pixel, assuming that the horizontal gradient of a certain pixel point on the edge contour of the circular template is Gmdx(i, j) vertical gradient Gmdy(i, j), and the horizontal gradient G of a certain pixel point of the corresponding zoomed round casting blank end surface imagedx(i + m, j + n) with a vertical gradient Gdy(i + M, j + n), the single-point pixel gradient matching value is Mdxy=Gdx(i+m,j+n)×Gmdx(i,j)+Gdy(i+m,j+n)×Gmdy(i, j), wherein m, n is the value of traversing all ranges;
s1.4.2 calculating gradient matching value of the round template, down-sampling the round template profile, setting the down-sampling coefficient to 2, namely taking one pixel at every other pixel point, traversing the down-sampled round template profile points, and obtaining gradient matching value M of all pixels of the scaled round casting blank end face image corresponding to the pointsdxyAccumulating all gradient matching values Mdxy, and dividing the accumulated result by the number of points of the outline of the circular template to obtain a gradient matching value so as to complete the gradient matching of the circular template for one time; setting the matching step size to1, calculating the gradient matching value of the circular template of the whole image by traversing the zoomed circular casting blank end face image, thereby obtaining a complete gradient matching image;
s1.5, adding NmRepeating the calculation of step S1.4 for each circular template image to obtain NmA gradient matching map, searching for NmAnd comparing the maximum value which is the brightest point in the gradient matching image with the set brightest point threshold value, so as to obtain the corresponding center coordinate and the radius of the circular template, and completing the positioning of the circular effective area.
Further, the method for calculating the slope average of the short side of the circumscribed rectangle in step S3 specifically includes:
s3.1, assuming that the number of minimum outline bounding rectangles is NcRemoving two profiles with minimum and maximum values of the inclination angle of the short side of the circumscribed rectangle, wherein θiIn order to remove the i-th minimum outline short edge inclination angle after the maximum value and the minimum value of the inclination angle, the inclination angle of the code-sprayed character is
Figure GDA0003615543290000031
Further, the method for voting by arranging and combining slopes of connecting lines between any two external rectangles in step S3 to obtain the tilt angle of the character specifically includes:
s3.2, according to the prior condition information of the character row-column distribution characteristics, assuming that M rows of characters exist, wherein AiThe number of the ith row of characters is, the number of any two character permutation and combination in the single row of characters is
Figure GDA0003615543290000032
The total number of any two character permutation and combination of all the single-line characters is
Figure GDA0003615543290000033
Assuming that the number of minimum bounding rectangles of the obtained outline is Nc,θ(i,j)Is the inclination angle of the connecting line of the minimum external rectangle central points of any two outlines, wherein i is not equal to j, i belongs to [1, N ]c],j∈[1,Nc],θ(i,j)E is [0, 180 degrees ], the total number of permutation and combination of the connecting lines of the central points of the minimum external rectangles of any two outlines is
Figure GDA0003615543290000034
The total number of any two character permutation and combination of all the single-line characters is as follows
Figure GDA0003615543290000035
By looking for theta(i,j)Theta with total ratio of P in a range of a certain cell in which the values of the middle inclination angle are concentrated(i,j)The inclination angles are integrated to obtain theta with the ratio of P(i,j)And taking the average value of the elements in the inclination angle set as the inclination angle of the code-sprayed character.
Further, the post-processing of the character correction result in step S4 specifically includes: sorting all corrected single characters according to the central coordinate position of the circumscribed rectangle to obtain the quantity information of each row of characters, comparing the quantity information with the prior condition information of the character row-column distribution, namely the quantity characteristics, and if the quantity information is matched with the prior condition information of the characters, the correction result of the step S3 is the final correction result; if not, a 180 degree rotation is required as the final correction result.
Further, the ResNet-inclusion model fusion classifier described in step S5 uses ResNet-18 as a main feature extraction network, fuses the inclusion module, adjusts the 7 × 7 convolution kernel of the 1 st convolution module of ResNet-18 into two 5 × 5 convolution kernels, the 2 nd convolution module includes 2 residual structures, the residual structures are composed of 64 number of 3x3+3x3 convolution kernels, the 2 th convolution module fuses the 2 residual structures by concat connection, the 4 th convolution module includes 2 residual structures, the residual structures are composed of 256 number of 3x3+3x3 convolution kernels, the 2 residual structures are fused by concat connection, the 3 × 3+3 × 3 convolution kernels of the 3 rd convolution module and the 5 th convolution module are adjusted into 1 × 1+3 × 3+1 × 1 convolution kernel, and fuses the split-transform-filter structure paradigm, and finally, the full-dimensional connection layer is changed into 64-dimensional output, and the regularization method DropBlock is used in the 2 nd convolution module.
Further, in step S2, only the pixels in the area surrounded by the circle contour are preprocessed, and the pixels outside the circle contour are not processed as invalid pixels.
In another aspect, the present invention also discloses a computer readable storage medium storing a computer program, which when executed by a processor causes the processor to perform the steps of the method as described above.
According to the technical scheme, the method for correcting and identifying the inclination of the code-sprayed characters on the end face of the round casting blank and the storage medium have the advantages that most of the end faces of the round casting blank are non-perfect round profiles, Hough transform is adopted and is difficult to adapt to the detection condition, and an improved profile gradient template matching algorithm is adopted, so that the effective area of the end face of the round blank can be accurately positioned. By combining the prior condition information of the row and column distribution characteristics of the code-spraying characters, the inclination angle of the code-spraying characters in the end face image of the round casting blank can be accurately calculated by adopting a short-edge slope average method of the circumscribed rectangle and a random minimum circumscribed rectangle central point connecting slope arrangement combination voting method. Meanwhile, a model with a combined ResNet-18 and inclusion structure paradigm is used as a classifier, and corrected single characters can be accurately and efficiently recognized. The round casting blank effective area positioning method and the character inclination correction method can be well suitable for detection in a static or moving state, have strong robustness and can be multiplexed on a square blank.
Drawings
FIG. 1 is a schematic flow diagram of an embodiment of the present invention;
FIG. 2a is an image acquisition scheme diagram of a round casting blank transmission mode according to an embodiment of the invention; FIG. 2b is a schematic diagram of an image acquisition scheme of a round casting blank rolling mode according to an embodiment of the invention;
FIG. 3a is an end view of a round billet according to an embodiment of the present invention; FIG. 3b is a diagram illustrating the effect of contour alignment according to an embodiment of the present invention;
FIG. 4a is a diagram illustrating the pre-processing result of the effective area image according to the embodiment of the present invention; FIG. 4b is a diagram of the effective area image post-processing results of an embodiment of the present invention;
FIG. 5a is a diagram illustrating the effect of the inkjet printing of 30 degree inclination according to the embodiment of the present invention;
FIG. 5b is a diagram illustrating the effect of the inkjet inclination of 210 degrees according to the embodiment of the present invention;
FIG. 6a is a block diagram of a model fusion classifier according to an embodiment of the present invention;
fig. 6b, fig. 6c, fig. 6d, fig. 6e are respectively a schematic structural diagram of stem1, stem2, stem3, stem4 modules;
FIG. 7a is a diagram illustrating the effect of correcting the end surface inclination of a round billet according to the embodiment of the present invention; fig. 7b is a diagram of a result of code-spraying identification according to the embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention.
As shown in fig. 1, the method for correcting and identifying the inclination of code-sprayed characters on the end surface of a round casting blank in this embodiment includes the following steps,
s1, acquiring an end face image of the round casting blank, and processing the end face image of the round casting blank by adopting an improved contour gradient template matching algorithm to obtain an effective area surrounded by a round contour;
s2, extracting the outline of the character connected domain after preprocessing the image of the effective area surrounded by the circular outline, and solving the minimum circumscribed rectangle of each character outline;
s3, solving the character inclination angle by adopting a slope average method of the short sides of the external rectangles or a slope arrangement combination voting method of the central connecting line of any two external rectangles to obtain a corrected image;
s4, combining the prior condition information of character row-column distribution, post-processing the correction result to obtain a plurality of single character correction images;
s5, fusing ResNet-18 and an inclusion structure paradigm to construct a ResNet-inclusion model fusion classifier, recognizing the single character correction image by using the trained fusion classifier, and summarizing classification results to obtain character recognition results;
the following are specifically described:
s1, acquiring an end face image of the round casting blank, and obtaining an effective area surrounded by a round contour by adopting an improved contour gradient template matching algorithm:
the round casting blank passes through the image acquisition device in a rolling or transmission mode, two motion modes on a production line are respectively shown in fig. 2a and fig. 2b, corresponding image acquisition schemes are designed, main hardware comprises an industrial camera, a lens, a bowl-shaped light source, a light source controller, a photoelectric sensor and the like, wherein the photoelectric sensor arranged below the acquisition device is connected with the industrial camera in a hard wiring mode, in-place signals are automatically acquired, the camera is triggered to acquire end face images of the round casting blank, and the image acquisition and detection under a static or motion state can be well adapted.
S1.1, assuming that the size of the outline radius of the round billet in the collected round billet end surface image accounts for pixels (C)rmin,Crmax) In which C isrmin、CrmaxThe end face image of the round casting blank is constant according to a proportionality coefficient S of 2KZooming, wherein K is a positive integer and takes the value of 3;
FIG. 3a is an end view of a round billet according to an embodiment of the present invention, wherein the radius of the round billet profile is between (500, 540), and the round billet profile is scaled by 8 times.
S1.2, setting the reference radius of the circular template as
Figure GDA0003615543290000061
The size of the reference circle template image is set to (2C)mr+5,2Cmr+5) with centre coordinates set to (C)mr+2,Cmr+2), the color of the pixel inside the circular contour of the reference circular template image is set to 0, and the color of the pixel outside the contour is set to 1; the upper and lower deviations of the round template are set as
Figure GDA0003615543290000062
Wherein C ismrRounding off to get an integer ErRounding up, therefore, the number of the circular template images is set to Nm=2Er+1, radius of the circular template is (C)mr-Er)~(Cmr+Er) To change in between;
according to the relevant setting of the step S1.1, the reference radius of the circular template is 65, the size of the reference template image is (135 ), the center coordinates of the circle are set (67, 67), the vertical deviation of the circular template is set to be 3, the number of the circular template images is 7, and the radius of the circular template is changed between 62 and 68.
S1.3, sequentially aligning the set N by using sobel operatormHorizontal gradient image G is obtained from round template imagemdxAnd vertical gradient image Gmdy(ii) a Similarly, a sobel operator is adopted to obtain a horizontal gradient image G of the zoomed round casting blank end surface imagedxAnd vertical gradient image GdyAt the same time, to GdxAnd GdyThe image is post-processed by
Figure GDA0003615543290000063
Setting the horizontal and vertical gradients of the pixel points to be 0, wherein sigma is a constant, sigma is a value between (0, 1), G is a matrix, and G of all templates and images is subjected to normalization processing;
according to the relevant settings of S1.1 and S1.2, sequentially solving horizontal gradient images and vertical gradient images of 7 circle template images by using a sobel operator; adopting a sobel operator to obtain a horizontal gradient image and a vertical gradient image of the end face image of the round casting blank after being zoomed by 8 times; and all the obtained gradient images are normalized.
S1.4, traversing, matching and zooming the round casting blank end face image of a certain round template image to obtain a gradient matching image, which specifically comprises the following steps: calculating the gradient matching value of the single-point pixel, and assuming that the horizontal gradient of a certain pixel point on the edge profile of the circular template is Gmdx(i, j) vertical gradient Gmdy(i, j), and the horizontal gradient G of a certain pixel point of the corresponding zoomed round casting blank end surface imagedx(i + m, j + n) with a vertical gradient Gdy(i + M, j + n), the single-point pixel gradient matching value is Mdxy=Gdx(i+m,j+n)×Gmdx(i,j)+Gdy(i+m,j+n)×Gmdy(i, j), wherein m, n is the value of traversing all ranges;
calculating the gradient matching value of the circular template, performing down-sampling on the outline of the circular template, setting the down-sampling coefficient to be 2, namely taking one pixel at every other pixel point, traversing the outline points of the circular template after down-sampling, and obtaining the gradient matching value M of all pixels of the end face image of the circular casting blank after being zoomed corresponding to the gradient matching value MdxyAccumulating and summing to obtain an average value so as to complete primary circular template gradient matching; setting the matching step length as 1, and completing the calculation of the gradient matching value of the circular template of the whole image by traversing the zoomed circular casting blank end face image so as to obtain a complete gradient matching image;
s1.5, adding NmRepeating the calculation of step S1.4 for each circular template image to obtain NmA gradient matching map is obtained by searching for NmAnd comparing the maximum value which is the brightest point in the gradient matching image with the set brightest point threshold value, so as to obtain the corresponding center coordinate and the radius of the circular template, and completing the positioning of the circular effective area.
The improved contour gradient template matching algorithm described in the above S1 can be multiplexed to the contour effective region location of the square billet by changing the reference circle template into the reference rectangle template.
FIG. 3b is a diagram of the contour positioning effect according to the embodiment of the present invention, which is calculated according to the above-mentioned processing method.
According to the obtained central coordinate and radius of the round billet, background information is removed, and only an image of an effective area in the outline of the round billet is captured, wherein the method specifically comprises the following steps: and keeping the pixel points in the profile of the round billet unchanged, and setting the pixel points in other areas to be 0.
S2, extracting the outline of the character connected domain after preprocessing the image of the effective area surrounded by the circular outline, and solving the minimum circumscribed rectangle of each character outline:
the following pretreatment methods may be employed: adopting Gaussian filtering to carry out smooth denoising on the image and eliminate certain noise interference; the method comprises the following steps of solving a segmentation threshold value of an effective area of the end face of a round billet by adopting a maximum inter-class variance method, carrying out binarization on an image, and specifically referring to the following settings by setting a plurality of convolution kernels with different sizes: when i is an odd number, the convolution kernel size S is 2k + i; when i is an even number, the convolution kernel size S is 2k-i +1, wherein S is 3, k is a constant value, and 2 is generally selected, and the binary image is subjected to open algorithm processing according to different set convolution kernels, so that isolated dots and burrs can be effectively removed.
And extracting the connected domain outline of the preprocessed image, solving the minimum circumscribed rectangle of all the outlines, and removing the obvious abnormal outline according to the area of the connected domain outline and the length and width information of the minimum circumscribed rectangle.
And finally, solving the minimum circumscribed rectangle of each character outline.
S3, solving the character inclination angle by adopting a method of averaging the slopes of the short sides of the external rectangles or adopting a method of arranging and combining the slopes of the central connecting lines of any two external rectangles to obtain a corrected image:
the inclination angle of the code spraying character is calculated by adopting the following two methods, namely: solving the character inclination angle by an external rectangle short edge slope average method; II, secondly: the slope arrangement and combination voting method for the connecting line of the centers of any two external rectangles.
S3.1, a character inclination angle calculation method I:
assuming that the number of minimum bounding rectangles of the obtained outline is NcRemoving two profiles with the minimum external rectangle short side inclination angle as the maximum value and the minimum value, wherein thetaiIn order to remove the i-th minimum outline short edge inclination angle after the maximum value and the minimum value of the inclination angle, the inclination angle of the code-sprayed character is
Figure GDA0003615543290000081
S3.2, a character inclination angle calculation method II:
according to the prior condition information of character row-column distribution characteristics, M rows of characters are assumed, wherein AiThe number of the ith row of characters is, the number of any two character permutation and combination in the single row of characters is
Figure GDA0003615543290000082
The total number of any two character permutation and combination of all the single-line characters is
Figure GDA0003615543290000083
Assuming that the number of minimum bounding rectangles of the obtained outline is Nc,θ(i,j)Is the inclination angle of the connecting line of the minimum external rectangle central points of any two outlines, wherein i is not equal to j, i belongs to [1, N ]c],j∈[1,Nc],θ(i,j)E is [0, 180 degrees ], the total number of permutation and combination of the connecting lines of the central points of the minimum external rectangles of any two outlines is
Figure GDA0003615543290000084
The total number of any two character permutation and combination of all the single-line characters is as follows
Figure GDA0003615543290000085
By looking for theta(i,j)Theta with total ratio of P in a range of a certain cell in which the values of the middle inclination angle are concentrated(i,j)The inclination angles are collected, and theta with the proportion of P is obtained(i,j)And taking the average value of the elements in the inclination angle set as the inclination angle of the code spraying character.
FIG. 4a is a diagram illustrating the pre-processing result of the effective area image according to the embodiment of the present invention; FIG. 4b is a graph of the result of the effective area image post-processing according to the embodiment of the present invention; according to the above calculation method, we obtain:
Figure GDA0003615543290000091
s4, carrying out post-processing on the correction result by combining the prior condition information of the row-column distribution of the characters to obtain a plurality of single-character correction images:
performing character inclination correction according to the character inclination angle obtained by calculation, and obtaining a corrected image; sorting all corrected single characters according to the central coordinate position of the circumscribed rectangle to obtain the quantity information of each row of characters, comparing the quantity information with the prior condition information of the character row-column distribution, namely the quantity characteristics, and if the quantity information is matched with the prior condition information of the characters, the correction result of the step S3 is the final correction result; if not, a 180 degree rotation is required as the final correction result.
As shown in fig. 5a and 5b, wherein fig. 5a is an effect diagram of the inkjet printing of the embodiment of the present invention being inclined by 30 degrees; FIG. 5b is a diagram illustrating the effect of the inkjet inclination of 210 degrees according to the embodiment of the present invention; according to the inclination angle obtained in step S3, the calculation results of the inclination angles of the characters in the two images should be the same, but actually the inclination angle of the right image needs to be turned over by 180 degrees to ensure the accuracy of character correction, so the character correction result needs to be verified with the prior condition information of the characters to ensure the accuracy of character correction when the inclination angle falls within the interval of [180 ° and 360 °.
S5, adopting a ResNet-inclusion model fusion classifier to recognize the single character correction image, and summarizing classification results to obtain character recognition results:
as shown in fig. 6a to 6e, the ResNet-inclusion model fusion classifier uses ResNet-18 as a trunk feature extraction network, fuses the inclusion module, adjusts the 7 × 7 convolution kernel of the 1 st convolution module of ResNet-18 into two 5 × 5 convolution kernels, the 2 nd convolution module includes a residual structure composed of 2 3 × 3+3 × 3 convolution kernels (the number of convolution kernels is 64), fuses the 2 residual structures by concat connection, the 4 th convolution module includes a residual structure composed of 2 3 × 3+3 × 3 convolution kernels (the number of convolution kernels is 256), fuses the 2 residual structures by concat connection, the 3 × 3+3 × 3 convolution kernels of the 3 rd convolution module and the 5 th convolution module are adjusted into 1 × 1+3 × 3+1 × 1 convolution kernel, fuses the split-transform-mer structure paradigm, and finally changes the full connection layer into 64-d output, and the regularization method DropBlock is used in the 2 nd convolution module.
Firstly, finishing inclination correction of code-sprayed characters on the end face of a round blank, storing the corrected single characters in an image form, establishing a single character sample database, wherein the database comprises common characters such as numbers, capital letters and lower case letters, and the like, and totally 64 categories, manually finishing classification of character data in the early stage, and after a certain amount of sample sets are collected, sending the character data into the model fusion classifier for training; in the later stage, newly acquired round casting blank end face image data can be identified by using a classifier trained in the earlier stage, the identified single character result is stored, the identification result is manually verified (wrongly divided characters need to be corrected), the verified identification result data is added to a single character sample database again, and iteration of a model fusion classifier is performed; the operation is repeated, model iteration is continuously carried out, and the detection effect of the character classifier is improved.
In summary, according to the method for correcting and identifying the inclination of the code-sprayed characters on the end face of the round casting blank, the corresponding image acquisition schemes are designed for 2 motion modes of the round casting blank on a production line, the photoelectric sensor can be directly connected with an industrial camera, the camera is automatically triggered to acquire images after the round blank is in place, and a PLC (programmable logic controller) is not required to acquire in-place signals. Most of the end surfaces of the round casting blanks are non-perfect round profiles, so that the Hough transform is difficult to adapt to the detection condition, and the effective areas of the end surfaces of the round blanks can be accurately positioned by adopting an improved profile gradient template matching algorithm. By combining the prior condition information of the row and column distribution characteristics of the code-spraying characters, the inclination angle of the code-spraying characters in the end face image of the round casting blank can be accurately calculated by adopting a short-edge slope average method of the circumscribed rectangle and a random minimum circumscribed rectangle central point connecting slope arrangement combination voting method. Meanwhile, a model with a fused ResNet-18 and inclusion structure paradigm is used as a classifier, corrected single characters can be accurately and efficiently recognized, as shown in FIGS. 7a and 7b, wherein FIG. 7a is a diagram of the effect of correcting the end face inclination of the round casting blank in the embodiment of the invention; fig. 7b is a diagram of a result of code spraying identification according to an embodiment of the present invention, and it can be seen that the method for positioning an effective area of a round casting blank and the method for correcting a character tilt according to the present invention can be well adapted to detection in a stationary or moving state, have strong robustness, and can also be multiplexed onto a square blank.
In yet another aspect, the present invention also discloses a computer readable storage medium storing a computer program, which when executed by a processor causes the processor to perform the steps of the method as described above.
In yet another aspect, the present invention also discloses a computer device comprising a memory and a processor, the memory storing a computer program which, when executed by the processor, causes the processor to perform the steps of the above method.
In another embodiment provided by the present application, there is also provided a computer program product containing instructions, which when run on a computer, causes the computer to execute any one of the above-mentioned methods for correcting and identifying the skew of the end-face code-sprayed characters of the round billet.
It is understood that the system provided by the embodiment of the present invention corresponds to the method provided by the embodiment of the present invention, and the explanation, the example and the beneficial effects of the related contents can refer to the corresponding parts in the method.
The embodiment of the application also provides an electronic device, which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus,
a memory for storing a computer program;
the processor is used for realizing the inclination correction and identification method of the code-sprayed characters on the end face of the round casting blank when executing the program stored in the memory;
the communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus may be divided into an address bus, a data bus, a control bus, etc.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM), or may include a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), or other Programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (7)

1. A method for correcting and identifying the inclination of code-sprayed characters on the end surface of a round casting blank is characterized by comprising the following steps of,
s1, acquiring an end face image of the round casting blank, and processing the end face image of the round casting blank by adopting an improved contour gradient template matching algorithm to obtain an effective area surrounded by a round contour;
s2, extracting the outline of the character connected domain after preprocessing the image of the effective area surrounded by the circular outline, and solving the minimum circumscribed rectangle of each character outline;
s3, solving the character inclination angle by adopting a slope average method of the short sides of the external rectangles or a slope arrangement combination voting method of the central connecting line of any two external rectangles to obtain a corrected image;
s4, combining the prior condition information of character row-column distribution, post-processing the correction result to obtain a plurality of single-character correction images;
s5, constructing a ResNet-inclusion model fusion classifier by fusing the ResNet-18 and the inclusion structure paradigm, identifying the single-character correction images by using the trained fusion classifier, and summarizing identification results to obtain character identification results;
the improved contour gradient template matching algorithm described in step S1 specifically includes:
s1.1, assuming that the size of the outline radius of the round billet in the collected round billet end surface image accounts for pixels (C)rmin,Crmax) In which C isrmin、CrmaxThe end face image of the round casting blank is constant according to a proportionality coefficient S of 2KZooming, wherein K is a positive integer and takes the value of 3;
s1.2, setting the reference radius of the circular template as
Figure FDA0003615543280000011
The size of the reference circle template image is set to (2C)mr+5,2Cmr+5) with centre coordinates set to (C)mr+2,Cmr+2), the color of the pixel inside the circular contour of the reference circular template image is set to 0, and the color of the pixel outside the contour is set to 1; the upper and lower deviation of the round template is set as
Figure FDA0003615543280000012
Wherein C ismrRounding off to get an integer ErRounding up, therefore, the number of the circular template images is set to Nm=2Er+1, radius of the circular template is (C)mr-Er)~(Cmr+Er) Change in between;
s1.3, adopting sobel operator to sequentially pair the set NmHorizontal gradient image G is obtained from round template imagemdxAnd vertical gradient image Gmdy(ii) a Similarly, a sobel operator is adopted to obtain a horizontal gradient image G of the zoomed round casting blank end surface imagedxAnd vertical gradient image GdyAt the same time, to GdxAnd GdyThe image is post-processed by
Figure FDA0003615543280000021
Setting the horizontal and vertical gradients of the pixel points to be 0, wherein sigma is a constant, sigma is a value between (0, 1), G is a matrix, and all templates and 6 of the images are subjected to normalization processing;
s1.4, traversing and matching the zoomed circular casting blank end face image by using an image of a certain circular template to obtain a gradient matching image, which specifically comprises the following steps: s1.4.1 calculation of gradient matching value of single-point pixel, assuming that the horizontal gradient of a certain pixel point on the edge contour of the circular template is Gmdx(i, j) vertical gradient Gmdy(i, j), and the horizontal gradient G of a certain pixel point of the zoomed round casting blank end face image corresponding to the (i, j)dx(i + m, j + n) with a vertical gradient Gdy(i + M, j + n), the gradient matching value of the single-point pixel is Mdxy=Gdx(i+m,j+n)×Gmdx(i,j)+Gdy(i+m,j+n)×Gmdy(i, j), wherein m, n is the value in all the traversal ranges;
s1.4.2 calculating gradient matching value of circular template, down-sampling the circular template profile, setting the down-sampling coefficient to 2, namely, taking one pixel at every other pixel, traversing the down-sampled circular template profile points, and obtaining the gradient matching value M of all pixels of the scaled circular casting blank end face image corresponding to the pointsdxyAccumulating all gradient matching values Mdxy, and dividing the accumulated result by the number of points of the outline of the circular template to obtain a gradient matching value so as to complete the gradient matching of the circular template for one time; setting the matching step length as 1, and completing the calculation of the gradient matching value of the circular template of the whole image by traversing the zoomed circular casting blank end face image so as to obtain a complete gradient matching image;
s1.5, adding NmRepeating the calculation of step S1.4 for each circular template image to obtain NmA gradient matching map, searching for NmAnd comparing the brightest point in the gradient matching image with the set brightest point threshold value, so as to obtain the corresponding center coordinate and the radius of the circular template, and positioning the circular effective area.
2. The method for correcting and identifying the inclination of the code-sprayed characters on the end faces of the round casting blanks according to claim 1, wherein the method comprises the following steps: step S3, the method for obtaining the slope average of the short side of the circumscribed rectangle includes:
s3.1, assuming that the number of minimum outline bounding rectangles is NcRemoving two profiles with the minimum external rectangle short side inclination angle as the maximum value and the minimum value, wherein thetaiIn order to remove the i-th minimum outline short edge inclination angle after the maximum value and the minimum value of the inclination angle, the character inclination angle of the code-sprayed character is
Figure FDA0003615543280000031
3. The method for correcting and identifying the inclination of the code-sprayed characters on the end faces of the round casting blanks according to claim 1, wherein the method comprises the following steps: step S3, where the method for voting by combining and arranging the slopes of the connecting lines between any two external rectangles to obtain the tilt angle of the character specifically includes:
s3.2, according to the prior condition information of the character row-column distribution characteristics, supposing that M rows of characters exist, wherein Ai is the number of the ith row of characters, and the number of any two character arrangement combinations in a single row of characters is
Figure FDA0003615543280000032
The total number of any two character permutation and combination of all the single-line characters is
Figure FDA0003615543280000033
Assuming that the number of the minimum bounding rectangles of the obtained outline is Nc,θ(i,j)Is the inclination angle of the connecting line of the minimum external rectangle central points of any two outlines, wherein i is not equal to j, i belongs to [1, N ]c],j∈[1,Nc],θ(i,j)E [0, 180 deg. ], the total number of permutation and combination of the connecting line of the central points of the minimum enclosing rectangles of any two outlines is
Figure FDA0003615543280000034
The total number of any two character permutation and combination of all the single-line characters is as follows
Figure FDA0003615543280000035
By looking for theta(i,j)Theta with total ratio of P in a range of a certain cell in which the values of the middle inclination angle are concentrated(i,j)The inclination angles are collected, and theta with the proportion of P is obtained(i,j)And taking the average value of the elements in the inclination angle set as the inclination angle of the code spraying character.
4. The method for correcting and identifying the inclination of the code-sprayed characters on the end faces of the round casting blanks according to claim 1, which is characterized by comprising the following steps of: the post-processing of the correction result in step S4 includes: sorting all corrected single characters according to the central coordinate position of the circumscribed rectangle to obtain the quantity information of each row of characters, comparing the quantity information with the prior condition information of the character row-column distribution, namely the quantity characteristics, and if the quantity information is matched with the prior condition information of the characters, the correction result of the step S3 is the final correction result; if not, a 180 degree rotation is required as the final correction result.
5. The method for correcting and identifying the inclination of the code-sprayed characters on the end faces of the round casting blanks according to claim 1, wherein the method comprises the following steps: the ResNet-inclusion model fusion classifier described in step S5, ResNet-18 is taken as a main feature extraction network, an inclusion module is fused, a 7 multiplied by 7 convolution kernel of a 1 st convolution module of the ResNet-18 is adjusted into two 5 multiplied by 5 convolution kernels, a 2 nd convolution module comprises 2 residual error structures, the residual error structures consist of 64-numbered 3 multiplied by 3+3 multiplied by 3 convolution kernels, fusing 2 residual error structures by concat connection, wherein the 4 th convolution module contains 2 residual error structures which are composed of 256 convolution kernels of 3x3+3x3, fusing 2 residual error structures by concat connection, adjusting the 3X3+3X3 convolution kernels of the 3 rd convolution module and the 5 th convolution module to be 1X 1+ 3X3+ 1X 1 convolution kernels, and fusing the split-transform-merge structural paradigm, finally changing the fully-connected layer into 64-dimensional output, and using a regularization method DropBlock in a 2 nd convolution module.
6. The method for correcting and identifying the inclination of the code-sprayed characters on the end faces of the round casting blanks according to claim 1, which is characterized by comprising the following steps of: in step S2, only the pixels in the area surrounded by the circle contour are preprocessed, and the pixels outside the circle contour are not processed as invalid pixels.
7. A computer-readable storage medium, storing a computer program which, when executed by a processor, causes the processor to carry out the steps of the method according to any one of claims 1 to 6.
CN202210213702.2A 2022-03-07 2022-03-07 Method for correcting and identifying inclination of code-spraying characters on end face of round casting blank and storage medium Active CN114299502B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210213702.2A CN114299502B (en) 2022-03-07 2022-03-07 Method for correcting and identifying inclination of code-spraying characters on end face of round casting blank and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210213702.2A CN114299502B (en) 2022-03-07 2022-03-07 Method for correcting and identifying inclination of code-spraying characters on end face of round casting blank and storage medium

Publications (2)

Publication Number Publication Date
CN114299502A CN114299502A (en) 2022-04-08
CN114299502B true CN114299502B (en) 2022-06-17

Family

ID=80978509

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210213702.2A Active CN114299502B (en) 2022-03-07 2022-03-07 Method for correcting and identifying inclination of code-spraying characters on end face of round casting blank and storage medium

Country Status (1)

Country Link
CN (1) CN114299502B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115497099B (en) * 2022-09-23 2023-04-18 神州数码系统集成服务有限公司 Single character image matching and identifying method based on circular scanning

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101751785A (en) * 2010-01-12 2010-06-23 杭州电子科技大学 Automatic license plate recognition method based on image processing
CN108596066A (en) * 2018-04-13 2018-09-28 武汉大学 A kind of character identifying method based on convolutional neural networks
CN109871938A (en) * 2019-01-21 2019-06-11 重庆大学 A kind of components coding detection method based on convolutional neural networks
CN111598083A (en) * 2020-05-08 2020-08-28 南通大学 Method for detecting quality of spray printing and code spraying on bottle bottom mold closing line
CN112085024A (en) * 2020-09-21 2020-12-15 江苏理工学院 Tank surface character recognition method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101751785A (en) * 2010-01-12 2010-06-23 杭州电子科技大学 Automatic license plate recognition method based on image processing
CN108596066A (en) * 2018-04-13 2018-09-28 武汉大学 A kind of character identifying method based on convolutional neural networks
CN109871938A (en) * 2019-01-21 2019-06-11 重庆大学 A kind of components coding detection method based on convolutional neural networks
CN111598083A (en) * 2020-05-08 2020-08-28 南通大学 Method for detecting quality of spray printing and code spraying on bottle bottom mold closing line
CN112085024A (en) * 2020-09-21 2020-12-15 江苏理工学院 Tank surface character recognition method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于梯度模板匹配的眉毛识别方法;李厚君;《广西科技大学学报》;20180705(第03期);全文 *

Also Published As

Publication number Publication date
CN114299502A (en) 2022-04-08

Similar Documents

Publication Publication Date Title
CN108985137B (en) License plate recognition method, device and system
CN110348264B (en) QR two-dimensional code image correction method and system
CN108345881B (en) Document quality detection method based on computer vision
Neto et al. Brazilian vehicle identification using a new embedded plate recognition system
CN116664559B (en) Machine vision-based memory bank damage rapid detection method
CN111860439A (en) Unmanned aerial vehicle inspection image defect detection method, system and equipment
CN114299502B (en) Method for correcting and identifying inclination of code-spraying characters on end face of round casting blank and storage medium
CN110648330B (en) Defect detection method for camera glass
WO2017161636A1 (en) Fingerprint-based terminal payment method and device
CN112378350B (en) Flatness detection method for PIN PIN of network transformer
CN106815830B (en) Image defect detection method
CN113019973B (en) Online visual inspection method for manufacturing defects of ring-pull cans
CN113177899A (en) Method for correcting text tilt of medical photocopy, electronic device and readable storage medium
CN111223078B (en) Method for determining flaw level and storage medium
CN110516731B (en) Visual odometer feature point detection method and system based on deep learning
CN115953373A (en) Glass defect detection method and device, electronic equipment and storage medium
Wankhede et al. A low cost surface strain measurement system using image processing for sheet metal forming applications
CN107545217B (en) Fingerprint matching method, fingerprint matching device and fingerprint identification chip
CN110969612B (en) Two-dimensional code printing defect detection method
CN113705564A (en) Pointer type instrument identification reading method
CN113421223A (en) Industrial product surface defect detection method based on deep learning and Gaussian mixture
CN117314901A (en) Scale-adaptive chip detection neural network system
CN113066087A (en) Intelligent detection and labeling system and method for parts
CN112036232A (en) Image table structure identification method, system, terminal and storage medium
CN117152165A (en) Photosensitive chip defect detection method and device, storage medium and electronic equipment

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