CN111738320A - Shielded workpiece identification method based on template matching - Google Patents

Shielded workpiece identification method based on template matching Download PDF

Info

Publication number
CN111738320A
CN111738320A CN202010532393.6A CN202010532393A CN111738320A CN 111738320 A CN111738320 A CN 111738320A CN 202010532393 A CN202010532393 A CN 202010532393A CN 111738320 A CN111738320 A CN 111738320A
Authority
CN
China
Prior art keywords
image
template
rgb
workpiece
matching
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.)
Granted
Application number
CN202010532393.6A
Other languages
Chinese (zh)
Other versions
CN111738320B (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.)
Shenyang University of Technology
Original Assignee
Shenyang University of Technology
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 Shenyang University of Technology filed Critical Shenyang University of Technology
Publication of CN111738320A publication Critical patent/CN111738320A/en
Application granted granted Critical
Publication of CN111738320B publication Critical patent/CN111738320B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/74Image or video pattern matching; Proximity measures in feature spaces
    • G06V10/75Organisation of the matching processes, e.g. simultaneous or sequential comparisons of image or video features; Coarse-fine approaches, e.g. multi-scale approaches; using context analysis; Selection of dictionaries
    • G06V10/751Comparing pixel values or logical combinations thereof, or feature values having positional relevance, e.g. template matching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/80Analysis of captured images to determine intrinsic or extrinsic camera parameters, i.e. camera calibration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/46Descriptors for shape, contour or point-related descriptors, e.g. scale invariant feature transform [SIFT] or bags of words [BoW]; Salient regional features
    • G06V10/462Salient features, e.g. scale invariant feature transforms [SIFT]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Databases & Information Systems (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Software Systems (AREA)
  • Image Analysis (AREA)

Abstract

The invention relates to the field of workpiece identification, in particular to a method for identifying a shielded workpiece based on template matching. The method comprises the steps of preprocessing a color image; then, manufacturing a plurality of standard templates; and finally, judging whether the workpiece exists or not through standard template matching. The system comprises an image alignment module, a preprocessing module, a standard template module and a template matching module. The identification method can effectively identify the workpieces in the non-shielding state and the shielding state, the identification rate can reach 94.4%, and the workpieces in the non-shielding state and the shielding state can be effectively identified.

Description

Shielded workpiece identification method based on template matching
Technical Field
The invention relates to the field of workpiece identification, in particular to a method for identifying a shielded workpiece based on template matching.
Background
Workpiece sorting is an important part of industrial automation production, and the efficiency and accuracy of the workpiece sorting depend on the recognition rate of workpieces to a great extent. Most sorting systems adopted by various factories are only suitable for identifying non-shielding workpieces, and if the workpieces are shielded, the sorting system fails due to the fact that the system cannot adapt to the change, so that selection of an identification algorithm is particularly important. The template matching technique, one of the commonly used recognition algorithms, is to translate the template to every possible position in the source image and evaluate whether the template matches the source image at that position. Existing template matching techniques can be broadly divided into two categories: a grayscale-based method and a feature-based method. The grayscale-based method can be considered as a process of finding the maximum similarity between the template and the source image; while the feature-based approach is to match basic features between images, such as boundaries, unique points, texture, entropy and energy.
US patent US20080240502, published 20/l 0, 2008, discloses an apparatus for mapping an object comprising an illumination assembly comprising a single transparency comprising a fixed pattern of spots. The principle of depth measurement adopts the principle of triangulation distance measurement. Guo Neppon, Chengning, Liubin in 2014 disclose color and depth camera calibration of Kinect sensors, specifically relating to calculating internal and external parameters of color cameras and infrared cameras.
In recent years, various improved algorithms related to template matching algorithms are widely used in many fields such as medicine, military affairs and the like. deAra jo et al propose a gray scale template matching algorithm named Ciratefi, which is more accurate but slow although its results are more accurate. Therefore, there is a need for a method for identifying a workpiece in a non-shielding state and a shielding state.
Disclosure of Invention
The purpose of the invention is as follows:
the invention aims to provide a method for identifying a shielded workpiece based on template matching, so as to solve the problem of identification of the workpiece in the prior art.
The technical scheme is as follows:
the method for identifying the shielded workpiece based on template matching specifically comprises the following steps: firstly, aligning a depth image and a color image; then, preprocessing of bilateral filtering, Laplace enhancement and texture extraction is carried out on the aligned color images in sequence; then, manufacturing a plurality of standard templates; and finally, judging whether the workpiece exists or not through standard template library matching.
Further, the depth image and the color image specifically include:
a kinect v2 camera is adopted for image acquisition, in the camera calibration process, a chessboard calibration graph adhered on a flat wood board is shot under the natural light condition by a laser transmitter shielding kinect v2, a color image and an infrared image of a calibration chessboard are obtained, angular points are extracted, and then internal and external parameters of the color camera and the infrared camera are calculated;
kinect v2 color camera internal reference KrgbThe following were used:
Figure BDA0002535850780000021
wherein f isx_rgbAnd fy_rgbScale factors of the color camera in the x direction and the y direction respectively; (c)x_rgb,cy_rgb) The coordinates of the central position of the color image; the color camera internal parameters used by the calibration experiment were:
Figure BDA0002535850780000022
thus for homogeneous three-dimensional points P in the color camera coordinate systemrgb=[XrgbYrgbZrgb1]TTo the homogeneous coordinate p of the pixel on the color picturergb=[urgbvrgb1]TThe mapping relationship of (1) is as follows:
Zrgb*prgb=Krgb*[I|0]Prgb(3)
unfolding to obtain:
Figure BDA0002535850780000031
wherein, Prgb=[XrgbYrgbZrgb1]TAs homogeneous coordinates, using non-homogeneous coordinates
Figure BDA0002535850780000032
Expressed in the form:
Figure BDA0002535850780000033
similarly, obtaining a mapping formula of the depth camera:
Figure BDA0002535850780000034
wherein p isir=[uirvir1]THomogeneous coordinates of pixels on the depth image;
Figure BDA0002535850780000035
homogeneous three-dimensional points under a depth camera coordinate system;
Figure BDA0002535850780000036
is an internal parameter of the depth camera, fx_irAnd fy_irScale factors of the depth camera in the x direction and the y direction respectively; (c)x_ir,cy_ir) The coordinates of the center position of the depth image are obtained; obtained by calibration experiment
Figure BDA0002535850780000037
The color camera external parameter for the same checkerboard is RrgbAnd Trgb(ii) a And the external parameter of the depth camera is RirAnd Tir(ii) a The two cameras have the following rigid body transformation relationship:
Rir 2 rgb=Rrgb*Rir -1(8)
Tir 2 rgb=Trgb-Rir 2 rgb*Tir(9)
three-dimensional points in respective camera coordinate systems for non-homogeneous coordinate representations
Figure BDA0002535850780000041
And
Figure BDA0002535850780000042
for example, the following relationships are given:
Figure BDA0002535850780000043
the following equation is obtained:
Figure BDA0002535850780000044
to simplify the representation, let: r is Krgb*Rir 2 rgb*Kir -1,T=Krgb*Tir 2 rgbThen, there are:
Zrgb*prgb=R*Zir*pir+T (12)
the correspondence between the depth image of kinect v2 and the color image is obtained from the above equation.
Further, the image preprocessing specifically includes: aligning the depth image and the color image, then carrying out image filtering on the aligned color image, then carrying out image enhancement on the filtered image, and then carrying out texture extraction.
Further, the image filtering specifically includes:
adopting a bilateral filtering algorithm; the expression for bilateral filtering is as follows:
Figure BDA0002535850780000045
wherein: g (i, j) represents the pixel value of the output point; s (i, j) refers to the range of 10 × 10 centered on (i, j); f (k, l) represents the pixel value of the input point; w (i, j, k, l) is a weighting function, and is expressed as follows:
Figure BDA0002535850780000046
wherein: (i, j) is the position coordinate of the current point, (k, l) is the position coordinate of the central point, f (i, j) is the gray value of the current point, and f (k, l) is the gray value of the central point; sigmasIs the standard deviation, σ, of the spatial domainrSelecting weights for the value domain standard deviation, i.e. the ws function, according to the distance between pixels, the closer the distance the weight is greater; the wr function distributes weight values according to the difference between pixels, and if two pixel values tend to be the same, the weight values are larger than the weight values of the pixel points which are close to each other but have larger difference even if the two pixel values are far away from each other; due to the function of the wr function, the characteristics of the pixel points at the edge of the workpiece are reserved.
Further, Laplace enhancement is selected for the filtered image; the laplacian operator is:
Figure BDA0002535850780000051
the enhanced image can be obtained according to the following formula:
Figure BDA0002535850780000052
where l (x, y) is the pixel value of the point (x, y) in the output image, and k (x, y) is the pixel value of the point (x, y) in the original image.
Further, after image enhancement, texture extraction is carried out by adopting an LBP operator, and the expression is as follows:
Figure BDA0002535850780000053
wherein, p represents the p-th pixel point except the central pixel point in the 3 x 3 window; h (c) a pixel value representing a center pixel point; h (p) represents the pixel value of the p-th pixel point in the neighborhood; s (x) formula is as follows:
Figure BDA0002535850780000054
further, the manufacturing of the plurality of standard templates specifically includes:
defining an interested region matched with the image, namely the region where the workpiece is located, of the preprocessed image, extracting the interested region of the obtained image, and taking the obtained interested region as a template;
respectively placing workpieces in the same state as the template at different positions, acquiring workpiece images by using kinect v2 to respectively perform matching experiments, determining that the template is available if the workpieces can be matched under various conditions, otherwise, returning to a defined image to match a new region of interest, and if the workpieces cannot be identified, acquiring the workpiece images again; taking the theta angle as an increment, obliquely placing the workpiece on a plane until the theta angle is N times, and respectively shooting the workpiece to obtain N pairs of pictures; preprocessing the N +1 images to obtain N +1 templates; LBP calculation is carried out on the obtained template to obtain a texture image of the template, the texture image is used as a final template image, namely a standard template, and the standard templates are combined to establish a standard template library.
Furthermore, the similarity degree of the template and the subgraph is represented by R (x, y),
matching the relative value of the template to the mean value of the image based on the standard correlation coefficient, wherein 1 represents that the matching effect is best, 1 represents that the matching effect is worst, and 0 represents that the two have no correlation; let I (x, y) be a target image of size M × N pixels, and T (x, y) be a template image of size M × N pixels; t (x ', y') is a point in the current template, and I (x + x ', y + y') is a point on the target image corresponding to the point; the expression of the degree of similarity R (x, y) is as follows
Figure BDA0002535850780000061
Wherein:
T′(x′,y′)=T(x′,y′)-1/(mn)·∑x″,y″T(x″,y″)
I′(x+x′,y+y′)=I(x+x′,y+y′)-1/(mn)·∑x″,y″I(x+x″,y+y″);
because the direction of the inclined template in the obtained standard template is unique, image rotation is required for identifying workpieces in different inclined directions;
the image rotation refers to a process of forming a new image by rotating an image by a certain angle by taking a certain point as a center, wherein the point is usually the center of the image; because the rotation is carried out according to the center, and the distance r between the point before and after the rotation and the center is not changed, the corresponding relation between the coordinate of the point after the rotation and the original coordinate is obtained;
assumed point (x)1,y1) Rotated by an angle of theta to a point (x)2,y2) Where a is the angle from the center point of the original image to the x-axis and b is the angle from the center point of the original image to the y-axis, θ can be expressed as a-b, and the following equation is written:
x2=r*cos b=r*cos(a+θ) (20)
y2=r*sin b=r*sin(a+θ) (21)
unfolding to obtain:
x2=r*cos a*cosθ-r*sinθ*sin a (22)
y2=r*sin a*cosθ+r*sinθ*cos a (23)
namely:
x2=x1*cosθ-y1*sinθ (24)
y2=y1*cosθ+x1*sinθ (25)。
further, judging whether a workpiece exists through template matching specifically includes matching the preprocessed texture image with a template, judging whether matching needs to be carried out according to the similarity R (x, y) through a template matching algorithm based on a standard correlation coefficient, if the current template does not match, rotating the current template to 360 degrees according to 10-degree increment, sequentially calculating the similarity R (x, y) between the template at each angle and the image, and determining whether matching exists according to the judgment on the size of R (x, y); when a certain template is matched, outputting a matched area and position coordinates thereof in the image; if the rotated templates are not matched yet, performing the next template, repeating the matching process until the matching is successful, and judging that the target workpiece exists in the region; and if the matching is not successful in all the templates, judging that the target workpiece does not exist in the area.
The shielding workpiece identification system based on template matching comprises an image alignment module, a preprocessing module, a standard template module and a template matching module;
an image alignment module for aligning the depth image and the color image;
the preprocessing module is used for sequentially carrying out preprocessing of bilateral filtering, Laplace enhancement and texture extraction on the aligned color images;
the standard template module is used for manufacturing a plurality of standard templates;
and the template matching module is used for judging whether the workpiece exists or not through standard template matching.
The advantages and effects are as follows:
the invention has the following advantages and beneficial effects:
the identification algorithm combines the texture characteristics of the image while using the pixel gray value information for matching, and utilizes the texture information of the image to identify and position the workpiece, thereby improving the accuracy of the position coordinate of the workpiece; and then, multiple templates are added for rotary matching, so that the method can adapt to workpieces in different states, and the combined algorithm has higher recognition rate.
The identification method can effectively identify the workpieces in the non-shielding state and the shielding state, and the identification rate can reach 94.4%. Compared with the prior art, the identification speed of the identification method is higher while the identification rate is ensured.
Drawings
FIG. 1 is a flow chart of workpiece identification;
fig. 2 is a 3 x 3 window plot in texture extraction;
FIG. 3 is an image pre-processing diagram, (a) an original image; (b) a filtering result graph; (c) enhancing the result graph; (d) extracting a result graph of the texture;
FIG. 4 is a plurality of template images;
FIG. 5 is a template rotation diagram, (a) a template original image, and (b) a rotation image;
fig. 6 shows the results of recognition of a plurality of workpieces, (a) original images of workpieces to be recognized, and (b) workpiece recognition results.
Detailed Description
The invention is further described below with reference to the accompanying drawings:
the invention provides a multi-template rotation matching method based on pixel gray scale and combined with texture information, aiming at the problem of identification of a shielded workpiece in actual production. Firstly, the algorithm aligns the shot color image with the depth image by utilizing the corresponding relation between the depth camera and the color camera in kinect v 2; then preprocessing the color image such as filtering, enhancing, texture extracting and the like to obtain a clear texture image; then, workpieces which are horizontally placed and placed at different inclination angles are respectively manufactured into a plurality of standard templates; and finally, sequentially matching the template with the texture image, and if the matching is successful, judging that the target workpiece exists in the region. Experimental results prove that the method can effectively identify the workpieces in the non-shielding state and the shielding state, and the identification rate can reach 94.4%.
As shown in fig. l, the method for identifying the shielded workpiece based on template matching specifically comprises the following steps: firstly, aligning a depth image and a color image; then, preprocessing of bilateral filtering, Laplace enhancement and texture extraction is carried out on the aligned color images in sequence; then, manufacturing a plurality of standard templates; and finally, judging whether the workpiece exists or not through standard template matching.
First, the depth image is aligned with the color image.
The image acquisition is carried out by adopting a kinect v2 camera, the image acquisition device consists of an infrared laser transmitter, an infrared receiving camera and a color camera, the depth information of the image can be directly obtained, and the depth measurement principle is a triangular distance measurement principle. However, the color camera and the depth camera of kinect v2 are located differently, and the pixels of the captured color picture are 1920 × 1080 and the pixels of the captured depth picture are 512 × 424, so that the depth information and the color information cannot be aligned accurately, and the present invention requires that the depth image and the color image must be aligned completely in the workpiece recognition application later, that is, the depth information on the depth image is mapped onto the color information of the color image, so that the correspondence between the two cameras needs to be obtained.
The corresponding relation is obtained through camera calibration, firstly, a chessboard calibration image pasted on a flat wood board is shot through a laser transmitter shielding kinect v2 under the condition of natural light, a color image and an infrared image of a calibration chessboard are obtained, angular points are extracted, and then internal and external parameters of a color camera and an infrared camera are calculated.
The Kinect v2 comprises a color camera, a depth camera, an infrared projector and a quaternary linear microphone array; the color camera is used for acquiring a color video or image within the shooting visual angle range; the infrared projector actively projects near infrared spectrum outwards; the depth camera analyzes the infrared spectrum reflected from the object, and calculates the distance between the object and the depth camera according to the obtained spectral information; the quaternary linear microphone array is used for collecting sound; when the Kinect v2 camera is calibrated, firstly, the camera is used for collecting 20 images of a chessboard calibration plate shot at different angles, and then the obtained color image and depth image are respectively processed by adopting an image processing tool box carried in Matlab-R2016a, so that the internal and external parameters of a color camera and a depth camera can be obtained;
kinect v2 color camera internal reference KrgbThe following were used:
Figure BDA0002535850780000101
wherein f isx_rgbAnd fy_rgbScale factors of the color camera in the x direction and the y direction respectively; (c)x_rgb,cy_rgb) The coordinates of the central position of the color image; the color camera internal parameters used by the calibration experiment were:
Figure BDA0002535850780000102
thus for homogeneous three-dimensional points P in the color camera coordinate systemrgb=[XrgbYrgbZrgb1]TTo the homogeneous coordinate p of the pixel on the color picturergb=[urgbvrgb1]TThe mapping relationship of (1) is as follows:
Zrgb*prgb=Krgb*[I|0]Prgb(3)
unfolding to obtain:
Figure BDA0002535850780000103
wherein, Prgb=[XrgbYrgbZrgb1]TAs homogeneous coordinates, using non-homogeneous coordinates
Figure BDA0002535850780000104
Expressed in the form:
Figure BDA0002535850780000105
similarly, obtaining a mapping formula of the depth camera:
Figure BDA0002535850780000111
wherein p isir=[uirvir1]T is the homogeneous coordinate of the pixel on the depth image;
Figure BDA0002535850780000112
homogeneous three-dimensional points under a depth camera coordinate system;
Figure BDA0002535850780000113
is an internal parameter of the depth camera, fx_irAnd fy_irScale factors of the depth camera in the x direction and the y direction respectively; (c)x_ir,cy_ir) The coordinates of the center position of the depth image are obtained; obtained by calibration experiment
Figure BDA0002535850780000114
The color camera external parameter for the same checkerboard is RrgbAnd Trgb(ii) a And the external parameter of the depth camera is RirAnd Tir(ii) a The two cameras have the following rigid body transformation relationship:
Rir 2 rgb=Rrgb*Rir -1(8)
Tir 2 rgb=Trgb-Rir 2 rgb*Tir(9)
three-dimensional points in respective camera coordinate systems for non-homogeneous coordinate representations
Figure BDA0002535850780000115
And
Figure BDA0002535850780000116
for example, the following relationships are given:
Figure BDA0002535850780000117
the following equation is obtained:
Figure BDA0002535850780000118
to simplify the representation, let: r is Krgb*Rir 2 rgb*Kir -1,T=Krgb*Tir 2 rgbThen, there are:
Zrgb*prgb=R*Zir*pir+T (12)
the correspondence between the depth image of kinect v2 and the color image is obtained from the above equation.
Secondly, the aligned color image is preprocessed in a preprocessing stage.
Image filtering is performed first.
The invention is influenced by illumination or complex production environment of factory site when collecting picture, which causes noise of image, so filtering and denoising are carried out to image. The workpieces are shielded during shooting, the edge information of each workpiece plays an important role in distinguishing different workpieces in the identification process after the method is used, and if the edges of the workpieces are not clear, the boundary between the overlapped workpieces is difficult to distinguish, so the edge information needs to be kept as much as possible in the filtering process. After comparing various filter algorithms such as bilateral filter, median filter, mean filter, Gaussian filter and block filter, the invention finds that bilateral filter has the best effect of filtering noise and protecting edges, so bilateral filter algorithms are adopted in experiments. The expression for bilateral filtering is as follows:
Figure BDA0002535850780000121
wherein: g (i, j) represents the pixel value of the output point; s (i, j) refers to the range of 10 × 10 centered on (j, j); f (k, l) represents the pixel value of the input point; w (i, j, k, l) is a weighting function, and is expressed as follows:
Figure BDA0002535850780000122
wherein: (i, j) is the position coordinate of the current point, (k, l) is the position coordinate of the central point, f (i, j) is the gray value of the current point, and f (k, l) is the gray value of the central point; sigmasIs the standard deviation, σ, of the spatial domainrSelecting weights for the value domain standard deviation, i.e. the ws function, according to the distance between pixels, the closer the distance the weight is greater; the wr function distributes weight values according to the difference between pixels, and if two pixel values tend to be the same, the weight values are larger than the weight values of the pixel points which are close to each other but have larger difference even if the two pixel values are far away from each other; due to the function of the wr function, the characteristics of the pixel points at the edge of the workpiece are reserved. Through experimental comparison, when sigma iss=10,σrAt 50, the filtering effect is most suitable.
And then carrying out image enhancement.
The whole light and shade contrast of the filtered picture is not obvious, and in order to distinguish the workpiece from the background more clearly and reduce the interference of the background on the identification precision, the image is enhanced. The detail information of the workpiece plays an important role in the subsequent texture extraction, so the image is enhanced on the premise of not destroying the detail information of the workpiece, and the noise is enhanced when the image is enhanced, so the image enhancement is performed after bilateral filtering.
After contrast experiments are carried out on Laplace enhancement, histogram equalization, logarithmic enhancement and gamma conversion, it is found that the contrast between a workpiece and a background is improved by utilizing a Laplace operator to carry out image enhancement, the detail information of the workpiece is not damaged, the detail information of the workpiece is more prominent, and therefore Laplace enhancement is selected for the filtered image; the laplacian operator is:
Figure BDA0002535850780000131
the enhanced image can be obtained according to the following formula:
Figure BDA0002535850780000132
where l (x, y) is the pixel value of the point (x, y) in the output image, and k (x, y) is the pixel value of the point (x, y) in the original image.
And finally, extracting the texture.
Generally, only the same type of workpieces are processed at the same time on a production line, so that the characteristics of the workpieces are basically the same, the identification of non-overlapped workpieces is not greatly influenced, but the identification of overlapped workpieces is increased in difficulty, so that the overlapped workpieces cannot be well distinguished although the images are clearer after filtering and enhancing, in order to identify the shielded workpieces, the extraction of the texture characteristics of the workpieces is added before the identification, and the obtained texture information of the workpieces is used as the characteristics to distinguish each independent workpiece. The LBP operator is used for texture extraction, is the simplest and most effective operator for describing local texture characteristics of the image, and has the remarkable advantages of rotation invariance, gray scale invariance and the like, and the expression is as follows:
Figure BDA0002535850780000133
wherein, p represents the p-th pixel point except the central pixel point in the 3 x 3 window; h (c) a pixel value representing a center pixel point; h (p) represents the pixel value of the p-th pixel point in the neighborhood; s (x) formula is as follows:
Figure BDA0002535850780000141
the 3 x 3 window used in the present invention is shown in fig. 2, which can meet the requirement of texture extraction and does not affect the speed of the algorithm.
As shown in fig. 3, after the image is preprocessed, the contrast between light and shade is obvious, the background is almost white, and the influence of the background on the workpiece identification is reduced to the maximum extent; and the detailed information of the workpiece is also kept while the texture image is extracted.
For object recognition.
Template matching based on a round wheel is performed.
The template matching algorithm is one of the most commonly used algorithms for object detection, and can quickly and efficiently find out an object in an image. In brief, an image I contains a target object to be recognized, and the position of the target object is obtained by sliding the template image T on the source image I for matching. The portion of the template image T overlaid on the large image I is called a sub-image. The similarity between the template and the subgraph is represented by R (x, y), and there are four common matching criteria: squared error matching, standard squared error matching, correlation coefficient matching, and standard correlation coefficient matching. As can be seen from table 1, in the above 4 methods, the matching effect of the standard correlation coefficient matching is the best, and the recognition rate is the highest, so that the template matching based on the standard correlation coefficient is adopted in all the following experiments.
TABLE 1 matching method identification results
Figure BDA0002535850780000142
Wherein, the similarity degree of the template and the subgraph is represented by R (x, y),
matching the relative value of the template to the mean value of the image based on the standard correlation coefficient, wherein 1 represents that the matching effect is best, 1 represents that the matching effect is worst, and 0 represents that the two have no correlation; let I (x, y) be a target image of size M × N pixels, and T (x, y) be a template image of size M × N pixels; t (x ', y') is a point in the current template, and I (x + x ', y + y') is a point on the target image corresponding to the point; the expression of the degree of similarity R (x, y) is as follows
Figure BDA0002535850780000151
Wherein:
T′(x′,y′)=T(x′,y′)-1/(mn)·∑x″,y″T(x″,y″)
I′(x+x′,y+y′)=I(x+x′,y+y′)-1/(mn)·∑x″,y″I(x+x″,y+y″);
the method is used for carrying out matching experiments on the workpieces in various states. The experimental result shows that for a single workpiece, the template matching algorithm based on the standard correlation coefficient can accurately detect the target workpiece, but for a plurality of workpieces which are overlapped, the method can not identify the workpiece in the image sometimes, so that the invention improves the traditional template matching algorithm to improve the identification rate of the algorithm.
And (4) matching multiple templates.
In order to realize template matching of the workpiece, the invention needs to manufacture a standard template for the workpiece. The template making and selection is most important when the template matching algorithm is used for identifying the object, and if the template is not made properly, the algorithm cannot accurately identify the object or the identification error can occur even if the hardware condition is superior and the extracted part image to be matched is clear.
In practice, since workpieces are stacked and placed to be inclined, a single template is used, and is easily affected by inclination deviation, so that the recognition rate is low, and therefore, it is necessary to produce a plurality of templates to match the workpiece images and to include various shapes in which the workpieces are placed as much as possible. Firstly, templates are manufactured for workpieces with different inclination angles, and then the standard templates are combined to establish a standard template library.
The template manufacturing steps are as follows:
(1) placing a workpiece on a horizontal plane, collecting a workpiece image by a kinect v2, and extracting a single collected image;
(2) the image is subjected to bilateral filtering and Laplace enhancement processing in sequence, noise in the image is filtered, background interference is reduced, and the outline of an image workpiece tends to be clear;
(3) the region of interest in which the image matches, i.e. the region in which the workpiece is located, is defined as a generally rectangular region. Extracting an interested region of the obtained image, and taking the obtained interested region as a template;
(4) running a program, respectively placing workpieces in the same state as the template at different positions, acquiring workpiece images by using kinect v2 to respectively perform matching experiments, determining that the template is available if the workpieces can be matched under various conditions, otherwise returning to the step (3), and acquiring the workpiece images again if the workpieces cannot be identified;
(5) the workpiece was placed on a plane with an inclination of up to 60 deg. in increments of 20 deg., and 3 pictures were taken of it, respectively. Carrying out the operations (2), (3) and (4) on the 4 images to obtain 4 templates;
(6) LBP calculation is performed on the obtained 4 templates to obtain texture images of the 4 templates, and the texture images are used as final template images, namely as shown in FIG. 4.
Under the actual shooting condition, most upper workpieces are placed close to the horizontal plane or have smaller inclination angles, so that the templates placed on the horizontal plane are used as first templates and are sorted according to the increase of the inclination angles, the matching time can be shortened, and the working efficiency is improved.
And matching the rotating templates.
The algorithm requires the selected template to be aligned with the direction of the target object in the image. This method can only allow a small rotation of the target object in the image, i.e. the possible pose space is limited to the translation space, so that if the orientation of the target object in the image is different from that in the template, the target object will not be found. Only the first template in the standard template library is horizontal, and the rest templates are inclined, so that the directions of the other templates except the first template are unique, and in practical situations, the inclined directions of workpieces cannot be consistent. If it is desired that all templates identify workpieces with different tilt directions, a new method, i.e. image rotation, needs to be added to the matching method.
Since the direction of the tilted template in the obtained standard template is unique, image rotation is required in order to identify workpieces with different tilted directions.
The image rotation refers to a process of forming a new image by rotating an image by a certain angle around a certain point, which is usually the center of the image. Because the rotation is carried out according to the center, and the distance r between the point before and after the rotation and the center is not changed, the corresponding relation between the coordinate of the point after the rotation and the original coordinate can be obtained.
Assumed point (x)1,y1) Rotated by an angle of theta to a point (x)2,y2) Where a is the angle from the center point of the original image to the x-axis and b is the angle from the center point of the original image to the y-axis as shown in fig. 5, θ is given by a-b, which is expressed by the following equation:
x2=r*cos b=r*cos(a+θ) (20)
y2=r*sin b=r*sin(a+θ) (21)
unfolding to obtain:
x2=r*cos a*cosθ-r*sinθ*sin a (22)
y2=r*sin a*cosθ+r*sinθ*cos a (23)
namely:
x2=x1*cosθ-y1*sinθ (24)
y2=y1*cosθ+x1*sinθ (25)。
as shown in fig. 5, 3 templates having an inclination angle are rotated once by 10 ° increments, and (a) is an original image and (b) is an image rotated by 10 ° counterclockwise. And respectively matching each image obtained by rotating the original template with the image to be matched until the matching is successful.
And (4) multi-template rotation matching.
The template matching algorithm based on the standard correlation coefficient judges whether matching is carried out according to the similarity R (x, y), although R (x, y) is the best matching result, because the workpieces are stacked and placed, the template and the workpieces in the image cannot be completely the same sometimes, so that in most cases, R (x, y) is not up to 1, a threshold value is set for R (x, y), and the result can be output when the similarity between the template and the image reaches the threshold value. According to experiments, when R (x, y) > 0.99, the workpiece which is most convenient to grab can be identified, and the identification rate is the highest.
The workpiece identification steps are as follows:
(1) acquiring a workpiece image in real time by a kinect v2, and extracting an acquired color image;
(2) carrying out bilateral filtering and Laplace enhancement treatment on the acquired workpiece image in sequence;
(3) extracting texture of the processed workpiece image to obtain a texture image;
(4) matching the texture image of the workpiece with the template, if the current template is not matched, rotating the template to 360 degrees in increments of 10 degrees, sequentially calculating the similarity R (x, y) between the template and the image at each angle, and determining whether the template is matched with the image according to the judgment of the size of the R (x, y);
(5) when a certain template is matched, the matched area in the image and the position coordinates of the matched area are output. And if the rotated templates are not matched yet, performing the next template, and repeating the step (4) until the matching is successful.
If all the standard templates fail to be matched successfully, no workpiece exists in the area.
The shielding workpiece identification system based on template matching comprises an image alignment module, a preprocessing module, a standard template module and a template matching module; an image alignment module for aligning the depth image and the color image; the preprocessing module is used for sequentially carrying out preprocessing of bilateral filtering, Laplace enhancement and texture extraction on the aligned color images; the standard template module is used for manufacturing a plurality of standard templates; and the template matching module is used for judging whether the workpiece exists or not through standard template matching.
The image alignment module mainly comprises:
a kinect v2 camera is adopted for image acquisition, in the camera calibration process, a chessboard calibration graph adhered on a flat wood board is shot under the natural light condition by a laser transmitter shielding kinect v2, a color image and an infrared image of a calibration chessboard are obtained, angular points are extracted, and then internal and external parameters of the color camera and the infrared camera are calculated;
kinect v2 color camera internal reference KrgbThe following were used:
Figure BDA0002535850780000191
wherein f isx_rgbAnd fy_rgbScale factors of the color camera in the x direction and the y direction respectively; (c)x_rgb,cy_rgb) The coordinates of the central position of the color image; the color camera internal parameters used by the calibration experiment were:
Figure BDA0002535850780000192
thus for homogeneous three-dimensional points P in the color camera coordinate systemrgb=[XrgbYrgbZrgb1]TTo the homogeneous coordinate p of the pixel on the color picturergb=[urgbvrgb1]TThe mapping relationship of (1) is as follows:
Zrgb*prgb=Krgb*[I|0]Prgb(3)
unfolding to obtain:
Figure BDA0002535850780000193
wherein, Prgb=[XrgbYrgbZrgb1]TAs homogeneous coordinates, using non-homogeneous coordinates
Figure BDA0002535850780000194
Expressed in the form:
Figure BDA0002535850780000195
similarly, obtaining a mapping formula of the depth camera:
Figure BDA0002535850780000196
wherein p isir=[uirvir1]THomogeneous coordinates of pixels on the depth image;
Figure BDA0002535850780000201
homogeneous three-dimensional points under a depth camera coordinate system;
Figure BDA0002535850780000202
is an internal parameter of the depth camera, fx_irAnd fy_irScale factors of the depth camera in the x direction and the y direction respectively; (c)x_ir,cy_ir) The coordinates of the center position of the depth image are obtained; obtained by calibration experiment
Figure BDA0002535850780000203
The color camera external parameter for the same checkerboard is RrgbAnd Trgb(ii) a And the external parameter of the depth camera is RirAnd Tir(ii) a The two cameras have the following rigid body transformation relationship:
Rir 2 rgb=Rrgb*Rir -1(8)
Tir 2 rgb=Trgb-Rir 2 rgb*Tir(9)
in respective camera coordinate systems for non-homogeneous coordinate representationsLower three-dimensional point
Figure BDA0002535850780000204
And
Figure BDA0002535850780000205
for example, the following relationships are given:
Figure BDA0002535850780000206
the following equation is obtained:
Figure BDA0002535850780000207
to simplify the representation, let: r is Krgb*Rir 2 rgb*Kir -1,T=Krgb*Tir 2 rgbThen, there are:
Zrgb*prgb=R*Zir*pir+T (12)
the correspondence between the depth image of kinect v2 and the color image is obtained from the above equation.
And the preprocessing module is used for sequentially carrying out bilateral filtering, Laplace enhancement and texture extraction on the aligned color picture.
In the preprocessing module, the color picture after alignment is firstly processed by the bilateral filtering module, then the picture after filtering is subjected to image enhancement by the Laplace enhancement module, and then the texture of the enhanced image is extracted.
Specifically processing by a bilateral filtering module: adopting a bilateral filtering algorithm; the expression for bilateral filtering is as follows:
Figure BDA0002535850780000211
wherein: g (i, j) represents the pixel value of the output point; s (i, j) refers to the range of 10 × 10 centered on (i, j); f (k, l) represents the pixel value of the input point; w (i, j, k, l) is a weighting function, and is expressed as follows:
Figure BDA0002535850780000212
wherein: (i, j) is the position coordinate of the current point, (k, l) is the position coordinate of the central point, f (i, j) is the gray value of the current point, and f (k, l) is the gray value of the central point; sigmasIs the standard deviation, σ, of the spatial domainrSelecting weights for the value domain standard deviation, i.e. the ws function, according to the distance between pixels, the closer the distance the weight is greater; the wr function distributes weight values according to the difference between pixels, and if two pixel values tend to be the same, the weight values are larger than the weight values of the pixel points which are close to each other but have larger difference even if the two pixel values are far away from each other; due to the function of the wr function, the characteristics of the pixel points at the edge of the workpiece are reserved.
Specific processing of the laplacian enhancement module: laplace enhancement is selected for the filtered image; the laplacian operator is:
Figure BDA0002535850780000213
the enhanced image can be obtained according to the following formula:
Figure BDA0002535850780000214
where l (x, y) is the pixel value of the point (x, y) in the output image, and k (x, y) is the pixel value of the point (x, y) in the original image.
The texture extraction module specifically processes:
and after image enhancement, texture extraction is carried out by adopting an LBP operator, and the expression is as follows:
Figure BDA0002535850780000221
wherein, p represents the p-th pixel point except the central pixel point in the 3 x 3 window; h (c) a pixel value representing a center pixel point; h (p) represents the pixel value of the p-th pixel point in the neighborhood; s (x) formula is as follows:
Figure BDA0002535850780000222
the standard template module specifically comprises:
defining an interested region matched with the image, namely the region where the workpiece is located, of the preprocessed image, extracting the interested region of the obtained image, and taking the obtained interested region as a template;
respectively placing workpieces in the same state as the template at different positions, acquiring workpiece images by using kinect v2 to respectively perform matching experiments, determining that the template is available if the workpieces can be matched under various conditions, otherwise, returning to a defined image to match a new region of interest, and if the workpieces cannot be identified, acquiring the workpiece images again;
taking the theta angle as an increment, obliquely placing the workpiece on a plane until the theta angle is N times, and respectively shooting the workpiece to obtain N pairs of pictures; preprocessing the N +1 images to obtain N +1 templates;
the embodiment of the invention sets the template under the following conditions: obliquely placing the workpiece on a plane by taking 20 degrees as an increment until the workpiece reaches 60 degrees, and respectively shooting the workpiece to obtain 3 pictures; preprocessing the 4 images to obtain 4 templates;
LBP calculation is carried out on the obtained template to obtain a texture image of the template, the texture image is used as a final template image, namely a standard template, and the standard templates are combined to establish a standard template library.
Since the direction of the tilted template in the obtained standard template is unique, image rotation is required in order to identify workpieces with different tilted directions.
The image rotation refers to a process of forming a new image by rotating an image by a certain angle by taking a certain point as a center, wherein the point is usually the center of the image; because the rotation is carried out according to the center, and the distance r between the point before and after the rotation and the center is not changed, the corresponding relation between the coordinate of the point after the rotation and the original coordinate is obtained;
assumed point (x)1,y1) Rotated by an angle of theta to a point (x)2,y2) Position ofAs shown in fig. 5, if a is the angle between the center point of the original image and the x-axis and b is the angle between the center point of the original image and the y-axis, θ can be expressed as a-b, and the following formula is written:
x2=r*cos b=r*cos(a+θ) (20)
y2=r*sin b=r*sin(a+θ) (21)
unfolding to obtain:
x2=r*cos a*cosθ-r*sinθ*sin a (22)
y2=r*sin a*cosθ+r*sinθ*cos a (23)
namely:
x2=x1*cosθ-y1*sinθ (24)
y2=y1*cosθ+x1*sinθ (25)。
the template matching module specifically comprises:
judging whether a workpiece exists or not through template matching, namely matching the preprocessed texture image with the template,
judging whether matching is required to be carried out according to the similarity R (x, y) by a template matching algorithm based on a standard correlation coefficient, if the current template is not matched, rotating the current template to 360 degrees by taking 10 degrees as increment, sequentially calculating the similarity R (x, y) between the template at each angle and the image, and determining whether matching is required according to the judgment on the size of R (x, y);
when a certain template is matched, outputting a matched area and position coordinates thereof in the image; if the rotated templates are not matched yet, performing the next template, repeating the matching process until the matching is successful, and judging that the target workpiece exists in the region; and if the matching is not successful in all the templates, judging that the target workpiece does not exist in the area.
And carrying out application analysis on the identification method.
The method and system of the present invention are run on an Inter (R) core (TM) i5-3210M CPU, 64-bit Windows 10 operating system. The development environment is Visual Studio 2013, and a library is developed based on OpenCV2.4.10. The camera adopts kinect v2, the depth distance range of which is most suitable from 0.8 m to 2.5 m, and when the workpiece is shot right below the camera, the distortion is minimum, the light irradiation is more uniform, and the recognition accuracy is highest, so that the workpiece is placed in the area right below the camera to be shot to improve the recognition accuracy.
The template matching experiment is performed on the workpieces which are in different states and randomly placed, and the experimental result is shown in fig. 6.
The workpiece outlined by the black box in fig. 6(b) is the identified workpiece, and the value on the box is the degree of similarity R (x, y) between the workpiece and the template used. For multiple overlapping workpieces, the result can be output when one workpiece is identified, so the workpiece outlined by the black box is the first workpiece identified by the algorithm. As can be seen from the two recognition results in fig. 6(b), whether a single workpiece or a plurality of overlapping workpieces, the target workpiece which is convenient to grasp can be accurately recognized by using the template matching algorithm of the present invention.
And (5) verifying the validity.
To further verify the validity, the following are given of the standard correlation coefficient matching method, template matching (multi-template selection only), template matching (texture feature only) and comparison of the recognition rates of 4 methods of the recognition method of the present invention.
TABLE 2 workpiece recognition Rate
Figure BDA0002535850780000241
In table 2, the effectiveness of the 4 identification methods is compared and tested, and it is obvious from the test results that the algorithm adopted by the present invention is superior to the identification rate of the workpiece. The recognition rate of the template matching method based on the standard correlation coefficient is low mainly because the method has insufficient resolution capability for overlapped same kind of workpieces, can not effectively distinguish a plurality of shielded workpieces, and can not effectively recognize workpieces with inclined angles because the template is single. The identification algorithm combines the texture characteristics of the image while matching the pixel gray value information, and identifies and positions the workpiece by using the texture information of the image, so that the accuracy of the position coordinate of the workpiece is improved; and then, multiple templates are added for rotary matching, so that the method can adapt to workpieces in different states, and the combined algorithm has higher recognition rate.
The invention provides a multi-template rotation matching identification method combined with texture information. Extracting texture information of the preprocessed image, performing template matching on the texture image by using a matching method based on pixel gray level correlation, and identifying the workpieces in the image one by one, but because the workpieces are overlapped, adding a plurality of templates and rotating the templates for matching so as to improve the identification rate of the workpieces. The data of the test results show that the workpiece identified by the method has higher identification rate. Although the recognition algorithm is provided for workpiece recognition, the recognition algorithm is not specific and can be used for recognizing other objects.

Claims (10)

1. The method for identifying the shielded workpiece based on template matching is characterized by comprising the following steps: the method comprises the following specific steps:
firstly, preprocessing a color image; then, manufacturing a plurality of standard templates; and finally, judging whether the workpiece exists or not through standard template library matching.
2. The mask workpiece identification method based on the template matching according to claim 1, characterized in that: the depth image and the color image specifically include:
a kinect v2 camera is adopted for image acquisition, in the camera calibration process, a chessboard calibration graph adhered on a flat wood board is shot under the natural light condition by a laser transmitter shielding kinect v2, a color image and an infrared image of a calibration chessboard are obtained, angular points are extracted, and then internal and external parameters of the color camera and the infrared camera are calculated;
kinect v2 color camera internal reference KrgbThe following were used:
Figure FDA0002535850770000011
wherein f isx-rgbAnd fy-rgbScale factors of the color camera in the x direction and the y direction respectively; (c)x_rgb,cy_rgb) The coordinates of the central position of the color image; the color camera internal parameters used by the calibration experiment were:
Figure FDA0002535850770000012
thus for homogeneous three-dimensional points P in the color camera coordinate systemrgb=[XrgbYrgbZrgb1]TTo the homogeneous coordinate p of the pixel on the color picturergb=[urgbvrgb1]TThe mapping relationship of (1) is as follows:
Zrgb*prgb=Krgb*[I|0]]Prgb(3)
unfolding to obtain:
Figure FDA0002535850770000021
wherein, Prgb=[XrgbYrgbZrgb1]TAs homogeneous coordinates, using non-homogeneous coordinates
Figure FDA0002535850770000022
Expressed in the form:
Figure FDA0002535850770000023
similarly, obtaining a mapping formula of the depth camera:
Figure FDA0002535850770000024
wherein p isir=[uirvir1]THomogeneous coordinates of pixels on the depth image;
Figure FDA0002535850770000025
homogeneous three-dimensional points under a depth camera coordinate system;
Figure FDA0002535850770000026
is an internal parameter of the depth camera, fx-irAnd fy-irScale factors of the depth camera in the x direction and the y direction respectively; (c)x_ir,cy_ir) The coordinates of the center position of the depth image are obtained; obtained by calibration experiment
Figure FDA0002535850770000027
The color camera external parameter for the same checkerboard is RrgbAnd Trgb(ii) a And the external parameter of the depth camera is RirAnd Tir(ii) a The two cameras have the following rigid body transformation relationship:
Rir2rgb=Rrgb*Rir -1(8)
Tir2rgb=Trgb-Rir2rgb*Tir(9)
three-dimensional points in respective camera coordinate systems for non-homogeneous coordinate representations
Figure FDA0002535850770000028
And
Figure FDA0002535850770000029
for example, the following relationships are given:
Figure FDA00025358507700000210
the following equation is obtained:
Figure FDA0002535850770000031
to simplify the representation, let: r is Krgb*Rir2rgb*Kir -1,T=Krgb*Tir2rgbThen, there are:
Zrgb*prgb=R*Zir*pir+T (12)
the correspondence between the depth image of kinect v2 and the color image is obtained from the above equation.
3. The mask workpiece identification method based on the template matching according to claim 1, characterized in that: the image preprocessing specifically comprises: aligning the depth image and the color image, then carrying out image filtering on the aligned color image, then carrying out image enhancement on the filtered image, and then carrying out texture extraction.
4. The mask workpiece identification method based on the template matching according to claim 3, characterized in that: the image filtering specifically includes:
adopting a bilateral filtering algorithm; the expression for bilateral filtering is as follows:
Figure FDA0002535850770000032
wherein: g (i, j) represents the pixel value of the output point; s (i, j) refers to the range of 10 × 10 centered on (i, j); f (k, l) represents the pixel value of the input point; w (i, j, k, l) is a weighting function, and is expressed as follows:
Figure FDA0002535850770000033
wherein: (i, j) is the position coordinate of the current point, (k, l) is the position coordinate of the central point, f (i, j) is the gray value of the current point, and f (k, l) is the gray value of the central point; sigmasIs the standard deviation, σ, of the spatial domainrSelecting weights for the value domain standard deviation, i.e. the ws function, according to the distance between pixels, the closer the distance the weight is greater; the wr function distributes weight values according to the difference between pixels, and if two pixel values tend to be the same, the weight values are larger than the weight values of the pixel points which are close to each other but have larger difference even if the two pixel values are far away from each other; due to the function of the wr function, the characteristics of the pixel points at the edge of the workpiece are reserved.
5. The mask workpiece identification method based on the template matching according to claim 3, characterized in that: laplace enhancement is selected for the filtered image; the laplacian operator is:
Figure FDA0002535850770000041
the enhanced image can be obtained according to the following formula:
Figure FDA0002535850770000042
where l (x, y) is the pixel value of the point (x, y) in the output image, and k (x, y) is the pixel value of the point (x, y) in the original image.
6. The mask workpiece identification method based on the template matching according to claim 3, characterized in that: and after image enhancement, texture extraction is carried out by adopting an LBP operator, and the expression is as follows:
Figure FDA0002535850770000043
wherein, p represents the p-th pixel point except the central pixel point in the 3 x 3 window; h (c) a pixel value representing a center pixel point; h (p) represents the pixel value of the p-th pixel point in the neighborhood; s (x) formula is as follows:
Figure FDA0002535850770000044
7. the mask workpiece identification method based on the template matching according to claim 1, characterized in that: the manufacturing of the plurality of standard templates specifically comprises: defining an interested region matched with the image, namely the region where the workpiece is located, of the preprocessed image, extracting the interested region of the obtained image, and taking the obtained interested region as a template; respectively placing workpieces in the same state as the template at different positions, acquiring workpiece images by using kinect v2 to respectively perform matching experiments, determining that the template is available if the workpieces can be matched under various conditions, otherwise, returning to a defined image to match a new region of interest, and if the workpieces cannot be identified, acquiring the workpiece images again; taking the theta angle as an increment, obliquely placing the workpiece on a plane until the theta angle is N times, and respectively shooting the workpiece to obtain N pairs of pictures; preprocessing the N +1 images to obtain N +1 templates; LBP calculation is carried out on the obtained template to obtain a texture image of the template, the texture image is used as a final template image, namely a standard template, and the standard templates are combined to establish a standard template library.
8. The mask workpiece identification method based on the template matching according to claim 7, characterized in that: the similarity degree of the template and the subgraph is represented by R (x, y),
matching the relative value of the template to the mean value of the image based on the standard correlation coefficient, wherein 1 represents that the matching effect is best, 1 represents that the matching effect is worst, and 0 represents that the two have no correlation; let I (x, y) be a target image of size M × N pixels, and T (x, y) be a template image of size M × N pixels; t (x ', y') is a point in the current template, and I (x + x ', y + y') is a point on the target image corresponding to the point; the expression of the degree of similarity R (x, y) is as follows
Figure FDA0002535850770000051
Wherein:
T′(x′,y′)=T(x′,y′)-1/(mn)·∑x″,y″T(x″,y″)
I′(x+x′,y+y′)=
I(x+x′,y+y′)-1/(mn)·∑x″,y″I(x+x″,y+y″);
because the direction of the inclined template in the obtained standard template is unique, image rotation is required for identifying workpieces in different inclined directions;
the image rotation refers to a process of forming a new image by rotating an image by a certain angle by taking a certain point as a center, wherein the point is usually the center of the image; because the rotation is carried out according to the center, and the distance r between the point before and after the rotation and the center is not changed, the corresponding relation between the coordinate of the point after the rotation and the original coordinate is obtained;
assumed point (x)1,y1) Rotated by an angle of theta to a point (x)2,y2) Where a is the angle from the center point of the original image to the x-axis and b is the angle from the center point of the original image to the y-axis, θ can be expressed as a-b, and the following equation is written:
x2=r*cosb=r*cosOa+θ) (20)
y2=r*sinb=r*sin(a+θ) (21)
unfolding to obtain:
x2=r*cosa*cosθ-r*sinθ*sina (22)
y2=r*sina*cosθ+r*sinθ*cosa (23)
namely:
x2=x1*cosθ-y1*sinθ (24)
y2=y1*cosθ+x1*sinθ (25)。
9. the mask workpiece identification method based on the template matching according to claim 1, characterized in that: judging whether a workpiece exists or not through template matching, namely matching the preprocessed texture image with the template,
judging whether matching is required to be carried out according to the similarity R (x, y) by a template matching algorithm based on a standard correlation coefficient, if the current template is not matched, rotating the current template to 360 degrees by taking 10 degrees as increment, sequentially calculating the similarity R (x, y) between the template at each angle and the image, and determining whether matching is required according to the judgment on the size of R (x, y);
when a certain template is matched, outputting a matched area and position coordinates thereof in the image; if the rotated templates are not matched yet, performing the next template, repeating the matching process until the matching is successful, and judging that the target workpiece exists in the region; and if the matching is not successful in all the templates, judging that the target workpiece does not exist in the area.
10. Shielding workpiece recognition system based on template matching is characterized in that: the system comprises an image alignment module, a preprocessing module, a standard template module and a template matching module;
an image alignment module for aligning the depth image and the color image;
the preprocessing module is used for sequentially carrying out preprocessing of bilateral filtering, Laplace enhancement and texture extraction on the aligned color images;
the standard template module is used for manufacturing a plurality of standard templates;
and the template matching module is used for judging whether the workpiece exists or not through standard template matching.
CN202010532393.6A 2020-03-04 2020-06-12 Shielded workpiece identification method based on template matching Active CN111738320B (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010141057 2020-03-04
CN2020101410579 2020-03-04

Publications (2)

Publication Number Publication Date
CN111738320A true CN111738320A (en) 2020-10-02
CN111738320B CN111738320B (en) 2022-12-06

Family

ID=72650121

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010532393.6A Active CN111738320B (en) 2020-03-04 2020-06-12 Shielded workpiece identification method based on template matching

Country Status (1)

Country Link
CN (1) CN111738320B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112893007A (en) * 2021-01-15 2021-06-04 深圳市悦创进科技有限公司 Dispensing system based on machine vision and dispensing method thereof
CN113758439A (en) * 2021-08-23 2021-12-07 武汉理工大学 Method and device for measuring geometric parameters on line in hot ring rolling forming process
CN114549642A (en) * 2022-02-10 2022-05-27 中国科学院上海技术物理研究所 Low-contrast infrared weak and small target detection method
CN115933534A (en) * 2023-02-09 2023-04-07 山东山科世鑫科技有限公司 Numerical control intelligent detection system and method based on Internet of things
CN116309577A (en) * 2023-05-19 2023-06-23 山东晨光胶带有限公司 Intelligent detection method and system for high-strength conveyor belt materials

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050152604A1 (en) * 2004-01-09 2005-07-14 Nucore Technology Inc. Template matching method and target image area extraction apparatus
CN103425988A (en) * 2013-07-03 2013-12-04 江南大学 Real-time positioning and matching method with arc geometric primitives
CN109583461A (en) * 2017-09-28 2019-04-05 沈阳高精数控智能技术股份有限公司 A kind of template matching method based on edge feature
CN110647925A (en) * 2019-09-06 2020-01-03 重庆邮电大学 Rigid object identification method and device based on improved LINE-MOD template matching

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050152604A1 (en) * 2004-01-09 2005-07-14 Nucore Technology Inc. Template matching method and target image area extraction apparatus
CN103425988A (en) * 2013-07-03 2013-12-04 江南大学 Real-time positioning and matching method with arc geometric primitives
CN109583461A (en) * 2017-09-28 2019-04-05 沈阳高精数控智能技术股份有限公司 A kind of template matching method based on edge feature
CN110647925A (en) * 2019-09-06 2020-01-03 重庆邮电大学 Rigid object identification method and device based on improved LINE-MOD template matching

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112893007A (en) * 2021-01-15 2021-06-04 深圳市悦创进科技有限公司 Dispensing system based on machine vision and dispensing method thereof
CN113758439A (en) * 2021-08-23 2021-12-07 武汉理工大学 Method and device for measuring geometric parameters on line in hot ring rolling forming process
CN114549642A (en) * 2022-02-10 2022-05-27 中国科学院上海技术物理研究所 Low-contrast infrared weak and small target detection method
CN114549642B (en) * 2022-02-10 2024-05-10 中国科学院上海技术物理研究所 Low-contrast infrared dim target detection method
CN115933534A (en) * 2023-02-09 2023-04-07 山东山科世鑫科技有限公司 Numerical control intelligent detection system and method based on Internet of things
CN115933534B (en) * 2023-02-09 2023-11-07 山东山科世鑫科技有限公司 Numerical control intelligent detection system and method based on Internet of things
CN116309577A (en) * 2023-05-19 2023-06-23 山东晨光胶带有限公司 Intelligent detection method and system for high-strength conveyor belt materials
CN116309577B (en) * 2023-05-19 2023-08-04 山东晨光胶带有限公司 Intelligent detection method and system for high-strength conveyor belt materials

Also Published As

Publication number Publication date
CN111738320B (en) 2022-12-06

Similar Documents

Publication Publication Date Title
CN111738320B (en) Shielded workpiece identification method based on template matching
WO2018219054A1 (en) Method, device, and system for license plate recognition
CN109410207B (en) NCC (non-return control) feature-based unmanned aerial vehicle line inspection image transmission line detection method
CN111260731B (en) Self-adaptive detection method for checkerboard sub-pixel level corner points
CN105261022B (en) PCB board matching method and device based on outer contour
CN110648367A (en) Geometric object positioning method based on multilayer depth and color visual information
CN106709950B (en) Binocular vision-based inspection robot obstacle crossing wire positioning method
JP6899189B2 (en) Systems and methods for efficiently scoring probes in images with a vision system
CN111739031B (en) Crop canopy segmentation method based on depth information
US20040037467A1 (en) Matching of discrete curves under affine transforms
WO2023060926A1 (en) Method and apparatus for guiding robot positioning and grabbing based on 3d grating, and device
CN111507908A (en) Image correction processing method, device, storage medium and computer equipment
CN110222661B (en) Feature extraction method for moving target identification and tracking
CN108109154A (en) A kind of new positioning of workpiece and data capture method
CN114331879A (en) Visible light and infrared image registration method for equalized second-order gradient histogram descriptor
CN115205286B (en) Method for identifying and positioning bolts of mechanical arm of tower-climbing robot, storage medium and terminal
CN114972458A (en) Method and system for registering visible light and infrared thermal imaging images
CN107680035B (en) Parameter calibration method and device, server and readable storage medium
CN113313725B (en) Bung hole identification method and system for energetic material medicine barrel
CN113689365B (en) Target tracking and positioning method based on Azure Kinect
Han et al. Target positioning method in binocular vision manipulator control based on improved canny operator
CN114936997A (en) Detection method, detection device, electronic equipment and readable storage medium
CN113673515A (en) Computer vision target detection algorithm
CN116594351A (en) Numerical control machining unit system based on machine vision
CN116758266A (en) Reading method of pointer type instrument

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