A method for positioning a semi-transparent workpiece target based on machine vision
Patent Information
- Application Number
- CN202410405720.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-07
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2044-04-07
AI Technical Summary
[0003]第一种方式为将图像从RGB色彩空间(Red,Green,Blue,红,绿,蓝)转至HSV色彩空间(Hue,Saturation,Value,色相,饱和度,明度),并针对HSV色彩空间下手动调节给定三个阈值范围并进行二值化,当存在符合待检测部分大小的前景区域时判定为找到待检测部分,但是这种方式在待检测部分被工件中的其他部分遮挡或者有其他相似部分混淆时提取效果较差
[0047]本方案中,考虑到HSV色彩空间不可避免地对光照不均匀问题鲁棒性不强,通过上述基于部分形状的筛选设置可以进一步提高在光照不均匀、目标待检测部分与目标工件中的其他部分出现混淆或遮挡的情况下,对目标待检测部分的提取准确率。
Smart Images

Figure CN118096889B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of workpiece inspection technology, and more specifically, to a method for locating semi-transparent workpiece targets based on machine vision. Background Technology
[0002] In the integrity inspection of semi-transparent workpieces, the following methods are mainly used to identify and extract the part to be inspected from the image including the workpiece:
[0003] The first method involves converting the image from the RGB color space (Red, Green, Blue) to the HSV color space (Hue, Saturation, Value), manually adjusting three given threshold ranges for the HSV color space, and then binarizing it. When a foreground region matching the size of the part to be detected exists, it is considered that the part to be detected has been found. However, this method has poor extraction performance when the part to be detected is occluded by other parts of the workpiece or is confused by other similar parts.
[0004] The second approach is template matching, which involves matching the acquired workpiece image with a template image and calculating the similarity between the two images in the current orientation to identify the complete part to be detected. However, the orientation of the part to be detected in the workpiece is usually varied, which means that these template matching methods need to perform corresponding image matching steps in a considerable number of directions, making this approach very time-consuming and inefficient.
[0005] The third approach involves applying deep learning methods such as BP neural networks or other machine learning methods to the integrity extraction process of the component to be detected. However, this approach requires training with a large number of sample datasets in advance, and its performance is often poor when the training samples are not large enough.
[0006] Furthermore, the area to be detected in the image may have uneven lighting, which poses a challenge to complete extraction and detection. Therefore, how to provide an effective solution to achieve complete extraction of the area to be detected in a semi-transparent workpiece is an urgent problem to be solved. Summary of the Invention
[0007] The problem solved by this invention is to provide a machine vision-based method for locating semi-transparent workpiece targets, which effectively improves the accuracy of extracting the target to be detected part and has good robustness.
[0008] To address the above problems, this invention provides a machine vision-based method for locating semi-transparent workpiece targets, comprising:
[0009] A first image is determined based on the original image, which includes only the target workpiece, wherein the target workpiece includes the target part to be extracted and detected.
[0010] The first image is converted from the RGB color space to the HSV color space to obtain the second image;
[0011] The second image is subjected to brightness threshold binarization to obtain the first extraction region;
[0012] Based on the feature parameters of the target to be detected, determine whether the first extraction region includes the complete target to be detected;
[0013] If not, the second image is processed based on a preset brightness linear enhancement strategy to obtain the first suspected region;
[0014] The second image is processed according to a preset partial shape-based filtering strategy to obtain a second suspected region;
[0015] When it is determined that the first suspected region and the second suspected region are not the same region, a second extraction region is determined based on the first suspected region, the second suspected region and a preset frequency domain feature filtering strategy, so as to determine whether the second extraction region includes the complete target to be detected part based on the feature parameters.
[0016] The beneficial effects of this invention are as follows: A preset brightness linear enhancement strategy can effectively reduce the impact of uneven illumination on the extraction effect of the target area to be detected; a preset partial shape-based screening strategy can effectively reduce the impact of occlusion of the target area to be detected or confusion caused by other similar parts in the target workpiece on the extraction effect; and a preset frequency domain feature screening strategy is set to process suspected areas determined by various methods to determine the second extraction area. Therefore, this scheme effectively improves the accuracy of extracting the target area to be detected, and performs well even when the target area to be detected has uneven illumination, occlusion, or confusion. It has good robustness, is suitable for various applications, and has high processing efficiency.
[0017] Furthermore, a first image, comprising only the target workpiece, is determined based on the original image, including:
[0018] The ROI region is extracted from the original image based on a preset Canny threshold used to extract the outer edge of the target workpiece;
[0019] The ROI region is dilated to obtain a first image that includes the complete outer edge of the target workpiece.
[0020] Furthermore, when the target to be detected is a square component, determining that the first extraction region does not include the complete target to be detected based on the feature parameters of the target to be detected includes:
[0021] Determine the aspect ratio, rectangularity, density, and number of corner points of the structure corresponding to the target part to be detected within the first extraction area;
[0022] Determine whether the first, second, third, and fourth conditions are all met. The first condition is that the aspect ratio is the same as the target aspect ratio of the target to be detected within a first tolerance range. The second condition is that the rectangularity is the same as the target rectangularity of the target to be detected within a second tolerance range. The third condition is that the density is the same as the target density of the target to be detected within a third tolerance range. The fourth condition is that the number of corner points is less than a preset corner point number threshold.
[0023] If not, it is determined that the first extraction region does not include the complete target to be detected portion.
[0024] In this solution, the above settings can reliably determine whether the extracted area includes the complete target to be detected.
[0025] Furthermore, the second image is processed based on a preset brightness linear enhancement strategy to obtain a first suspected region, including:
[0026] Determine the original brightness value of each pixel in the second image and the corresponding brightness threshold of the second image;
[0027] The new brightness value of each pixel is determined based on the preset brightness linear enhancement factor, the preset proportional coefficient representing the brightness range of linear enhancement, the original brightness value, and the brightness threshold, so as to obtain the third image after brightness linear enhancement.
[0028] The position corresponding to the maximum L2 norm in the third image is determined as the reference position;
[0029] The polygonal neighborhood of the reference position is determined as the first suspected region.
[0030] In this solution, when there is no significant color difference between the target part to be detected and other parts of the target workpiece, the influence of uneven lighting on the extraction effect can be reduced by setting the above-mentioned linear brightness enhancement strategy. The L2 norm is used to find the reference position and then determine the polygonal neighborhood of the reference position as the first suspected area, which can solve the problem of contour adhesion caused by confusion or occlusion between the target part to be detected and other parts of the target workpiece.
[0031] Furthermore, determining the new brightness value of each pixel based on a preset brightness linear enhancement factor, a preset proportional coefficient representing the brightness range of linear enhancement, the original brightness value, and the brightness threshold includes:
[0032] The new brightness value of each pixel is determined based on the first preset relationship;
[0033] The first preset relation is:
[0034]
[0035] Wherein, newValue is the new brightness value, oldValue is the original brightness value, factor is the preset brightness linear enhancement factor, threshold is the brightness threshold, and range is the preset proportional coefficient representing the range of linearly enhanced brightness.
[0036] Furthermore, before determining the position corresponding to the maximum L2 norm in the third image as the reference position, the process also includes:
[0037] The third image is subjected to brightness threshold binarization to obtain the fourth image;
[0038] The fourth image is then filled with holes to obtain the fifth image;
[0039] Determining the position corresponding to the maximum L2 norm in the third image as the reference position includes:
[0040] The position corresponding to the maximum value of the L2 norm in the fifth image is determined as the reference position.
[0041] In this solution, considering that linear brightness enhancement may cause contour adhesion between the target part to be detected and other parts of the target workpiece, the above settings can eliminate the influence of contour adhesion on the subsequent determination of whether the extraction area includes the complete target part to be detected, so as to better extract the target part to be detected.
[0042] Furthermore, when the target to be detected part has a right-angled contour, the second image is processed according to a preset partial shape-based screening strategy to obtain a second suspected region, including:
[0043] All line pairs in the second image are determined according to the line pair recognition strategy. The line pair is two perpendicular lines within the allowable error range.
[0044] For each pair of lines, determine the average brightness of the line connecting the midpoints of the two lines in the pair.
[0045] Non-maximum suppression screening is performed based on the mean brightness values of each line to determine the unique straight line pair.
[0046] The unique straight line pair is processed according to the aspect ratio of the target to be detected and the preset polygon construction strategy to obtain the minimum bounding rotation polygon, and then the area enclosed by the minimum bounding rotation polygon is determined as the second suspected area.
[0047] In this solution, considering that the HSV color space is inevitably not very robust to uneven lighting, the above-mentioned partial shape-based filtering settings can further improve the extraction accuracy of the target part in cases of uneven lighting, confusion or occlusion between the target part and other parts of the target workpiece.
[0048] Furthermore, based on the line pair recognition strategy, all line pairs in the second image are determined, including:
[0049] The Sobel operator is used to extract all the outer contours of the second image;
[0050] The Hough transform is used to extract the straight lines in the outer contour;
[0051] A sliding window with an aspect ratio greater than that of the target portion to be detected is determined;
[0052] The second image is traversed using the sliding window to determine all pairs of straight lines in the second image.
[0053] In this solution, compared with template matching schemes based on complete shapes, the partial shape-based filtering strategy provided in this application essentially uses edge extraction and straight line transformation to find partial right-angle contours for filtering. Therefore, regardless of whether the target to be detected has uneven lighting or is confused or occluded, the solution provided in this application has better robustness.
[0054] Furthermore, the unique line pair is processed according to the aspect ratio of the target to be detected and a preset polygon construction strategy to obtain the minimum circumscribed rotation polygon, including:
[0055] For the unique pair of straight lines, construct a rotated polygon with an aspect ratio greater than that of the target portion to be detected;
[0056] Determine all corner points within the rotated polygon;
[0057] Construct a convex hull based on the corner points, so as to construct a minimum circumscribed rotation polygon using the convex hull.
[0058] Furthermore, a second extraction region is determined based on the first suspected region, the second suspected region, and a preset frequency domain feature filtering strategy, including:
[0059] Determine the intersection-union ratio between the first suspected region and the second suspected region;
[0060] Non-maximum suppression processing is performed based on the intersection-union ratio to determine P regions to be evaluated, where P is an integer not less than 1;
[0061] For the i-th region to be evaluated, where 1 ≤ i ≤ P and i is an integer, perform the following steps:
[0062] The score of the i-th region to be evaluated is determined based on the second preset relation.
[0063] The second preset relation is:
[0064]
[0065] mark i F represents the score of the i-th region to be evaluated. i (u,v) represents the gray value of the i-th region to be evaluated at position (u,v) in the spectrum, and F i (u,v) is determined based on the third preset relation, M i N represents the row number of the spectrum graph corresponding to the i-th region to be evaluated. i Let be the number of columns corresponding to the spectrum of the i-th region to be evaluated;
[0066] The third preset relation is:
[0067]
[0068] I i (x,y) represents the gray value of the i-th region to be evaluated at position (x,y) in the grayscale image, S i Q represents the row number of the grayscale image corresponding to the i-th region to be evaluated. i This represents the column number corresponding to the grayscale image of the i-th region to be evaluated;
[0069] The region with the lowest score is identified as the second extraction region.
[0070] In this scheme, considering that the texture changes on the surface of a semi-transparent workpiece are not obvious, the low-frequency part of the spectrum may have high energy. With the above settings, the unique second extraction area that is closest to the target part to be detected can be reliably determined based on the first suspected area and the second suspected area. Attached Figure Description
[0071] Figure 1 A flowchart illustrating a machine vision-based method for locating semi-transparent workpiece targets, provided by this invention;
[0072] Figure 2This invention provides a structural schematic diagram of a semi-transparent workpiece;
[0073] Figure 3 This invention provides a schematic diagram characterizing the texture of a target to be detected and including corner points.
[0074] Figure 4 This invention provides a schematic diagram characterizing the texture of similar parts in a target workpiece and including corner points.
[0075] Figure 5 This is a schematic diagram illustrating the processing results of the target detection portion in a first image, the target detection portion in a second image, and the target detection portion in a third image, provided by the present invention.
[0076] Figure 6 This invention provides a schematic diagram of the target detection portion in a fourth image and the processing result of the target detection portion in a fifth image after hole filling processing.
[0077] Figure 7 This invention provides a schematic diagram of the extraction results of a first suspected region.
[0078] Figure 8 A schematic diagram of an ideal straight line pair in a target to be detected, provided by the present invention;
[0079] Figure 9 This invention provides a corresponding schematic diagram of the original target to be detected, the grayscale image of the target to be detected, and the spectrum image of the target to be detected;
[0080] Explanation of reference numerals in the attached figures:
[0081] 1-Target part to be detected, 2-Semi-transparent tube, 3-Similar part, 4-Band, 11-Corner point in the target part to be detected, 31-Corner point in the similar part, 111-Circular neighborhood. Detailed Implementation
[0082] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0083] Please refer to Figure 1 , Figure 1 The flowchart illustrates a machine vision-based method for locating semi-transparent workpiece targets, as provided in this invention.
[0084] This invention provides an embodiment of a machine vision-based method for locating semi-transparent workpiece targets, comprising:
[0085] S11: Determine a first image based on the original image, which includes only the target workpiece, and the target workpiece includes the target detection part 1 to be extracted;
[0086] S12: Perform a conversion process from RGB color space to HSV color space on the first image to obtain the second image;
[0087] S13: Perform brightness threshold binarization on the second image to obtain the first extraction region;
[0088] S14: Determine whether the first extraction region includes the complete target detection part 1 based on the feature parameters of the target detection part 1; if not, proceed to S15;
[0089] S15: Process the second image based on a preset brightness linear enhancement strategy to obtain the first suspected region;
[0090] S16: Process the second image according to a preset partial shape-based filtering strategy to obtain the second suspected region;
[0091] S17: When it is determined that the first suspected region and the second suspected region are not the same region, the second extraction region is determined according to the first suspected region, the second suspected region and the preset frequency domain feature screening strategy, so as to determine whether the second extraction region includes the complete target to be detected part 1 according to the feature parameters.
[0092] Specifically, an original image is acquired, which includes the target workpiece and other structures such as a conveyor belt. Therefore, according to S11, a first image is determined. The first image includes the target detection part 1 to be extracted. It should be noted that the target workpiece here can be a semi-transparent workpiece. Please refer to [reference needed]. Figure 2 , Figure 2 This is a schematic diagram of a semi-transparent workpiece provided by the present invention. The workpiece includes a target part to be detected 1, a semi-transparent tube 2, and a similar part 3 connected in sequence. The semi-transparent workpiece is fastened by a strap 4. It can be seen that the target part to be detected 1 is a rectangular structure with a straight outline, and the similar part 3 is similar to it. In practical applications, the first image including the target part to be detected 1 may have problems such as uneven lighting, the target part to be detected 1 being obscured, or confusion between the target part to be detected and the similar part 3.
[0093] Understandably, when there is a significant color difference between the target part to be detected 1 and other parts of the target workpiece, after obtaining the second image, the target part to be detected 1 can be extracted by manually setting the threshold in the HSV color space through experience. Here, the HSV threshold setting range is (0,0,200) to (180,30,255), where 0 corresponds to the lower threshold of the H phase, 180 corresponds to the upper threshold of the H phase, 0 corresponds to the lower threshold of the S phase, 30 corresponds to the upper threshold of the S phase, 200 corresponds to the lower threshold of the V phase, and 255 corresponds to the upper threshold of the V phase.
[0094] It should also be noted that when there is no obvious color difference between the target part to be detected 1 and other parts of the target workpiece, after obtaining the second image, considering the large difference in the V phase color space, the second image is subjected to brightness threshold binarization to obtain the first extraction area; in addition, if it is determined according to S14 that the first extraction area includes the complete target part to be detected 1, the first extraction area is directly used as the final extraction result, and the extraction work for the next original image is started.
[0095] In summary, this application provides a machine vision-based method for locating semi-transparent workpiece targets. A preset linear brightness enhancement strategy effectively reduces the impact of uneven illumination on the extraction result. A preset partial shape-based screening strategy effectively reduces the impact of occlusion of the target part 1 or confusion caused by other similar parts 3 within the target workpiece on the extraction result. A preset frequency domain feature screening strategy processes suspected areas identified through various methods to determine a second extraction region. Finally, feature parameters are used to determine whether the second extraction region includes the complete target part 1. If it does, the second extraction region is determined as the final extraction result; otherwise, a feedback signal indicating that the target part 1 was not found is provided, allowing technicians to promptly understand the situation. Therefore, this scheme effectively improves the accuracy of extracting the target part 1, performs well even with uneven illumination, occlusion, and confusion of the target part 1, exhibits good robustness, is suitable for various applications, and has high processing efficiency.
[0096] As a preferred embodiment, determining a first image that includes only the target workpiece based on the original image includes:
[0097] The ROI region is extracted from the original image based on a preset Canny threshold used to extract the outer edge of the target workpiece;
[0098] The ROI region is dilated to obtain a first image that includes the complete outer edge of the target workpiece.
[0099] It should be noted that the preset Canny threshold here can be set to a low value. Considering the uneven lighting in the original image, the extracted ROI region is dilated to ensure that the first image includes the complete outer edge of the target workpiece. The specific method for dilation here can be to use the dilation algorithm in image processing.
[0100] In a preferred embodiment, when the target part to be detected 1 is a square component, determining that the first extraction region does not include the complete target part to be detected 1 based on the feature parameters of the target part to be detected 1 includes:
[0101] Determine the aspect ratio, rectangularity, compactness, and number of corner points of the structure corresponding to the target part 1 within the first extraction area;
[0102] Determine whether the first, second, third, and fourth conditions are all met. The first condition is that the aspect ratio is the same as the target aspect ratio of the target part 1 within the first tolerance range. The second condition is that the rectangularity is the same as the target rectangularity of the target part 1 within the second tolerance range. The third condition is that the compactness is the same as the target compactness of the target part 1 within the third tolerance range. The fourth condition is that the number of corner points is less than the preset corner point number threshold.
[0103] If not, the first extraction region is determined to not include the complete target to be detected portion 1.
[0104] Specifically, when the target part to be inspected, 1, is a square-shaped component, such as an attached... Figure 2 The rectangular structure shown can reliably determine whether the first extraction area includes the complete target part 1 through the above settings. Please refer to... Figure 3 and Figure 4 , Figure 3 Corresponding to Figure 2 This shows the texture of the target area 1 to be detected and a schematic diagram of the corner points 11 included therein. Figure 4 Corresponding to Figure 2 The diagram shows the texture of similar parts 3 in the target workpiece and the corner points 31 included therein.
[0105] It is understandable that when the first condition, the second condition, the third condition, and the fourth condition are all met, the first extraction region is determined to include the complete target to be detected part 1.
[0106] As a preferred embodiment, the second image is processed based on a preset brightness linear enhancement strategy to obtain a first suspected region, including:
[0107] Determine the original brightness value of each pixel in the second image and the corresponding brightness threshold of the second image;
[0108] The new brightness value of each pixel is determined based on the preset brightness linear enhancement factor, the preset proportional coefficient representing the brightness range of linear enhancement, the original brightness value, and the brightness threshold, so as to obtain the third image after brightness linear enhancement.
[0109] The position corresponding to the maximum value of the L2 norm in the third image is determined as the reference position;
[0110] The polygonal neighborhood of the reference location is identified as the first suspected region.
[0111] Specifically, the methods for determining the brightness threshold corresponding to the second image include, but are not limited to: calculating the frequency distribution of each brightness value in the second image, forming a histogram, and selecting 30% of the histogram range as the brightness threshold. Please refer to... Figure 5 , Figure 5 For corresponding Figure 2 The diagram shows the processing results of the target detection part 1 in the first image, the target detection part 1 in the second image, and the target detection part 1 in the third image.
[0112] It should also be noted that the polygonal neighborhood of the reference position includes, but is not limited to, a circular neighborhood 111, and the aspect ratio of the polygonal neighborhood can be slightly larger than the aspect ratio of the target part to be detected 1, so as to ensure that the target part to be detected 1 is fully included.
[0113] As can be seen, when there is no obvious color difference between the target part to be detected 1 and other parts of the target workpiece, the above-mentioned brightness linear enhancement strategy can reduce the impact of uneven lighting on the extraction effect. By using the L2 norm to find the reference position and then determining the polygonal neighborhood of the reference position as the first suspected area, the problem of contour adhesion caused by confusion or occlusion between the target part to be detected 1 and other parts of the target workpiece can be solved to a certain extent.
[0114] As a preferred embodiment, the new brightness value of each pixel is determined based on a preset brightness linear enhancement factor, a preset scaling factor representing the brightness range of linear enhancement, the original brightness value, and a brightness threshold, including:
[0115] The new brightness value of each pixel is determined based on the first preset relationship;
[0116] The first presupposed relation is:
[0117]
[0118] Wherein, newValue is the new brightness value, oldValue is the original brightness value, factor is the preset brightness linear enhancement factor, threshold is the brightness threshold, and range is the preset proportional coefficient representing the range of linearly enhanced brightness.
[0119] It should also be noted that, as an example, the brightness threshold can be set to 150, the preset scaling factor can be set to 10%, and the preset brightness linear enhancement factor can be set to 0.25.
[0120] As a preferred embodiment, before determining the position corresponding to the maximum L2 norm in the third image as the reference position, the method further includes:
[0121] The third image is subjected to brightness threshold binarization to obtain the fourth image;
[0122] The fourth image is then filled with holes to obtain the fifth image;
[0123] The position corresponding to the maximum L2 norm in the third image is determined as the reference position, including:
[0124] The position corresponding to the maximum value of the L2 norm in the fifth image is determined as the reference position.
[0125] Specifically, considering that linear brightness enhancement significantly improves the uneven illumination of the target part 1, but may cause contour adhesion between the target part 1 and other parts of the target workpiece, relying solely on the aspect ratio, rectangularity, density, and preset corner point threshold of the target part 1 is insufficient for effective extraction. Furthermore, considering that the target part 1 often occupies the largest space after brightness threshold binarization, brightness threshold binarization and hole filling are performed sequentially through the above steps to obtain the fifth image. The position corresponding to the maximum L2 norm in the fifth image is then determined as the reference position, and the polygonal neighborhood of the reference position is identified as the first suspected region. For more details, please refer to... Figure 6 and Figure 7 , Figure 6 For corresponding Figure 2 The image shows the target detection part 1 in the fifth image after the hole filling is performed on the target detection part 1 in the fourth image; Figure 7 A schematic diagram of the extraction of the first suspected region is shown, in which the polygonal neighborhood is specifically a circular neighborhood 111.
[0126] As can be seen, the above settings can eliminate the influence of contour adhesion on the subsequent determination of whether the extracted region includes the complete target part 1, so as to better extract the target part 1.
[0127] In a preferred embodiment, when the target part to be detected 1 has a right-angled contour, the second image is processed according to a preset partial shape-based screening strategy to obtain a second suspected region, including:
[0128] Based on the line pair recognition strategy, all line pairs in the second image are determined. A line pair is two perpendicular lines within the allowable error range.
[0129] For each pair of lines, determine the average brightness of the line connecting the midpoints of the two lines in the pair.
[0130] Non-maximum suppression screening is performed based on the mean brightness values to determine the unique straight line pair;
[0131] Based on the aspect ratio of the target part to be detected 1 and the preset polygon construction strategy, the unique straight line pair is processed to obtain the minimum bounding rotation polygon, and then the area enclosed by the minimum bounding rotation polygon is determined as the second suspected area.
[0132] For details, please refer to Figure 8 , Figure 8 A schematic diagram of an ideal straight line pair in the target part to be detected 1 is shown. Considering that the HSV color space is inevitably not very robust to uneven lighting, and the shape of the target part to be detected 1 is not sensitive to lighting, even if it is partially occluded, a considerable number of contours can still be retained, the above-mentioned filtering settings based on partial shape can further improve the extraction accuracy of the target part to be detected 1 in the case of uneven lighting, confusion or occlusion between the target part to be detected 1 and other parts of the target workpiece.
[0133] As a preferred embodiment, determining all line pairs in the second image according to the line pair recognition strategy includes:
[0134] Use the Sobel operator to extract all the outer contours of the second image;
[0135] Use Hough transform to extract straight lines from the outer contour;
[0136] Determine a sliding window whose aspect ratio is greater than that of the target part to be detected 1;
[0137] The second image is traversed using a sliding window to determine all pairs of lines in the second image.
[0138] It should also be noted that the aspect ratio of the sliding window here only needs to be slightly larger than the aspect ratio of the target part to be detected 1. Then, the second image is traversed using this sliding window to find whether there are two straight lines in the sliding window that can be considered to be perpendicular within the error allowable range. If so, the pair of lines formed by these two lines is retained. If not, the search continues until the traversal is completed.
[0139] As can be seen, compared with template matching schemes based entirely on shape, the partial shape-based screening strategy provided in this application essentially uses edge extraction and line transformation to find partial right-angled contours for screening. Regardless of whether the target part to be detected 1 has uneven lighting or is confused or occluded, the solution provided in this application has better robustness.
[0140] As a preferred embodiment, the unique line pairs are processed according to the aspect ratio of the target part to be detected 1 and a preset polygon construction strategy to obtain the minimum circumscribed rotation polygon, including:
[0141] For a unique pair of straight lines, construct a rotated polygon with an aspect ratio greater than that of the target part to be detected 1;
[0142] Determine all corner points within the rotated polygon;
[0143] Construct a convex hull based on the corner points, so as to use the convex hull to construct a minimum bounded rotation polygon.
[0144] Specifically, taking the target part to be detected, 1, as an example... Figure 2 Taking the rectangular structure shown as an example, for a unique straight line pair, construct a rotating rectangle with an aspect ratio slightly larger than that of the target part to be detected 1. Determine all the corner points within the rotating rectangle, and construct a convex hull based on these corner points. Then, construct the minimum bounding rotating rectangle using the convex hull. The area enclosed by the minimum bounding rotating rectangle is the second suspected area.
[0145] As a preferred embodiment, the second extraction region is determined based on the first suspected region, the second suspected region, and a preset frequency domain feature filtering strategy, including:
[0146] Determine the intersection-union ratio between the first and second suspected regions;
[0147] Non-maximum suppression is performed based on the crossover-union ratio to determine P regions to be evaluated, where P is an integer not less than 1;
[0148] For the i-th region to be evaluated, where 1 ≤ i ≤ P and i is an integer, perform the following steps:
[0149] The score of the i-th region to be evaluated is determined based on the second preset relation.
[0150] The second presupposed relation is:
[0151]
[0152] mark i F represents the score of the i-th region to be evaluated. i(u,v) represents the gray value of the i-th region to be evaluated at position (u,v) in the spectrum, and F i (u,v) is determined based on the third preset relation, M i N represents the row number of the spectrum graph corresponding to the i-th region to be evaluated. i Let be the column number corresponding to the spectrum of the i-th region to be evaluated;
[0153] The third presupposed relation is:
[0154]
[0155] I i (x,y) represents the gray value of the i-th region to be evaluated at position (x,y) in the grayscale image, S i Q represents the row number of the grayscale image corresponding to the i-th region to be evaluated. i This represents the column number corresponding to the grayscale image of the i-th region to be evaluated;
[0156] The region with the lowest score is identified as the second extraction region.
[0157] In this embodiment, considering that the texture variation on the surface of the semi-transparent workpiece is not obvious, the low-frequency part of the spectrum may have high energy. Please refer to... Figure 9 , Figure 9 Corresponding to Figure 2 It displays the original target to be detected, the grayscale image of the target to be detected, and the spectrum of the target to be detected. The original target to be detected is labeled as image, the grayscale image of the target to be detected is labeled as I(x,y), and the spectrum of the target to be detected is labeled as F(u,v). The third preset relation can realize the calculation of discrete Fourier transform and spectrum centering, and then be substituted into the second preset relation to determine the score of the i-th region to be evaluated.
[0158] Specifically, the number of rows in the spectrogram of the region to be evaluated can be the same as the number of rows in the grayscale image of the region to be evaluated, i.e., M. i =S i The number of columns in the spectrum of the region to be evaluated can be the same as the number of columns in the grayscale image of the region to be evaluated, i.e., N. i =Q i The region with the lowest score among the P regions to be evaluated can be considered as the closest region including the target to be detected, and thus the region with the lowest score is determined as the second extraction region.
[0159] While the disclosure is as stated above, its scope of protection is not limited thereto. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of this disclosure, and all such changes and modifications will fall within the protection scope of this invention.
[0160] It should also be noted that in this specification, relational terms such as first, second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not imply any such actual relationship or order between these entities or operations.
Claims
1. A method for locating a semi-transparent workpiece target based on machine vision, characterized in that, include: Based on the original image, a first image is determined that includes only the target workpiece, wherein the target workpiece includes the target detection part to be extracted (1). The first image is converted from the RGB color space to the HSV color space to obtain the second image; The second image is subjected to brightness threshold binarization to obtain the first extraction region; Based on the feature parameters of the target part to be detected (1), it is determined whether the first extraction region includes the complete target part to be detected (1); the feature parameters include the aspect ratio, rectangularity, density and number of corner points of the structure corresponding to the target part to be detected (1) in the first extraction region; If not, the second image is processed based on a preset brightness linear enhancement strategy to obtain the first suspected region; including: Determine the original brightness value of each pixel in the second image and the corresponding brightness threshold of the second image; Determining the new brightness value of each pixel based on a preset brightness linear enhancement factor, a preset proportional coefficient representing the range of linearly enhanced brightness, the original brightness value, and the brightness threshold includes: determining the new brightness value of each pixel based on a first preset relationship. The first preset relation is: ; in, For the new brightness value, The original brightness value, To preset the linear enhancement factor of brightness, The brightness threshold is... A preset scaling factor to characterize the range of linearly enhanced brightness; To obtain a third image with linearly enhanced brightness; The position corresponding to the maximum L2 norm in the third image is determined as the reference position; The polygonal neighborhood of the reference position is determined as the first suspected region; The second image is processed according to a preset partial shape-based filtering strategy to obtain a second suspected region; including: All line pairs in the second image are determined according to the line pair recognition strategy. The line pair is two perpendicular lines within the allowable error range. For each pair of lines, determine the average brightness of the line connecting the midpoints of the two lines in the pair. Non-maximum suppression screening is performed based on the mean brightness values of each line to determine the unique straight line pair. The unique straight line pair is processed according to the aspect ratio of the target part to be detected (1) and the preset polygon construction strategy to obtain the minimum bounding rotation polygon, and then the area enclosed by the minimum bounding rotation polygon is determined as the second suspected area. When it is determined that the first suspected region and the second suspected region are not the same region, a second extraction region is determined based on the first suspected region, the second suspected region and the preset frequency domain feature filtering strategy, so as to determine whether the second extraction region includes the complete target to be detected part based on the feature parameters (1).
2. The machine vision-based method for locating semi-transparent workpiece targets as described in claim 1, characterized in that, Based on the original image, a first image is determined that includes only the target workpiece, including: The ROI region is extracted from the original image based on a preset Canny threshold used to extract the outer edge of the target workpiece; The ROI region is dilated to obtain a first image that includes the complete outer edge of the target workpiece.
3. The machine vision-based method for locating semi-transparent workpiece targets as described in claim 1, characterized in that, When the target part to be detected (1) is a square component, the first extraction region is determined to not include the complete target part to be detected (1) based on the feature parameters of the target part to be detected (1), including: Determine the aspect ratio, rectangularity, density, and number of corner points of the structure corresponding to the target part to be detected (1) within the first extraction area; Determine whether the first, second, third, and fourth conditions are all met. The first condition is that the aspect ratio is the same as the target aspect ratio of the target part to be detected (1) within the first tolerance range. The second condition is that the rectangularity is the same as the target rectangularity of the target part to be detected (1) within the second tolerance range. The third condition is that the density is the same as the target density of the target part to be detected (1) within the third tolerance range. The fourth condition is that the number of corner points is less than a preset corner point number threshold. If not, it is determined that the first extraction region does not include the complete target to be detected portion (1).
4. The machine vision-based method for locating semi-transparent workpiece targets as described in claim 1, characterized in that, Before determining the position corresponding to the maximum L2 norm in the third image as the reference position, the method further includes: The third image is subjected to brightness threshold binarization to obtain the fourth image; The fourth image is then filled with holes to obtain the fifth image; Determining the position corresponding to the maximum L2 norm in the third image as the reference position includes: The position corresponding to the maximum value of the L2 norm in the fifth image is determined as the reference position.
5. The machine vision-based method for locating semi-transparent workpiece targets as described in claim 1, characterized in that, Based on the line pair recognition strategy, all line pairs in the second image are determined, including: The Sobel operator is used to extract all the outer contours of the second image; The Hough transform is used to extract the straight lines in the outer contour; A sliding window with an aspect ratio greater than that of the target part to be detected (1) is determined; The second image is traversed using the sliding window to determine all pairs of straight lines in the second image.
6. The machine vision-based method for locating semi-transparent workpiece targets as described in claim 1, characterized in that, Based on the aspect ratio of the target part to be detected (1) and the preset polygon construction strategy, the unique line pair is processed to obtain the minimum circumscribed rotation polygon, including: For the unique pair of lines, construct a rotated polygon with an aspect ratio greater than that of the target part to be detected (1); Determine all corner points within the rotated polygon; Construct a convex hull based on the corner points, so as to construct a minimum circumscribed rotation polygon using the convex hull.
7. The machine vision-based method for locating semi-transparent workpiece targets as described in any one of claims 1 to 6, characterized in that, The second extraction region is determined based on the first suspected region, the second suspected region, and a preset frequency domain feature filtering strategy, including: Determine the intersection-union ratio between the first suspected region and the second suspected region; Non-maximum suppression processing is performed based on the intersection-union ratio to determine P regions to be evaluated, where P is an integer not less than 1; For the i-th region to be evaluated, where 1 ≤ i ≤ P and i is an integer, perform the following steps: The score of the i-th region to be evaluated is determined based on the second preset relation. The second preset relation is: ; This represents the score of the i-th region to be evaluated. This represents the grayscale value of the i-th region to be evaluated at its position in the spectrum, and Determined based on the third preset relation. Let i be the row number of the spectrum graph corresponding to the i-th region to be evaluated. Let be the number of columns corresponding to the spectrum of the i-th region to be evaluated; The third preset relation is: ; This indicates the position of the i-th region to be evaluated in the grayscale image. grayscale value at that location This represents the row number of the grayscale image corresponding to the i-th region to be evaluated. This represents the column number corresponding to the grayscale image of the i-th region to be evaluated; The region with the lowest score is identified as the second extraction region.
Citation Information
Patent Citations
Traffic sign detection method in natural scene
CN107301405A
Smoke video detection method and system based on lightweight 3d-rdnet model
WO2021212443A1