CN117830336A - Polygonal contour detection method and device based on line scanning camera imaging - Google Patents

Polygonal contour detection method and device based on line scanning camera imaging Download PDF

Info

Publication number
CN117830336A
CN117830336A CN202410239044.3A CN202410239044A CN117830336A CN 117830336 A CN117830336 A CN 117830336A CN 202410239044 A CN202410239044 A CN 202410239044A CN 117830336 A CN117830336 A CN 117830336A
Authority
CN
China
Prior art keywords
image
edge
contour
line
points
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
CN202410239044.3A
Other languages
Chinese (zh)
Other versions
CN117830336B (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.)
Fujian Deshi Technology Group Co ltd
Original Assignee
Fujian Deshi Technology Group 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 Fujian Deshi Technology Group Co ltd filed Critical Fujian Deshi Technology Group Co ltd
Priority to CN202410239044.3A priority Critical patent/CN117830336B/en
Publication of CN117830336A publication Critical patent/CN117830336A/en
Application granted granted Critical
Publication of CN117830336B publication Critical patent/CN117830336B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30164Workpiece; Machine component

Landscapes

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

Abstract

The invention discloses a polygonal contour detection method and a polygonal contour detection device based on line scanning camera imaging, which are characterized in that a target template image and a target image to be identified are obtained, and the coordinates of the target image are corrected according to the coordinates of the target template image to obtain a corrected image; identifying edge contour points in the corrected image, and fitting the edge contour points by taking the vertex coordinates of the target template image as reference coordinates to obtain polygonal edge contour lines; taking the intersection points of the different edge contour lines as vertexes of the correction image, and dividing the edge contour lines forming the vertexes into sub-line segments with preset lengths; acquiring a real contour corresponding to the sub-line segment, and acquiring gradient points according to the real contour; fitting all gradient points to obtain a fitting line, and calculating the vertical distance between each gradient point and the fitting line; acquiring a threshold distance, and marking gradient points with vertical distances larger than the threshold distance as outliers; and integrating all outliers to obtain the edge anomaly range in the corrected image.

Description

Polygonal contour detection method and device based on line scanning camera imaging
Technical Field
The invention relates to the technical field of industrial vision detection, in particular to a polygonal contour detection method and device based on line scanning camera imaging.
Background
In the field of industrial visual inspection, high-precision edge detection has been a great challenge in the industry. The classical edge detection algorithm canny, sobel, laplace can generally have an effective detection effect under parallel backlight imaging. However, considering the actual industrial production environment, currently, more vision detection modules adopt a line scanning camera scheme. Unlike an area array camera, a line scan camera has a visual perspective in only one direction, and has an advantage in handling perspective distortion.
However, the key to the stability of line scan imaging is the stability of line frequency and conveyor belt, especially the constant speed of conveyor belt is difficult to ensure in practical industrial production environments. The hardware cost of the high-precision constant-speed conveyor belt is too high, if the problem of non-constant speed of the conveyor belt is ignored, the measurement precision is rapidly reduced, the error is up to a few pixels, and the subsequent calibration and the precision of a sub-pixel algorithm are affected.
Currently, there are two main flow directions of an integrity detection algorithm for a contour in industrial detection: firstly, a tree-shaped logic judgment is obtained by continuously screening regional characteristics such as roundness and centroid based on morphological processing and intersection sets, and the disadvantage is that the algorithm parameters are relatively bulky along with the increase of the depth width of the tree, and the integrity of an actual contour cannot be well and intuitively quantified. And secondly, based on the thought of a measuring algorithm, the outer contour dimension of a workpiece is strictly measured, and although the measuring algorithm has the basis of unified quantification integrity according to the lengths of the concave and the convex, the result of the algorithm is extremely unstable due to the problems of the line scanning camera on an actual production line.
Disclosure of Invention
The technical problems to be solved by the invention are as follows: the polygonal contour detection method and device based on the line scanning camera imaging are provided, and the detection precision of the line scanning camera on the polygonal contour workpiece is improved.
In order to solve the technical problems, the invention adopts the following technical scheme:
a polygonal contour detection method based on line scan camera imaging, comprising:
acquiring a target template image and a target image to be identified;
correcting the coordinates of the target image according to the coordinates of the target template image to obtain a corrected image;
identifying edge contour points in the corrected image;
fitting the edge contour points by taking the vertex coordinates of the target template image as reference coordinates to obtain edge contour lines of polygons;
taking intersection points of different edge contour lines as vertexes of the correction image, and dividing the edge contour lines forming the vertexes into sub-line segments with preset lengths;
acquiring a real contour corresponding to the sub-line segment, and acquiring gradient points according to the real contour;
fitting all the gradient points to obtain a fitting line, and calculating the vertical distance between each gradient point and the fitting line;
acquiring a threshold distance, and marking the gradient points with the vertical distance larger than the threshold distance as outliers;
and integrating all the outliers to obtain an edge anomaly range in the corrected image.
In order to solve the technical problems, the invention adopts another technical scheme that:
a polygon contour detection device based on line scan camera imaging comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor realizes each step in a polygon contour detection method based on line scan camera imaging when executing the computer program.
The invention has the beneficial effects that: the method comprises the steps of carrying out coordinate correction on coordinates on a target image to be identified through the target template image to obtain a corrected image, carrying out fitting on the coordinates of the corrected image by taking the vertex coordinates of the target template image as a reference, determining the vertex of the corrected image based on an edge contour straight line obtained by fitting, effectively avoiding errors of a line scanning camera on high resolution, enabling the capturing of the vertex to be more accurate, obtaining sub-line segments in a local segmentation mode, avoiding the problem that fitting cannot be carried out due to distortion when the edge contour straight line is longer, further generating a large number of outliers, and finally determining an edge abnormal range in the corrected image based on the determined outliers, thereby improving the detection precision of the line scanning camera on a polygonal contour workpiece.
Drawings
FIG. 1 is a flow chart of steps of a method for detecting a polygonal contour based on line scan camera imaging in an embodiment of the invention;
fig. 2 is a schematic diagram of an extended fitting straight line in a polygon contour detection method based on line scanning camera imaging in an embodiment of the present invention;
FIG. 3 is a schematic diagram of a linear fitting preliminary vertex in a polygonal contour detection method based on line scan camera imaging in an embodiment of the present invention;
FIG. 4 is a schematic diagram of a linear fitting actual vertex in a polygonal contour detection method based on line scan camera imaging in an embodiment of the present invention;
FIG. 5 is a schematic diagram of vertex contour segmentation in a polygon contour detection method based on line scan camera imaging in an embodiment of the present invention;
FIG. 6 is a schematic diagram of outliers of edge dicing in a polygonal contour detection method based on line scan camera imaging in an embodiment of the invention;
FIG. 7 is a schematic edge view of an outlier Gaussian weight capture anomaly in a line-scan camera imaging-based polygonal contour detection method according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a polygon contour detection device based on line scan camera imaging in an embodiment of the present invention.
Detailed Description
In order to describe the technical contents, the achieved objects and effects of the present invention in detail, the following description will be made with reference to the embodiments in conjunction with the accompanying drawings.
In order to describe the technical contents, the achieved objects and effects of the present invention in detail, the following description will be made with reference to the embodiments in conjunction with the accompanying drawings.
Referring to fig. 1, a polygon contour detection method based on line scan camera imaging includes:
acquiring a target template image and a target image to be identified;
correcting the coordinates of the target image according to the coordinates of the target template image to obtain a corrected image;
identifying edge contour points in the corrected image;
fitting the edge contour points by taking the vertex coordinates of the target template image as reference coordinates to obtain edge contour lines of polygons;
taking intersection points of different edge contour lines as vertexes of the correction image, and dividing the edge contour lines forming the vertexes into sub-line segments with preset lengths;
acquiring a real contour corresponding to the sub-line segment, and acquiring gradient points according to the real contour;
fitting all the gradient points to obtain a fitting line, and calculating the vertical distance between each gradient point and the fitting line;
acquiring a threshold distance, and marking the gradient points with the vertical distance larger than the threshold distance as outliers;
and integrating all the outliers to obtain an edge anomaly range in the corrected image.
From the above description, the beneficial effects of the invention are as follows: the method comprises the steps of carrying out coordinate correction on coordinates on a target image to be identified through the target template image to obtain a corrected image, carrying out fitting on the coordinates of the corrected image by taking the vertex coordinates of the target template image as a reference, determining the vertex of the corrected image based on an edge contour straight line obtained by fitting, effectively avoiding errors of a line scanning camera on high resolution, enabling the capturing of the vertex to be more accurate, obtaining sub-line segments in a local segmentation mode, avoiding the problem that fitting cannot be carried out due to distortion when the edge contour straight line is longer, further generating a large number of outliers, and finally determining an edge abnormal range in the corrected image based on the determined outliers, thereby improving the detection precision of the line scanning camera on a polygonal contour workpiece.
Further, before the target template image is acquired, the method includes:
constructing at least one template picture model;
the acquiring the target template image comprises the following steps:
loading all the template picture models;
and matching all the template picture models with the target image according to the graph to obtain the target template image.
According to the description, the corresponding template picture model is constructed before the target image is matched, so that the corresponding template picture can be directly loaded for matching in the detection process, the detection efficiency is improved, and workpieces with larger abnormality can be screened out through matching the template picture model and the target image.
Further, the correcting the coordinates of the target image according to the coordinates of the target template image to obtain a corrected image includes:
matching calculation is carried out on the target template image and the target image through a matching algorithm, and a homography matrix is generated;
and correcting the coordinates of the target image to coordinate points of the target image according to the homography matrix.
From the above description, after the target template image is acquired, a corresponding homography matrix is obtained according to the target template image, and coordinate points from the target image to the target template image are corrected based on the homography matrix, so that measurement at the same position of the image by a subsequent measurement algorithm is facilitated, a large amount of time consumption is reduced, and the detection efficiency is improved.
Further, the generating the homography matrix includes:
acquiring coordinate points matched with the target template image and the target image;
and solving according to the homography matrix calculation formula carried in by the coordinate points to obtain the homography matrix.
From the above description, when the template matching algorithm cannot directly obtain the homography matrix in the matching process, the homography matrix formula can be solved to obtain the homography matrix through the matched key point mapping, so as to realize the correction of the target image which is not matched with the homography matrix.
Further, the fitting the edge contour points by using the vertex coordinates of the target template image as reference coordinates to obtain a polygonal edge contour line includes:
taking the vertex coordinates of the target template image as endpoints, and acquiring the edge contour points positioned between the endpoints in the corrected image;
performing convolution operation on a domain near the edge contour point through a Gaussian filter to obtain an edge denoising image;
calculating the gradient of the image edge in the edge denoising image in the vertical direction to obtain edge gradient points;
and fitting according to the edge gradient points and the end points to obtain the edge contour straight line.
As can be seen from the above description, since there is distortion in the imaging of the target image, the target image and the target template image cannot generally coincide, the template matching result obtains a homography matrix which is only the result of optimal matching, and errors exist between the actual vertex of the corrected image and the vertex of the target template image; therefore, the edge contour line is obtained by fitting the edge contour points on the corrected image by taking the vertex coordinates of the target template image as a reference, the error of the fitting line can be reduced, and the detection precision is improved.
Further, the end points are located between two end points of the edge profile line.
As can be seen from the above description, the vertex coordinates of the target template image are set between two end points of the edge contour line, that is, the edge contour line is adaptively extended in the direction along the vertex coordinates of the target template image, so that the robustness of the edge contour line is improved.
Further, the taking the intersection point of the edge contour lines as the vertex of the correction image includes:
taking the intersection points of the edge contour lines as the preliminary vertexes of the corrected image;
the actual contour of the corrected image is obtained, a circle is made by taking the initial vertex as a circle center, and a first intersection point and a second intersection point which are intersected with the actual contour are obtained;
obtaining a first straight line according to the edge contour straight line and the first intersection point, and obtaining a second straight line according to the edge contour straight line and the second intersection point;
and taking an intersection point of the first straight line and the second straight line as the vertex.
As can be seen from the above description, since the line scan camera images the whole straight line with offset, so that there is a certain error in the polygon vertex constructed based on the edge straight line obtained by fitting, the recognition accuracy of the vertex can be improved by determining the first straight line and the second straight line of the edge by making a circle with the initial vertex as the center of a circle and then determining the vertex again based on the determined first straight line and second straight line.
Further, the dividing the edge contour line forming the vertex into sub-line segments with preset lengths includes:
dividing the edge contour straight line into the sub-line segments with preset lengths by a fixed pixel division or an equal ratio division mode;
judging whether the segmented target sub-line segment reaches the preset length, if not, merging the target sub-line segment with the adjacent sub-line segment.
From the above description, the edge contour line is segmented by using a fixed pixel segmentation or an equal ratio segmentation mode to obtain a plurality of segments of sub-line segments, so that the requirements that global errors are ignored and local errors are highlighted for the integrity of the line scanning imaging edge are met, and the edge detection precision is improved.
Further, the integrating all the outliers to obtain the edge anomaly range in the corrected image includes:
calculating second-order Gaussian weights of all the outliers on the sub-line segment to obtain the Gaussian weights of the sub-line segment;
calculating according to the target template image to obtain a first image edge, and calculating according to the correction image to obtain a second image edge;
comparing the first image edge with the second image edge to obtain a contour region difference set;
matching the profile area difference set with all the sub-line segments to obtain Gaussian weights corresponding to the profile areas;
and acquiring a Gaussian weight threshold, and screening the contour regions in the contour region difference set according to the Gaussian weight threshold to obtain the edge anomaly range.
As can be seen from the above description, the difference set of the contour region is obtained by making the difference set between the first image edge and the second image edge, and the gaussian weight of each sub-line segment is used as the gaussian weight of the corresponding contour region; because a large number of fragment areas exist in the profile area difference set, one part is a real profile concave or convex area, the other part is caused by different stretching and twisting of two images on line scanning imaging, and the profile areas are screened through Gaussian weight threshold values, so that the real profile convex-concave areas can be effectively screened out, namely, the areas with abnormal profiles can be determined.
Another embodiment of the present invention provides a polygon contour detection apparatus based on line scan camera imaging, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements each step in a polygon contour detection method based on line scan camera imaging as described above when executing the computer program.
The polygonal contour detection method and device based on line scanning camera imaging can be applied to edge contour integrity detection of workpieces, such as edge integrity detection of a flash instrument and edge integrity detection of a silicon wafer, and are described in the following by specific embodiments:
example 1
Referring to fig. 1, a polygonal contour detection method based on line scan camera imaging includes a model preprocessing portion and a detection portion, wherein the model preprocessing portion is only executed when modification is needed to be performed on a model, such as an increase of the model, a modification of a model size, etc., for integrating necessary loading and calculation redundancy of the detection portion, without executing a model preprocessing step at each detection; the detection part is the necessary step for single detection.
The model preprocessing comprises the following steps:
s0, constructing at least one template picture model; considering the positioning problem of any polygonal complex shape, adopting a template matching algorithm to match one or more template picture models with a target image, and realizing the preliminary positioning of the target image; for example, the template picture model includes a pentagonal image, a hexagonal image, a heptagonal image, or includes a plurality of different types of pentagonal images; when the target image is a pentagon image, matching the pentagon template image model of the corresponding type; because a certain time is required to construct the template picture model, the time consumption for subsequent detection can be reduced by creating the template picture model in a preprocessing step; the model selection of the template picture model and the actual workpiece and detection beat are determined, most of the workpieces can be satisfied based on the template matching model of the outline, and more complicated models based on descriptors can be tried, for example: sift, surf realization; the method is simple or has higher requirement on the beat, and can also be realized by using corner detection harris or generalized Hough change; after the construction of the template picture model is completed, the coordinates of the point positions of the vertex angles of the outer outline of the template picture model are recorded and used as the measurement basis for the subsequent positioning of the target image.
The detection part comprises the following steps:
s1, acquiring a target template image and a target image to be identified, and specifically: loading all the template picture models; matching all the template picture models with the target image to obtain the target template image; meanwhile, in the matching process, the matching efficiency can be improved by introducing a feature pyramid or setting the limitation of the matching homopolar or heteropolar stretching.
S2, correcting the coordinates of the target image according to the coordinates of the target template image to obtain a corrected image, and specifically:
s21, carrying out matching calculation on the target template image and the target image through a matching algorithm to generate a homography matrix; wherein, the ways of obtaining homography matrix by different matching algorithms are different; and when the algorithm can not acquire the homography matrix in the process of matching the key points, the homography matrix is needed to be solved by adopting a parameter carrying-in method according to the matched key point pairs, namely after the coordinate points matched with the target template image and the target image are needed to be acquired, the homography matrix is obtained by carrying-in the homography matrix calculation formula according to the coordinate points, and the specific formula is as follows:
wherein H is a homography matrix of 3x 3; simplifying the formula to obtain the following components:
for example, α=1/H33, the actual degree of freedom of H is 8, and a minimum of four sets of key points are required for solving; more key points can be better fitted, and accuracy and stability are improved.
S22, correcting the coordinates of the target image to coordinate points of the target image according to the homography matrix; the coordinate points from the target graph to the template graph are corrected according to the homography matrix, so that measurement can be carried out on the same position of the image by a subsequent measurement algorithm, and a large amount of time consumption is reduced; meanwhile, in the embodiment, the correction is performed before contour detection, so that the subsequent detection time can be reduced, and the algorithm performance can be improved.
S3, identifying edge contour points in the corrected image;
s4, fitting the edge contour points by taking the vertex coordinates of the target template image as reference coordinates to obtain polygonal edge contour lines, and specifically:
s41, taking the vertex coordinates of the target template image as endpoints, and acquiring the edge contour points positioned between the endpoints in the corrected image; taking scattered points from straight lines formed by adjacent vertexes to be used as fitting of the straight lines;
s42, performing convolution operation on the domain near the edge contour point through a Gaussian filter to obtain an edge denoising image;
s43, calculating gradients in the vertical direction of the image edges in the edge denoising image to obtain edge gradient points; calculating gradients in the vertical direction of the image edges in the edge denoising image on the basis of a sobel operator, for example, so as to obtain gradient points; after the gradient points are obtained, abnormal gradient points are further removed according to a ransac algorithm, and the effective edge gradient points are obtained;
s44, fitting according to the edge gradient points and the end points to obtain the edge contour straight line; wherein the end points are positioned between two end points of the edge contour straight line in order to improve the robustness of the fitting straight line; referring to fig. 2, the straight line to be fitted is extended.
S5, taking intersection points of different edge contour lines as vertexes of the correction image, and dividing the edge contour lines forming the vertexes into sub-line segments with preset lengths, wherein the sub-line segments are specifically as follows:
s51, taking intersection points of different edge contour lines as preliminary vertexes of the corrected image; referring to fig. 3, since the whole line imaged by the line scanning camera is offset, that is, there is an error in polygon vertices constructed by the whole line, the intersection points obtained by the fitted polygon lines are used as preliminary vertices; as shown in fig. 3, the solid line represents the actual contour of the workpiece under enlargement, the dotted line represents the edge contour line obtained in step S44, and the workpiece has fragments and distortions due to global fitting, so that the intersection point obtained by the two edge contour lines is not an actual vertex, and is taken as a preliminary vertex;
s52, acquiring an actual contour of the corrected image, and making a circle by taking the initial vertex as a circle center to obtain a first intersection point and a second intersection point which are intersected with the actual contour; referring to fig. 4, an otsu algorithm is adopted to segment and correct an actual contour of an image, and then a preliminary vertex (i.e. an intersection point of dot-dashed lines in the image) is used to make a circle, so as to obtain an intersection point of the circle and the actual contour, such as two groups of small crosses in fig. 4;
s53, obtaining a first straight line according to the edge contour straight line and the first intersection point, and obtaining a second straight line according to the edge contour straight line and the second intersection point; as shown in fig. 4, the straight line fitting is performed again within the range of the dotted line to obtain a first straight line and a second straight line, which are indicated by dotted lines in fig. 4; wherein the arrow represents the direction of gradient detection;
s54, taking an intersection point of the first straight line and the second straight line as the vertex; the intersection point of the two groups of straight lines is the actual intersection point, such as a large cross in fig. 4;
after the actual accurate vertex is obtained, the global error is ignored due to the integrity of the line scanning imaging edge, and the local error is highlighted; in this embodiment, the local error is highlighted by means of a linear dicing formed by the actual vertices, specifically: referring to fig. 5, the edge contour line is divided into the sub-line segments with a predetermined length by means of fixed pixel division or equal ratio division; and meanwhile, judging whether the segmented target sub-line segment reaches the preset length, if not, merging the target sub-line segment with the adjacent sub-line segment, namely merging sub-line segments with insufficient length.
S6, acquiring a real contour corresponding to the sub-line segment, and obtaining gradient points according to the real contour; after calculating the outline of the target image by adopting an otsu algorithm in an optional implementation manner, obtaining the corresponding real outline of each sub-line segment further based on the outline of the target image; referring to fig. 6, the left solid line is the real outline of the workpiece, and the dotted line and the dashed line are the sub-line segments after dicing; as shown in fig. 6, the sub-line segments capture the abnormal contour of the workpiece according to the arrow direction, and the dots in the figure represent gradient points.
S7, fitting all the gradient points to obtain fitting lines, and calculating the vertical distance between each gradient point and each fitting line; as shown in the right part of fig. 6, a vertical straight line is a fitting line; the horizontal straight line is the distance from each gradient point to the fitted line.
S8, acquiring a threshold distance, and marking the gradient points with the vertical distance larger than the threshold distance as outliers; for example, if the threshold distance is set to 3, all gradient points with the vertical distance greater than 3 are marked as outliers, and the smaller the set threshold distance value, the higher the integrity requirement on the edge profile.
S9, integrating all the outliers to obtain an edge anomaly range in the corrected image, and specifically:
s91, calculating second-order Gaussian weights of all the outliers on the sub-line segment to obtain the Gaussian weights of the sub-line segment; because the range that the workpiece has edge abnormality is represented after all outliers are integrated, the second-order Gaussian distribution weights of the outliers are calculated, and the weights of all the outliers are overlapped for subsequent screening;
s92, calculating to obtain a first image edge according to the target template image, and calculating to obtain a second image edge according to the correction image; obtaining a region complement or salient to the target template image through morphology and intersection set; wherein morphology comprises: calculating a first image edge contour by using an otsu algorithm of the target template image, calculating a second image edge contour, and filling by a closed operation;
s93, comparing the first image edge with the second image edge to obtain a contour region difference set; referring to fig. 7, a large number of fragment areas are obtained after the difference set of the contour areas is obtained, wherein one part is a true contour concave or convex area, and the other part is caused by different stretching and twisting of two images on the line scan image; as shown in fig. 7, the solid line in the left side portion is the template workpiece profile, and the dotted line and the dashed line are the target workpiece profile; after the difference processing, such as the right part, besides the real abnormal broken piece area, the long and narrow area with more fragments is captured, so that the further broken piece area is needed to obtain the real contour convex-concave area;
s94, matching the contour region difference set with all the sub-line segments to obtain Gaussian weights corresponding to the contour regions; as shown in fig. 7, the gaussian weights corresponding to different regions are obtained;
s95, acquiring a Gaussian weight threshold, and screening the contour regions in the contour region difference set according to the Gaussian weight threshold to obtain the edge anomaly range; for example, a Gaussian weight threshold of 0.2; three contour regions with gaussian weight values of 0.3, 0.5 and 0.7 are screened out, namely the three regions are edge anomaly ranges.
Example two
Referring to fig. 8, a polygon contour detection apparatus based on line scan camera imaging includes a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of a polygon contour detection method based on line scan camera imaging as described in the first embodiment when executing the computer program.
In summary, according to the polygon contour detection method and device based on line scanning camera imaging provided by the invention, firstly, a model is constructed in a preprocessing step, a target image is initially positioned by using the constructed template picture model, workpieces with certain stretching and twisting can be robustly matched, workpieces with larger anomalies are screened out, a rough homography rectangle is provided so as to correct the target image, and time is saved for a subsequent measurement algorithm; in the detection process, the vertex acquisition adopts global measurement and local measurement, a preliminary polygon vertex is found through a measurement algorithm, and then an accurate vertex is obtained through local measurement, so that errors of a line scanning camera on high resolution can be effectively avoided, and the capturing of the vertex is more accurate; the sub line segments are obtained in a local segmentation mode, so that the problem that the sub line segments cannot be fitted due to distortion when the edge contour line is long is avoided, and a large number of outliers are generated to be misjudged; finally, the Gaussian weight superposition design of outliers is adopted to screen the fragment area processed by morphological intersection and union, so that logic judgment of similar area feature decision trees can be avoided, interference of image distortion is avoided, and screening precision and efficiency are improved.
The foregoing description is only illustrative of the present invention and is not intended to limit the scope of the invention, and all equivalent changes made by the specification and drawings of the present invention, or direct or indirect application in the relevant art, are included in the scope of the present invention.

Claims (10)

1. A polygonal contour detection method based on line scan camera imaging, comprising:
acquiring a target template image and a target image to be identified;
correcting the coordinates of the target image according to the coordinates of the target template image to obtain a corrected image;
identifying edge contour points in the corrected image;
fitting the edge contour points by taking the vertex coordinates of the target template image as reference coordinates to obtain edge contour lines of polygons;
taking intersection points of different edge contour lines as vertexes of the correction image, and dividing the edge contour lines forming the vertexes into sub-line segments with preset lengths;
acquiring a real contour corresponding to the sub-line segment, and acquiring gradient points according to the real contour;
fitting all the gradient points to obtain a fitting line, and calculating the vertical distance between each gradient point and the fitting line;
acquiring a threshold distance, and marking the gradient points with the vertical distance larger than the threshold distance as outliers;
and integrating all the outliers to obtain an edge anomaly range in the corrected image.
2. The method for detecting a polygonal contour based on line scan camera imaging according to claim 1, wherein before the capturing of the target template image, the method comprises:
constructing at least one template picture model;
the acquiring the target template image comprises the following steps:
loading all the template picture models;
and matching all the template picture models with the target image according to the graph to obtain the target template image.
3. The method of claim 1, wherein correcting the coordinates of the target image according to the coordinates of the target template image to obtain a corrected image comprises:
matching calculation is carried out on the target template image and the target image through a matching algorithm, and a homography matrix is generated;
and correcting the coordinates of the target image to coordinate points of the target image according to the homography matrix.
4. A method of polygonal contour detection based on line scan camera imaging as in claim 3, wherein generating a homography matrix comprises:
acquiring coordinate points matched with the target template image and the target image;
and solving according to the homography matrix calculation formula carried in by the coordinate points to obtain the homography matrix.
5. The method for detecting a polygonal contour based on line scan camera imaging according to claim 1, wherein the fitting the edge contour points to obtain a polygonal edge contour line by using the vertex coordinates of the target template image as reference coordinates comprises:
taking the vertex coordinates of the target template image as endpoints, and acquiring the edge contour points positioned between the endpoints in the corrected image;
performing convolution operation on a domain near the edge contour point through a Gaussian filter to obtain an edge denoising image;
calculating the gradient of the image edge in the edge denoising image in the vertical direction to obtain edge gradient points;
and fitting according to the edge gradient points and the end points to obtain the edge contour straight line.
6. The method of claim 5, wherein the end points are located between two end points of the edge profile line.
7. The method of claim 1, wherein the step of using the intersection points of the edge contour lines as the vertices of the corrected image comprises:
taking the intersection points of the edge contour lines as the preliminary vertexes of the corrected image;
the actual contour of the corrected image is obtained, a circle is made by taking the initial vertex as a circle center, and a first intersection point and a second intersection point which are intersected with the actual contour are obtained;
obtaining a first straight line according to the edge contour straight line and the first intersection point, and obtaining a second straight line according to the edge contour straight line and the second intersection point;
and taking an intersection point of the first straight line and the second straight line as the vertex.
8. The method of claim 1, wherein the dividing the edge contour line constituting the vertex into sub-line segments of a predetermined length comprises:
dividing the edge contour straight line into the sub-line segments with preset lengths by a fixed pixel division or an equal ratio division mode;
judging whether the segmented target sub-line segment reaches the preset length, if not, merging the target sub-line segment with the adjacent sub-line segment.
9. The method of claim 1, wherein said integrating all of said outliers to obtain an edge anomaly range in said corrected image comprises:
calculating second-order Gaussian weights of all the outliers on the sub-line segment to obtain the Gaussian weights of the sub-line segment;
calculating according to the target template image to obtain a first image edge, and calculating according to the correction image to obtain a second image edge;
comparing the first image edge with the second image edge to obtain a contour region difference set;
matching the profile area difference set with all the sub-line segments to obtain Gaussian weights corresponding to the profile areas;
and acquiring a Gaussian weight threshold, and screening the contour regions in the contour region difference set according to the Gaussian weight threshold to obtain the edge anomaly range.
10. A line scan camera imaging based polygon contour detection apparatus comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor, when executing the computer program, performs the steps of a line scan camera imaging based polygon contour detection method as claimed in any one of claims 1-9.
CN202410239044.3A 2024-03-04 2024-03-04 Polygonal contour detection method and device based on line scanning camera imaging Active CN117830336B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410239044.3A CN117830336B (en) 2024-03-04 2024-03-04 Polygonal contour detection method and device based on line scanning camera imaging

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410239044.3A CN117830336B (en) 2024-03-04 2024-03-04 Polygonal contour detection method and device based on line scanning camera imaging

Publications (2)

Publication Number Publication Date
CN117830336A true CN117830336A (en) 2024-04-05
CN117830336B CN117830336B (en) 2024-06-14

Family

ID=90504306

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410239044.3A Active CN117830336B (en) 2024-03-04 2024-03-04 Polygonal contour detection method and device based on line scanning camera imaging

Country Status (1)

Country Link
CN (1) CN117830336B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090109195A1 (en) * 2007-10-26 2009-04-30 Kent Joel C Method and apparatus for laplace constrained touchscreen calibration
CN102938066A (en) * 2012-12-07 2013-02-20 南京大学 Method for reconstructing outer outline polygon of building based on multivariate data
US20170076169A1 (en) * 2011-10-17 2017-03-16 Sharp Laboratories of America (SLA), Inc. System and Method for Scanned Document Correction
CN109544575A (en) * 2018-11-15 2019-03-29 西北工业大学 One kind being based on the matched method for reconstructing 3 D contour of ISAR sequence polygon
CN110992326A (en) * 2019-11-27 2020-04-10 江苏理工学院 QFN chip pin image rapid inclination correction method
CN112750107A (en) * 2021-01-11 2021-05-04 齐鲁工业大学 Spherical workpiece identification method and system based on contour edge number fitting and convex hull processing
CN115131587A (en) * 2022-08-30 2022-09-30 常州铭赛机器人科技股份有限公司 Template matching method of gradient vector features based on edge contour
CN116958515A (en) * 2023-09-20 2023-10-27 苏州凌云光工业智能技术有限公司 Fitting positioning method and device for workpiece contour and storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090109195A1 (en) * 2007-10-26 2009-04-30 Kent Joel C Method and apparatus for laplace constrained touchscreen calibration
US20170076169A1 (en) * 2011-10-17 2017-03-16 Sharp Laboratories of America (SLA), Inc. System and Method for Scanned Document Correction
CN102938066A (en) * 2012-12-07 2013-02-20 南京大学 Method for reconstructing outer outline polygon of building based on multivariate data
CN109544575A (en) * 2018-11-15 2019-03-29 西北工业大学 One kind being based on the matched method for reconstructing 3 D contour of ISAR sequence polygon
CN110992326A (en) * 2019-11-27 2020-04-10 江苏理工学院 QFN chip pin image rapid inclination correction method
CN112750107A (en) * 2021-01-11 2021-05-04 齐鲁工业大学 Spherical workpiece identification method and system based on contour edge number fitting and convex hull processing
CN115131587A (en) * 2022-08-30 2022-09-30 常州铭赛机器人科技股份有限公司 Template matching method of gradient vector features based on edge contour
CN116958515A (en) * 2023-09-20 2023-10-27 苏州凌云光工业智能技术有限公司 Fitting positioning method and device for workpiece contour and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
何长海;许增朴;王永强;周聪玲;: "一种基于双目视觉的奥制齿轮刀具参数测量方法", 传感器与微***, no. 10, 20 October 2015 (2015-10-20) *
唐敏;李永树;王生明;: "基于无人机影像的畸变校正研究", 激光与光电子学进展, no. 06, 10 June 2013 (2013-06-10) *

Also Published As

Publication number Publication date
CN117830336B (en) 2024-06-14

Similar Documents

Publication Publication Date Title
CN109003258B (en) High-precision sub-pixel circular part measuring method
CN111260731B (en) Self-adaptive detection method for checkerboard sub-pixel level corner points
CN108898147B (en) Two-dimensional image edge flattening method and device based on angular point detection
US9704232B2 (en) Stereo vision measurement system and method
CN113344931B (en) Plug-in visual detection and identification method, readable storage medium and device
CN114494045B (en) Large spur gear geometric parameter measurement system and method based on machine vision
CN115170669B (en) Identification and positioning method and system based on edge feature point set registration and storage medium
JP6899189B2 (en) Systems and methods for efficiently scoring probes in images with a vision system
CN112233116B (en) Concave-convex mark visual detection method based on neighborhood decision and gray level co-occurrence matrix description
CN115096206B (en) High-precision part size measurement method based on machine vision
CN112686920A (en) Visual measurement method and system for geometric dimension parameters of circular part
CN107356213B (en) Optical filter concentricity measuring method and terminal equipment
CN112330678A (en) Product edge defect detection method
CN116958125B (en) Electronic contest host power supply element defect visual detection method based on image processing
CN111354047A (en) Camera module positioning method and system based on computer vision
CN107680035B (en) Parameter calibration method and device, server and readable storage medium
CN109148433B (en) Method and apparatus for determining dimensions of an integrated circuit device
CN112419225B (en) SOP type chip detection method and system based on pin segmentation
CN117830336B (en) Polygonal contour detection method and device based on line scanning camera imaging
JP2012203731A (en) Device and method for detecting rotation angle from normal position of image
CN117372498A (en) Multi-pose bolt size measurement method based on three-dimensional point cloud
JP5136108B2 (en) 3D shape measuring method and 3D shape measuring apparatus
CN113592962B (en) Batch silicon wafer identification recognition method based on machine vision
JPH1196372A (en) Method and device for processing image and recording medium of control program for image processing
CN114120320A (en) Image multi-target information identification method, system and medium

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