Measurement method, device, equipment and storage medium

By extracting the edge segments of the product image to be tested and determining the bias information of the target area, the problem of unfixed measurement positions and large background interference in industrial vision measurement is solved, and the accuracy of measurement is improved.

CN119599939APending Publication Date: 2025-03-11中科慧远半导体技术(广东)有限公司 +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411456219.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

In industrial vision measurement tasks, there are problems such as unfixed measurement location, uncertain number of measurement areas, and large interference in measurement background, which affects the accuracy of measurement.

Method used

By acquiring the image of the product to be tested, extracting the image edge segment, determining the target area in the image, calculating the offset information between the areas, and correlating this information with the product to be tested, to improve the accuracy of the measurement.

Benefits of technology

This method can more accurately determine defect areas in the product to be tested with uncertain location, irregular number, and complex interference information, and improve the accuracy of industrial vision measurement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119599939A_ABST
    Figure CN119599939A_ABST
Patent Text Reader

Abstract

The invention provides a measurement method and device, equipment and a storage medium, and the method comprises the steps: obtaining a to-be-measured product image, extracting an image edge line segment of the to-be-measured product image, determining a first target image region and a second target image region in the to-be-measured product image based on the image edge line segment, the first target image area is an overlapping image area between target components representing the to-be-detected product, and the second target image area is an image area representing the target components of the to-be-detected product, determining a third target image area in the to-be-detected product image based on the image edge line segment and the second target image area, and determining first deviation information between the first target image area and the second target image area, determining second deviation information between the first target image area and the third target image area, and carrying out association processing on the first deviation information, the second deviation information and the to-be-detected product. By adopting the method, the accuracy of industrial vision measurement is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing technology, and in particular to a measurement method, device, equipment and storage medium. Background Art

[0002] Industrial visual measurement tasks refer to the automated measurement and analysis of products through visual inspection in industrial production and quality control to improve product quality. Industrial visual measurement tasks usually have problems such as unstable measurement positions, uncertain number of measurement areas, and large measurement background interference, which will affect the accuracy of industrial visual measurement. Therefore, how to improve the accuracy of industrial visual measurement has become a technical problem that needs to be solved urgently. Summary of the invention

[0003] The present disclosure provides a measurement method, device, equipment and storage medium to at least solve the above technical problems existing in the prior art.

[0004] According to a first aspect of the present disclosure, a measurement method is provided, the method comprising:

[0005] Acquire an image of the product to be tested;

[0006] Extracting image edge segments of the image of the product to be tested;

[0007] Based on the image edge segments, determining a first target image region and a second target image region in the image of the product to be tested, wherein the first target image region is an overlapping image region between target components representing the product to be tested, and the second target image region is an image region representing the target components of the product to be tested;

[0008] Based on the image edge line segment and the first target image area, determining a third target image area in the image of the product to be tested, wherein the third target area represents an image area of ​​a surface feature of a target component of the product to be tested;

[0009] Determining first offset information between the first target image area and the second target image area, and determining second offset information between the first target image area and the third target image area;

[0010] The first offset information and the second offset information are associated with the product to be tested.

[0011] According to a second aspect of the present disclosure, a measuring device is provided, the device comprising:

[0012] An image determination module, used to obtain an image of a product to be tested;

[0013] An edge extraction module, used to extract image edge segments of the image of the product to be tested;

[0014] A first region determination module is used to determine a first target image region and a second target image region in the image of the product to be tested based on the image edge segment, wherein the first target image region is an overlapping image region between target components representing the product to be tested, and the second target image region is an image region representing the target components of the product to be tested;

[0015] A second region determination module, configured to determine a third target image region in the image of the product to be tested based on the image edge segment and the first target image region;

[0016] An offset information determination module is used to determine first offset information between the first target image area and the second target image area, and to determine second offset information between the first target image area and the third target image area;

[0017] The association module is used to associate the first offset information and the second offset information with the product to be tested.

[0018] According to a third aspect of the present disclosure, there is provided an electronic device, including:

[0019] at least one processor; and

[0020] a memory communicatively connected to the at least one processor; wherein,

[0021] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the present disclosure.

[0022] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method described in the present disclosure.

[0023] The measuring method, device, equipment and storage medium disclosed in the present invention acquire an image of a product to be tested, extract image edge segments of the image of the product to be tested, determine a first target image area and a second target image area in the image of the product to be tested based on the image edge segments, wherein the first target image area is an overlapping image area between target components representing the product to be tested, and the second target image area is an image area representing the target components of the product to be tested, determine a third target image area in the image of the product to be tested based on the image edge segments and the second target image area, determine first offset information between the first target image area and the second target image area, and determine second offset information between the first target image area and the third target image area, and associate the first offset information and the second offset information with the product to be tested. That is, the first target image area, the second target image area and the third target image area in the image of the product to be tested can be determined through the image edge segments of the image of the product to be tested, and then the first offset information between the first target image area and the second target image area and the second offset information between the first target image area and the third target image area can be calculated, and the first offset information and the second offset information are associated with the product to be tested, so that the first offset information and the second offset information can be used to better determine the defect areas in the product to be tested with uncertain positions, non-fixed numbers, and complex interference information, thereby improving the accuracy of industrial visual measurement.

[0024] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:

[0026] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.

[0027] Figure 1 A schematic diagram of a flow chart of a measurement method provided by an embodiment of the present disclosure is shown;

[0028] Figure 2 A schematic diagram of collecting an appearance image of a product to be tested provided by an embodiment of the present disclosure is shown;

[0029] Figure 3 A schematic diagram of an extraction process of image edge segments provided by an embodiment of the present disclosure is shown;

[0030] Figure 4A schematic diagram of determining an image edge segment provided by an embodiment of the present disclosure is shown;

[0031] Figure 5 A schematic diagram of fitting image edge segments provided by an embodiment of the present disclosure is shown;

[0032] Figure 6 An image of a product to be tested provided by an embodiment of the present disclosure is shown;

[0033] Figure 7 A schematic diagram of edge processing of a product image to be tested provided by an embodiment of the present disclosure is shown;

[0034] Figure 8 An overlapping area image provided by an embodiment of the present disclosure is shown;

[0035] Fig. 9 A metal region image provided by an embodiment of the present disclosure is shown;

[0036] Fig.10 A gold wire area image provided by an embodiment of the present disclosure is shown;

[0037] Fig.11 A schematic diagram of the structure of a measuring device provided by an embodiment of the present disclosure is shown;

[0038] Fig.12 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0039] In order to make the purpose, features, and advantages of the present disclosure more obvious and easy to understand, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.

[0040] Since current industrial vision measurement tasks usually have problems such as unstable measurement positions, uncertain number of measurement areas, and large measurement background interference, such problems will affect the accuracy of industrial vision measurement. Therefore, in order to improve the accuracy of industrial vision measurement, the present disclosure provides a measurement method, apparatus, equipment and storage medium. The measurement method provided by the present disclosure can be applied to any electronic device that can perform image processing, including but not limited to computers, mobile phones, and tablet computers.

[0041] The technical solution of the embodiment of the present disclosure will be described below in conjunction with the drawings in the embodiment of the present disclosure.

[0042] Figure 1 A schematic diagram of a flow chart of a measurement method provided by an embodiment of the present disclosure is shown. Figure 1 As shown, the method includes:

[0043] S101, obtaining an image of a product to be tested.

[0044] In the present disclosure, an image acquisition device may be used to acquire appearance images of the product to be tested, and the product to be tested may include automotive parts, optical elements, electronic components, etc. The image acquisition device may be a mobile phone camera, a video camera, an optical imaging system acquisition device, etc. Figure 2 FIG. 1 shows a schematic diagram of collecting an appearance image of a product to be tested provided by an embodiment of the present disclosure, such as Figure 2 As shown, a CCD camera 201 can be used to capture the appearance image of the product to be tested 202. Since a color image contains rich and detailed image information such as image color, lighting, shadow, and product material, the captured appearance image of the product to be tested is generally a color image. The image of the product to be tested can be further determined by performing image processing such as grayscale conversion on the captured appearance image.

[0045] In a possible implementation manner, obtaining the image of the product to be tested may include steps A1-A2:

[0046] Step A1, collecting a color image of the product to be tested.

[0047] In the present disclosure, an image acquisition device may be used to acquire a color appearance image of the product to be tested.

[0048] Step A2: preprocess the color image to obtain a corresponding grayscale image as the image of the product to be tested.

[0049] In the present disclosure, the color image may be directly converted into a grayscale image, and the grayscale image may be used as the image of the product to be tested.

[0050] In a possible implementation manner, the preprocessing of the color image to obtain a corresponding grayscale image as the image of the product to be tested may further include steps B1-B3:

[0051] Step B1, downsampling the color image to obtain a downsampled image.

[0052] In order to improve the image processing speed and the storage space occupied by the image, the color image may be downsampled first in the present disclosure. For example, the color image may be downsampled using a downsampling parameter of 0.5 to obtain a downsampled image.

[0053] Step B2: split each color channel of the downsampled image, and determine the weight corresponding to each color channel based on the scene information corresponding to the product to be tested.

[0054] In the present disclosure, the weights corresponding to the product to be tested in each color channel can be determined in advance according to the scene information corresponding to the product to be tested. Taking the RGB (red, green, and blue) color channel of an image as an example, the grayscale of the green channel is significantly higher than other channels under strong light conditions, so a higher weight can be assigned to the green channel. For example, the weight corresponding to the G channel can be assigned to be 0.6, the weight corresponding to the R channel can be assigned to be 0.3, and the weight corresponding to the B channel can be assigned to be 0.1. In scenes with darker light, it may be necessary to re-evaluate the weights for each color channel to ensure that the color features of the product to be tested can be accurately captured. Specifically, the split function in opencv can be used to separate the color channels of an image.

[0055] Step B3: determining a grayscale image corresponding to the downsampled image based on the weights corresponding to the color channels, and using the grayscale image as the image of the product to be tested.

[0056] In the present disclosure, for each pixel in a color image, the sum of the products of the pixel value in each channel and the weight of the channel can be calculated as the grayscale value corresponding to the pixel, and the obtained grayscale image is used as the image of the product to be tested. For example, if the weight corresponding to the G channel is 0.5870, the weight corresponding to the R channel is 0.2989, and the weight corresponding to the B channel is 0.1140, then the grayscale value of the pixel can be calculated as 0.2989*R+0.5870*G+0.1140*B.

[0057] In the present disclosure, weights are effectively assigned to each color channel by combining scene information and product characteristics, thereby improving the accuracy of the acquired image of the product to be tested.

[0058] S102: extracting image edge segments of the image of the product to be tested.

[0059] In the present disclosure, an edge detection operator may be used to extract edge lines in the image of the product to be tested as image edge segments. For example, a Canny edge detection operator may be used to extract edge lines of the image.

[0060] In the present disclosure, pixel points at the edge of the image may also be extracted, and image edge segments may be fitted based on the edge pixel points.

[0061] S103: Determine a first target image region and a second target image region in the image of the product to be tested based on the image edge segments.

[0062] In the present disclosure, the first target image area is an overlapping image area between target components that characterize the product to be tested, and the second target image area is an image area that characterizes the target components of the product to be tested. The target components may be metal components or other components in the product to be tested. For example, after the product to be tested is laser etched, the metal components of the product will be exposed. The portion of the upper part of the product to be tested that exposes the metal components may be used as the metal area, and the area of ​​the lower part of the product to be tested that is connected to the metal components may be used as the overlap area. The overlap area and the metal area overlap, so the image area corresponding to the metal area may be the second target image area, and the image area corresponding to the overlap area may be the first target image area.

[0063] S104: Determine a third target image region in the image of the product to be tested based on the image edge segment and the first target image region.

[0064] In the present disclosure, the third target area represents an image area of ​​the surface features of the target component of the product to be tested. The surface features of the target component of the product to be tested may include features such as texture, defects and surface stains of the target component.

[0065] S105, determining first offset information between the first target image region and the second target image region, and determining second offset information between the first target image region and the third target image region.

[0066] In the present disclosure, the offset between regions includes horizontal offset and vertical offset. The x offset and y offset between the center points of the image regions can be calculated as the horizontal offset and the vertical offset. Alternatively, the offset between regions can be determined by the image region edge, including the horizontal offset and the vertical offset.

[0067] S106: Associating the first offset information and the second offset information with the product to be tested.

[0068] In the present disclosure, by associating the first offset information and the second offset information with the product to be tested, the staff can determine whether there is a defective area in the product to be tested and determine the type of the defective area based on the offset information when testing the product to be tested.

[0069] By adopting the measurement method disclosed in the present invention, an image of a product to be tested is acquired, image edge segments of the image of the product to be tested are extracted, and a first target image area and a second target image area in the image of the product to be tested are determined based on the image edge segments, wherein the first target image area is an overlapping image area between target components representing the product to be tested, and the second target image area is an image area representing the target components of the product to be tested. Based on the image edge segments and the second target image area, a third target image area in the image of the product to be tested is determined, first offset information between the first target image area and the second target image area is determined, and second offset information between the first target image area and the third target image area is determined, and the first offset information and the second offset information are associated with the product to be tested. That is, the first target image area, the second target image area and the third target image area in the image of the product to be tested can be determined through the image edge segments of the image of the product to be tested, and then the first offset information between the first target image area and the second target image area and the second offset information between the first target image area and the third target image area can be calculated, and the first offset information and the second offset information are associated with the product to be tested, so that the first offset information and the second offset information can be used to better determine the defect areas in the product to be tested with uncertain positions, non-fixed numbers, and complex interference information, thereby improving the accuracy of industrial visual measurement.

[0070] In one possible implementation, Figure 3 A schematic diagram of an extraction process of image edge segments provided by an embodiment of the present disclosure is shown. The extraction of image edge segments of the image of the product to be tested may include:

[0071] S301, performing denoising processing on the image of the product to be tested to obtain a denoised image.

[0072] In the present disclosure, the image of the product to be tested can be processed by an opening operation, and the interference points in the image can be removed by the opening operation to obtain a denoised image. Alternatively, the image of the product to be tested can be filtered by a smoothing filter to remove the noise of the image of the product to be tested and obtain a denoised image.

[0073] S302: Binarization is performed on the denoised image to obtain a binary image.

[0074] In the present disclosure, the denoised image can be binarized by setting a global threshold. For example, a pixel value of 100 can be set as the global threshold, and the pixel values ​​of the pixels in the denoised image with pixel values ​​higher than 100 are reset to 255, and the pixel values ​​of the pixels in the denoised image with pixel values ​​not higher than 100 are reset to 0, so as to obtain a binary image. Alternatively, in the present disclosure, a local threshold can be set for each area in the denoised image or an adaptive threshold can be set for each pixel in the denoised image to obtain a binary image.

[0075] S303: extracting edge pixels in the binary image.

[0076] In the present disclosure, an edge detection operator may be used to extract edge pixels in a binary image.

[0077] S304, fitting straight lines based on the edge pixels to obtain image edge segments of the image of the product to be tested.

[0078] In the present disclosure, a straight line may be directly fitted based on each extracted edge pixel point, and a line segment in the image of the fitted straight line may be determined as an image edge line segment of the image of the product to be tested.

[0079] In one possible implementation, Figure 4 A schematic diagram of determining an image edge segment provided by an embodiment of the present disclosure is shown. The step of fitting a straight line based on each edge pixel point to obtain the image edge segment of the image of the product to be tested may include:

[0080] S401, for a first line segment formed by any two edge pixels, calculating the distances between each of the remaining edge pixels and the first line segment.

[0081] In the present disclosure, a line segment formed by any two pixel points may be used as a first line segment to obtain a plurality of first line segments.

[0082] S402: Determine an edge pixel point whose distance to the first line segment is less than or equal to a preset distance threshold as a target pixel point corresponding to the first line segment.

[0083] In the present disclosure, a preset distance threshold may be set according to actual application scenarios. For example, the preset distance threshold may be set to a 2-pixel distance or a 3-pixel distance, wherein the distance between any two adjacent pixels is equal to a one-pixel distance.

[0084] S403: Determine the first line segment corresponding to the largest number of target pixels as the second line segment.

[0085] S404: Fitting a straight line based on each target pixel point corresponding to the second line segment to obtain a fitted straight line as an image edge segment of the image of the product to be tested.

[0086] In the present disclosure, the least square method may be used to perform straight line fitting on each target pixel point corresponding to the second line segment, and the fitted straight line is obtained as the image edge line segment of the image of the product to be tested. Figure 5 FIG. 4 shows a schematic diagram of fitting an image edge segment provided by an embodiment of the present disclosure, such as Figure 5 As shown, the line segment L' is the second line segment, the distance from point p to the second line segment L' is greater than the preset distance threshold, and the distances from other points to the second line segment L' are less than the preset distance threshold. The least square method can be used to Figure 5 The target pixel points except the point p shown are fitted with a straight line to obtain a fitted straight line L as an image edge segment of the image of the product to be tested. Figure 6 An image of a product to be tested provided by an embodiment of the present disclosure is shown. Figure 6 As shown, it can be observed in the product to be tested image 601 corresponding to the product to be tested after laser etching that the metal component 602 is exposed in the product after laser etching. Figure 7 FIG. 4 shows a schematic diagram of edge processing of a product image to be tested provided by an embodiment of the present disclosure, such as Figure 7 As shown, by performing straight line fitting on each edge pixel point of the product image 701 to be tested, an image edge line segment 702 of the product image 701 to be tested can be obtained.

[0087] In a possible implementation manner, determining the first target image region and the second target image region in the image of the product to be tested based on the image edge segments may include steps C1-C4:

[0088] Step C1, performing correction processing on the image of the product to be tested according to the image edge segments to obtain a corrected image.

[0089] In order to better measure various areas in the image of the product to be measured and avoid the problem of inaccurate measurement due to image deviation, in the present disclosure, the image of the product to be measured can be corrected to correct the angular error of the image of the product to be measured with angular deviation.

[0090] In the present disclosure, the image of the product to be tested can be corrected according to the pixel coordinates at both ends of the image edge segment. Specifically, the offset angle θ of the image of the product to be tested can be determined according to the pixel coordinates at both ends of the image edge segment, and the image of the product to be tested can be corrected based on the offset angle θ, the preset translation parameters and the preset affine transformation matrix to obtain a corrected image.

[0091] Specifically, the offset angle θ of the image of the product to be tested can be determined by the following formula:

[0092]

[0093] Among them, x1 and y1 are the horizontal coordinates and vertical coordinates of the starting pixel point of the image edge segment, and x2 and y2 are the horizontal coordinates and vertical coordinates of the ending pixel point of the image edge segment.

[0094] Specifically, the translation transformation matrix HomMat2DTranslate can be determined using the following formula:

[0095] HomMat2DTranslatearctan=HomMat2D·E·T

[0096] Among them, HomMat2DTranslate is the translation transformation matrix, HomMat2D is the preset affine transformation matrix, E is the unit matrix, T is the preset translation parameter, T x is the distance of translation along the x-axis, T x The value can be Width / 2, where Width is the width of the image of the product to be tested, and T y is the distance of translation along the y-axis, T y The value can be Height / 2, where Height is the height of the product image to be tested.

[0097] Specifically, the rotation transformation matrix R can be determined using the following formula:

[0098]

[0099] Where θ is the offset angle of the image of the product to be tested.

[0100] The correction matrix A of the image of the product to be tested can be determined based on the translation transformation matrix HomMat2DTranslate and the rotation transformation matrix R using the following formula:

[0101] A=HomMat2DTranslatearctan·R

[0102] In the present disclosure, the correction matrix A of the image of the product to be tested may be used to correct each pixel point in the image of the product to be tested to obtain a corrected image.

[0103] Step C2: determining a first rectangle in the image of the product to be tested based on the pixel coordinates at both ends of the image edge segment.

[0104] In the present disclosure, a rectangle parallel to the coordinate axis can be generated as the first rectangle Rectangle1 in the image of the product to be tested according to the coordinates of the pixel points at both ends of the image edge segment. In the present disclosure, the coordinate axis can be established with the upper left corner pixel point of the image of the product to be tested as the origin, the horizontal right direction as the positive direction of the x-axis, and the vertical downward direction as the positive direction of the y-axis.

[0105] In a possible implementation manner, the coordinates of the upper left corner and the lower right corner of the first rectangle Rectangle1 may be determined according to the coordinates of the pixel points at both ends of the image edge segment.

[0106] Specifically, the horizontal coordinate of the upper left corner of the first rectangle Rectangle1 can be set to 0, the average vertical coordinate of the pixel points at both ends of the image edge segment can be calculated, and the difference obtained by subtracting the height of the first rectangle Rectangle1 from the sum of the average vertical coordinate and the first preset positioning height is determined as the vertical coordinate of the upper left corner of the first rectangle Rectangle1, wherein the height of the first rectangle Rectangle1 can be set in advance, for example, the height of the first rectangle Rectangle1 can be set to 30 pixels or 35 pixels, etc., and the first preset positioning height can be set to 70 pixels or 75 pixels, etc.

[0107] The horizontal coordinate of the lower right corner of the first rectangle Rectangle1 can be set as the width value of the product image to be tested, and the difference between the average value of the vertical coordinate and the sum of the second preset positioning height plus the height of the first rectangle Rectangle1 is determined as the vertical coordinate of the lower right corner of the first rectangle Rectangle1, wherein the second preset positioning height and the first preset positioning height can be the same as or different from the first preset positioning height, and the second preset positioning height can be set to 70 pixels or 75 pixels, etc.

[0108] Step C3: determining a first target image region in the image of the product to be tested according to the first rectangle.

[0109] In the present disclosure, the step of screening the first target image area in the image of the product to be tested according to the first rectangle may include steps D1-D3:

[0110] Step D1, segmenting the image region corresponding to the first rectangle based on a first preset global threshold to obtain a first segmented image region.

[0111] In the present disclosure, the first preset global threshold can be set according to the actual application scenario. For example, the maximum threshold in the first preset global threshold can be set to 255 and the minimum threshold can be set to 80. Then, the pixel values ​​of the pixels in the image area corresponding to the first rectangle whose pixel values ​​are less than 80 can be reset to 0, and the pixel values ​​of the pixels in the image area corresponding to the first rectangle whose pixel values ​​are greater than or equal to 80 can be reset to 255 to obtain the processed image. In order to eliminate small holes and broken areas in the processed image, the processed image can continue to be subjected to a rectangular closing operation. Specifically, a rectangle with a width and height of 10 pixels and 1 pixel distance respectively can be used to dilate the processed image, small holes and gaps in the image are filled, and part of the edge area is merged, and then the dilated image is eroded, thereby reducing the image boundary. Then, a rectangular opening operation can be performed on the image obtained after the rectangular closing operation. For example, a rectangle with a width and height of 30 pixels and 1 pixel distance respectively can be used to perform a rectangular opening operation on the image obtained after the rectangular closing operation. Specifically, the image obtained after the rectangle closing operation may be corroded, and then the corroded image may be expanded to obtain the image region RegionOpening1 as the first segmented image region.

[0112] Step D2, breaking up the first segmented image region to obtain a plurality of sub-image regions, and obtaining a first image group consisting of the plurality of sub-image regions.

[0113] In the present disclosure, in order to eliminate the narrower inspected areas in the image of the product to be tested, the first segmented image area can be broken up, and the multiple image areas obtained after the breakup can be screened to select multiple sub-image areas whose width and height meet the requirements, thereby obtaining a first image group consisting of multiple sub-image areas.

[0114] Specifically, each connected area in the first segmented image area can be marked, and for each connected area, the connected area RectRegions whose number of pixels in the width direction is between [25, 999999] pixels and whose number of pixels in the height direction is between [30, 999999] pixels are screened as sub-image areas that meet the requirements, and then a first image group consisting of the sub-image areas that meet the requirements is obtained.

[0115] Step D3: determining a first target image area according to the first image group.

[0116] Determining the first target image area according to the first image group may include steps E1-E2:

[0117] Step E1, obtaining the bounding rectangle of each sub-image area in the first image group.

[0118] In the present disclosure, the minimum bounding rectangle of each sub-image region RectRegions in the first image group may be calculated.

[0119] Step E2: determining a first target image area in the image of the product to be tested based on the circumscribed rectangle and the center coordinates of the first target image area.

[0120] In the present disclosure, the horizontal coordinate array RectRegionRow and the vertical coordinate data RectRegionCol of the center point of each sub-image region RectRegions in the first image group can be determined. Also, the width array Length11 of the minimum bounding rectangle of each sub-image region RectRegions in the first image group is determined, the horizontal coordinate array RectRegionColumn1 and the vertical coordinate array RectRegionRow1 of the upper left vertex of each minimum bounding rectangle are determined, and the horizontal coordinate array RectRegionColumn2 and the vertical coordinate array RectRegionRow2 of the lower right vertex of each minimum bounding rectangle are determined.

[0121] After obtaining each array, query the elements with a value of 0 and the index corresponding to the element in each array, and reset the value of the element with a value of 0 to 9999. By resetting the element value, it is convenient to filter out abnormal values ​​in the image. Then, each sub-image area corresponding to the first image group with reset element values ​​is jointly determined as the first target image area. In the present disclosure, the first target image area can be an overlapping area. Figure 8 An overlapping area image provided by an embodiment of the present disclosure is shown. Figure 8 As shown, the image 801 of the product to be tested shows that after the product to be tested is laser etched, the metal component 803 of the product to be tested is exposed. The portion of the upper part of the product to be tested that exposes the metal component can be used as the metal area, and the area where the lower part of the product to be tested is connected to the metal component is the overlap area, such as Figure 8 The area selected by the multiple rectangular frames in the image of the product to be tested is the overlapping area 802, and the overlapping area 802 is the first target image area.

[0122] Step C4, determining a second target image area in the image of the product to be tested according to the first target image area.

[0123] In the present disclosure, determining the second target image area in the image of the product to be tested according to the first target image area may include steps F1-F4:

[0124] Step F1, determining a second rectangular group corresponding to the first target image area.

[0125] Specifically, a rectangle row may be created whose length is equal to the length of the sub-image region RectRegions in the first image group and whose width is the sum of the average value of the ordinates of the two endpoints of the image edge segment and the third preset positioning height, wherein the third preset positioning height may be set to a distance of 70 pixels or a distance of 75 pixels, etc. Multiple rectangles Rectangle2 parallel to the coordinate axis are generated, and the horizontal coordinate of the upper left corner pixel point of each rectangle Rectangle2 is equal to the value obtained by subtracting the width array Length11 of the minimum circumscribed rectangle from the ordinate data RectRegionCol of the center point of the sub-image region RectRegions in the first image group and then subtracting the width threshold corresponding to the second target image region. In the present disclosure, the width threshold corresponding to the second target image region may be set to a distance of 20 pixels or a distance of 22 pixels, etc. The vertical coordinate of the upper left corner pixel of each rectangle Rectangle2 is equal to the value obtained by subtracting the height threshold corresponding to the second target image area from the difference between the height of rectangle row and the fourth preset positioning height. Row is the sum of the average vertical coordinates of the two endpoints of the image edge segment and the third preset positioning height. In the present disclosure, the third preset positioning height can be set to -70 pixels or -75 pixels, etc., and the width threshold corresponding to the second target image area can be set to 30 pixels or 32 pixels. The horizontal coordinate of the lower right corner pixel of each rectangle Rectangle2 is equal to the value obtained by adding the vertical coordinate data RectRegionCol of the center point of the sub-image area RectRegions in the first image group, the width array Length11 of the minimum circumscribed rectangle, and the width threshold corresponding to the second target image area. The vertical coordinate of the lower right corner pixel of each rectangle Rectangle2 is equal to the value obtained by adding the height of rectangle row to the difference between the fourth preset positioning height and the height threshold corresponding to the second target image area.

[0126] The rectangle group formed by rectangle row and each rectangle Rectangle2 is taken as the second rectangle group, and then the second target image area in the image of the product to be tested can be screened according to the second rectangle group.

[0127] Step F2, segmenting each image region corresponding to the second rectangular group based on a second preset global threshold value to obtain a second segmented image region.

[0128] In the present disclosure, the second preset global threshold can be set to: a minimum threshold of 50 and a maximum threshold of 255. The pixel values ​​of the pixels whose pixel values ​​are less than 50 in the image area corresponding to each rectangle Rectangle2 are reset to 0, and the pixel values ​​of the pixels whose pixel values ​​are greater than or equal to 50 in the image area corresponding to each rectangle Rectangle2 are reset to 255, and the processed images corresponding to each rectangle are obtained. In order to eliminate small holes and broken areas in the processed image, the processed image can continue to be closed. For example, a rectangle with a width and height of 10 pixels and a distance of 1 pixel can be used to expand the processed image, and the small holes and gaps in the image are filled, and some edge areas are merged. Then, the expanded image is corroded, and the image obtained after the closing operation is opened. For example, a rectangle with a width and height of 30 pixels and a distance of 1 pixel can be used to open the image obtained after the closing operation. Specifically, the image obtained after the closing operation can be corroded, and then the corroded image is expanded to obtain the image area RegionOpening2 as the second segmented image area.

[0129] Step F3, breaking up the second segmented image region to obtain a second image group consisting of a plurality of sub-image regions.

[0130] In the present disclosure, in order to detect the narrower inspection area in the image, the second segmented image area can be broken up, and the multiple image areas obtained after the breaking up can be screened to screen out multiple sub-image areas whose width and height meet the requirements, and then a second image group consisting of multiple sub-image areas can be obtained. Specifically, each connected area in the second segmented image area can be marked, and for each connected area, the connected area MetalRegions whose number of pixels in the width direction is between [20, 999999] pixels and whose number of pixels in the height direction is between [25, 999999] pixels can be screened as the sub-image area that meets the requirements, and then a second image group consisting of each sub-image area that meets the requirements can be obtained.

[0131] Step F4, determining a second target image area based on the first image group and the second image group.

[0132] In the present disclosure, the intersection of the image area of ​​the first image group and the image area of ​​the second image group may be obtained, and sub-images without intersection may be filled with spaces so that the number of sub-images in the first image group and the second image group is consistent.

[0133] In the present disclosure, the horizontal coordinate array MetalRegionRow formed by the horizontal coordinates of the center points of each sub-image in the second image group and the vertical coordinate array MetalRegionCol formed by the vertical coordinates can be determined. The minimum bounding rectangle of each sub-image in the second image group is obtained, and the horizontal coordinate array MetalRegionColumn1 and the vertical coordinate array MetalRegionRow1 of the upper left vertex of the minimum bounding rectangle of each sub-image in the second image group are determined, and the horizontal coordinate array MetalRegionColumn2 and the vertical coordinate array MetalRegionRow2 of the lower right vertex of each minimum bounding rectangle are determined.

[0134] After obtaining each array, query the elements with a value of 0 and the index corresponding to the element in each array, and reset the value of the element with a value of 0 to 9999. By resetting the element value, it is convenient to filter out abnormal values ​​in the image. Then, each sub-image corresponding to the second image group with reset values ​​is jointly determined as the second target image area. In the present disclosure, the second target image area can be a metal area. Fig. 9 A metal region image provided by an embodiment of the present disclosure is shown. Fig. 9 As shown, the image 901 of the product to be tested shows that after the product to be tested is laser etched, a metal component 903 is exposed on the product to be tested, and the exposed metal component area on the upper part of the product to be tested is the metal area 902, and the metal area 902 is the second target image area.

[0135] In a possible implementation, determining a third target image region in the image of the product to be tested based on the image edge segment and the first target image region may include steps G1-G3:

[0136] Step G1, generating a third rectangle based on the image edge segments.

[0137] Specifically, a third rectangle twoLineRegion parallel to the coordinate axis is generated, the horizontal coordinate of the upper left vertex of the third rectangle is 0, and the horizontal coordinate is the difference between the average vertical coordinate of the two end points of the image edge line and the fourth preset positioning height, wherein the fourth preset positioning height can be set to 0 or 10 pixels. The horizontal coordinate of the lower right vertex of the third rectangle is the width of the product image to be measured, and the vertical coordinate of the lower right vertex of the third rectangle is the sum of the average vertical coordinate of the two end points of the image edge line and the fifth preset positioning height, wherein the fifth preset positioning height can be set to 60 pixels or 70 pixels, etc.

[0138] Step G2, dividing the third rectangle to obtain a third image group consisting of a plurality of sub-image areas.

[0139] In the present disclosure, the third rectangle twoLineRegion can be segmented by using a global threshold. Specifically, the minimum threshold of the global threshold can be set to 0 and the maximum threshold can be set to 50, that is, the pixel values ​​of the pixels in the image area corresponding to the third rectangle whose pixel values ​​are less than 50 can be reset to 0, and the pixel values ​​of the pixels in the image area corresponding to the first rectangle whose pixel values ​​are greater than or equal to 50 can be reset to 255, so as to obtain a processed image. In order to eliminate small holes and broken areas in the processed image, the processed image can continue to be closed. Specifically, a rectangle with a width and height of 10 pixels and 1 pixel distance respectively can be used to dilate the processed image, small holes and gaps in the image are filled, some edge areas are merged, and then the dilated image is eroded. Then, the image obtained after the closing operation can be opened. For example, a rectangle with a width and height of 30 pixels and 1 pixel distance respectively can be used to open the image obtained after the closing operation. Specifically, the image obtained after the closing operation can be eroded, and then the eroded image can be expanded to obtain the image area RegionOpening3 as the third segmented image area. In order to remove the narrower inspected areas in the image of the product to be tested, the third segmented image area can be broken up, and the multiple image areas obtained after the breaking up can be screened to screen out multiple sub-image areas whose width and height meet the requirements, and obtain a third image group consisting of multiple sub-image areas. Specifically, each connected area in the third segmented image area can be marked, and for each connected area, the connected area GoldLineRegions whose number of pixels in the width direction is between [20, 999999] pixels and whose number of pixels in the height direction is between [25, 999999] pixels are screened as sub-image areas that meet the requirements, and then the third image group consisting of each sub-image area that meets the requirements is obtained.

[0140] Step G3: determining a third target image region in the image of the product to be tested based on the third image group and the first target image region.

[0141] In the present disclosure, the intersection of the image area of ​​the first image group and the image area of ​​the third image group may be obtained, and sub-images without intersection may be filled with spaces so that the number of sub-images in the first image group and the third image group are consistent.

[0142] In the present disclosure, the horizontal coordinate array GoldLineRegionRow formed by the horizontal coordinates of the center points of each sub-image in the third image group and the vertical coordinate array GoldLineRegionCol formed by the vertical coordinates can be determined. The minimum bounding rectangle of each sub-image in the third image group is obtained, and the horizontal coordinate array GoldLineRegionColumn1 and the vertical coordinate array GoldLineRegionRow1 of the upper left vertex of the minimum bounding rectangle of each sub-image in the third image group are determined, and the horizontal coordinate array GoldLineRegionColumn2 and the vertical coordinate array GoldLineRegionRow2 of the lower right vertex of each minimum bounding rectangle are determined.

[0143] After obtaining each array, query the elements with a value of 0 and the index corresponding to the element in each array, and reset the value of the element with a value of 0 to 9999. By resetting the element value, it is convenient to filter out abnormal values ​​in the image. Then, each sub-image corresponding to the third image group with reset values ​​is jointly determined as the third target image area. In the present disclosure, the third target image area can be a gold line area. In the present disclosure, the third target image area can be an overlap area. Fig.10 FIG. 4 shows a gold wire area image provided by an embodiment of the present disclosure, such as Fig.10 As shown, the image 1001 of the product to be tested shows that after the product to be tested is laser etched, the metal component 1003 of the product to be tested is exposed. The exposed metal component area on the upper part of the product to be tested is the metal area. The metal area 1002 is the black area on the upper part of the metal area. In the present disclosure, the gold wire area 1002 can be used to determine whether the metal area is abnormal.

[0144] In a possible implementation manner, determining the offset information between the first target image region and the second target image region may include steps H1-H2:

[0145] Step H1, determining the left edge difference and the right edge difference between the first target image area and the second target image area, and determining the larger difference between the left edge difference and the right edge difference as the horizontal offset between the first target image area and the second target image area.

[0146] Specifically, the horizontal offset between the first target image area and the second target image area may be determined by the following formula:

[0147] CenterOffsetX1=Max(|MetalRegionColumn1-RectRegionColumn1|,

[0148] |MetalRegionColumn2-RectRegionColumn2|)

[0149] Among them, CenterOffsetX1 is the horizontal offset between the first target image area and the second target image area, MetalRegionColumn1 is the vertical coordinate array of the upper left vertex of the minimum bounding rectangle of each sub-image in the second image group, RectRegionColumn1 is the vertical coordinate array of the upper left vertex of the minimum bounding rectangle of each sub-image in the first image group, MetalRegionColumn2 is the vertical coordinate array of the lower right vertex of the minimum bounding rectangle of each sub-image in the second image group, and RectRegionColumn2 is the vertical coordinate array of the lower right vertex of the minimum bounding rectangle of each sub-image in the first image group.

[0150] Step H2, determining the upper edge difference and the lower edge difference between the first target image area and the second target image area, and determining the larger difference between the upper edge difference and the lower edge difference as the vertical offset between the first target image area and the second target image area.

[0151] Specifically, the vertical offset between the first target image area and the second target image area may be determined by the following formula:

[0152] CenterOffsetY1=Max(|MetalRegionRow1-RectRegionRow1|,

[0153] |MetalRegionRow2-RectRegionRow2|)

[0154] Among them, CenterOffsetY1 is the vertical offset between the first target image area and the second target image area, MetalRegionRow1 is the horizontal coordinate array of the upper left vertex of the minimum bounding rectangle of each sub-image in the second image group, RectRegionRow1 is the horizontal coordinate array of the upper left vertex of the minimum bounding rectangle of each sub-image in the first image group, MetalRegionRow2 is the horizontal coordinate array of the lower right vertex of the minimum bounding rectangle of each sub-image in the second image group, and RectRegionRow2 is the horizontal coordinate array of the lower right vertex of the minimum bounding rectangle of each sub-image in the first image group.

[0155] In the present disclosure, the horizontal offset and vertical offset between the first target image area and the second target image area may also be determined by the following formula:

[0156] CenterOffsetX1=|MetalRegionCol-RectRegionCol|

[0157] CenterOffsetY1=|MetalRegionRow-RectRegionRow|

[0158] Among them, CenterOffsetX1 is the horizontal offset, CenterOffsetY1 is the vertical offset, MetalRegionRow is the horizontal coordinate array composed of the horizontal coordinates of the center points of each sub-image in the second image group, MetalRegionCol is the vertical coordinate array composed of the vertical coordinates of the center points of each sub-image in the second image group, RectRegionRow is the horizontal coordinate array composed of the horizontal coordinates of the center points of each sub-image in the first image group, and RectRegionCol is the vertical coordinate array composed of the vertical coordinates of the center points of each sub-image in the first image group.

[0159] In a possible implementation manner, determining the offset information between the first target image region and the third target image region may include steps M1-M2:

[0160] Step M1, determining the left edge difference and the right edge difference between the first target image area and the third target image area, and determining the larger difference between the left edge difference and the right edge difference as the horizontal offset between the first target image area and the third target image area.

[0161] Specifically, the horizontal offset between the first target image area and the third target image area may be determined by the following formula:

[0162] CenterOffsetX2=Max(|GoldLineRegionColumn1-RectRegionColumn1|,

[0163] |GoldLineRegionColumn2-RectRegionColumn2|)

[0164] Among them, CenterOffsetX2 is the horizontal offset between the first target image area and the third target image area, GoldLineRegionColumn1 is the vertical coordinate array of the upper left vertex of the minimum bounding rectangle of each sub-image in the third image group, RectRegionColumn1 is the vertical coordinate array of the upper left vertex of the minimum bounding rectangle of each sub-image in the first image group, GoldLineRegionColumn2 is the vertical coordinate array of the lower right vertex of the minimum bounding rectangle of each sub-image in the third image group, and RectRegionColumn2 is the vertical coordinate array of the lower right vertex of the minimum bounding rectangle of each sub-image in the first image group.

[0165] Step M2, determining the upper edge difference and the lower edge difference between the first target image area and the third target image area, and determining the larger difference between the upper edge difference and the lower edge difference as the vertical offset between the first target image area and the third target image area.

[0166] Specifically, the vertical offset between the first target image area and the third target image area may be determined by the following formula:

[0167] CenterOffsetY2=Max(|GoldLineRegionRow1-RectRegionRow1|,

[0168] |GoldLineRegionRow2-RectRegionRow2|)

[0169] Among them, CenterOffsetY2 is the vertical offset between the first target image area and the third target image area, GoldLineRegionRow1 is the horizontal coordinate array of the upper left vertex of the minimum bounding rectangle of each sub-image in the third image group, RectRegionRow1 is the horizontal coordinate array of the upper left vertex of the minimum bounding rectangle of each sub-image in the first image group, GoldLineRegionRow2 is the horizontal coordinate array of the lower right vertex of the minimum bounding rectangle of each sub-image in the third image group, and RectRegionRow2 is the horizontal coordinate array of the lower right vertex of the minimum bounding rectangle of each sub-image in the first image group.

[0170] In the present disclosure, the horizontal offset and vertical offset between the first target image area and the third target image area may also be determined by the following formula:

[0171] CenterOffsetX2=|GoldLineRegionCol-RectRegionCol|

[0172] CenterOffsetY2=|GoldLineRegionRow-RectRegionRow|

[0173] Among them, CenterOffsetX2 is the horizontal offset, CenterOffsetY2 is the vertical offset, GoldLineRegionRow is the horizontal coordinate array composed of the horizontal coordinates of the center points of each sub-image in the third image group, GoldLineRegionCol is the vertical coordinate array composed of the vertical coordinates of the center points of each sub-image in the third image group, RectRegionRow is the horizontal coordinate array composed of the horizontal coordinates of the center points of each sub-image in the first image group, and RectRegionCol is the vertical coordinate array composed of the vertical coordinates of the center points of each sub-image in the first image group.

[0174] In a possible implementation manner, the associating the first offset information and the second offset information with the product to be tested may include steps X1-X3:

[0175] Step X1, performing pixel equivalent conversion on the first offset information and the second offset information to obtain converted data.

[0176] In the present disclosure, the first offset information and the second offset information can be converted into corresponding pixel values ​​in the image by pixel equivalent conversion. Specifically, the pixels of the image area where there may be offset are multiplied by a preset pixel equivalent to obtain converted data. The preset pixel equivalent can be set according to actual application requirements, for example, set to 0.05 mm / pixel.

[0177] Step X2, performing compensation processing on the converted data based on a preset compensation value to obtain compensated data.

[0178] In the present disclosure, in order to make the converted data more accurate, a compensation value can usually be set to compensate the converted data, and the compensation value is generally set to 0.3 mm or 0.4 mm.

[0179] Step X3: associate and store the compensated data with the product attribute information of the product to be tested.

[0180] In the present disclosure, product attribute information of the product to be tested can be obtained from the product data of the product to be tested, and the product attribute information can include information such as a product ID and a product model that identify the product. An associated storage path is constructed, and the compensated data is associated with the product attribute information of the product to be tested and stored. Specifically, an associated storage path can be constructed based on information such as the storage path of the image to be tested, the detection time, the product attribute information, and the name of the image to be tested. For example, an associated storage path of "storage path of the image to be tested / date / product ID / image name" can be constructed, wherein the storage path of the image to be tested can be set by the user.

[0181] In the present disclosure, the compensated data can also be drawn on a target downsampled image, which is an image obtained by downsampling the image of the product to be tested, and then the target downsampled image on which the compensated data is drawn is stored. The user can intuitively observe whether the product to be tested has defects and the defect type by drawing the target downsampled image on which the compensated data is drawn.

[0182] In a possible implementation, the compensated data and product attribute information of the product to be measured may be associated and stored in a preset table, and the measurement method further includes: determining a defect position of the target product based on the preset table; and determining defect information of the target product according to the defect position.

[0183] In the present disclosure, the compensated data and the product attribute information of the product to be tested can be associated and stored in a CSV (Comma-Separated Values, a file format) table, or the measurement results of the product to be tested can be stored in a CSV table. Among them, the measurement results can include the results of whether there are defects in each area of ​​the product to be tested and the results of the types of defects that exist. The user can quickly determine whether the product to be tested has defects by viewing the CSV. If there are defects, the position of the defect of the product to be tested can be quickly located, and then the specific information of the defect can be observed based on the image and measurement data associated with the product to be tested.

[0184] By adopting the measurement method provided by the present disclosure, the overlap area can be determined by fitting the edge line segments of the image, constructing a rectangular threshold and other processing methods, and then the metal area and gold wire area with uncertain position and quantity in the product to be measured can be determined according to the overlap area, and then the problems of uncertain measurement position, uncertain number of measurement areas and large measurement background interference in industrial area measurement can be solved through the offset information. By adopting this method, not only can multiple metal areas and gold wire areas with uncertain position and quantity in the product to be measured be automatically measured, but also the accuracy of measurement is improved.

[0185] Based on the same inventive concept, according to the measurement method provided in the above embodiment of the present disclosure, correspondingly, another embodiment of the present disclosure further provides a measurement device, whose structural schematic diagram is shown in FIG. Fig.11 As shown, specifically including:

[0186] An image determination module 1101 is used to obtain an image of a product to be tested;

[0187] The edge extraction module 1102 is used to extract the image edge segments of the image of the product to be tested;

[0188] A first region determination module 1103 is used to determine a first target image region and a second target image region in the image of the product to be tested based on the image edge segment, wherein the first target image region is an overlapping image region between target components representing the product to be tested, and the second target image region is an image region representing the target components of the product to be tested;

[0189] A second region determining module 1104 is configured to determine a third target image region in the image of the product to be tested based on the image edge segment and the first target image region;

[0190] The offset information determination module 1105 is used to determine first offset information between the first target image area and the second target image area, and to determine second offset information between the first target image area and the third target image area;

[0191] The association module 1106 is used to associate the first offset information and the second offset information with the product to be tested.

[0192] By adopting the device, the first target image area, the second target image area and the third target image area in the image of the product to be tested can be determined through the image edge segments of the image of the product to be tested, and then the first offset information between the first target image area and the second target image area and the second offset information between the first target image area and the third target image area can be calculated, and the first offset information and the second offset information are associated with the product to be tested, so that the first offset information and the second offset information can be used to better determine the defect areas in the product to be tested with uncertain positions, unfixed numbers and complex interference information, thereby improving the accuracy of industrial visual measurement.

[0193] In one possible implementation, the image determination module 1101 is specifically configured to collect a color image of the product to be tested; and preprocess the color image to obtain a corresponding grayscale image as the product to be tested image.

[0194] In one possible implementation, the image determination module 1101 is specifically used to downsample the color image to obtain a downsampled image; split the color channels of the downsampled image, and determine the weights corresponding to the color channels based on the scene information corresponding to the product to be tested; determine the grayscale image corresponding to the downsampled image based on the weights corresponding to the color channels, and use the grayscale image as the image of the product to be tested.

[0195] In one possible implementation, the edge extraction module 1102 is specifically used to denoise the image of the product to be tested to obtain a denoised image; binarize the denoised image to obtain a binary image; extract each edge pixel point in the binary image; and fit a straight line based on each edge pixel point to obtain an image edge segment of the image of the product to be tested.

[0196] In one possible implementation, the edge extraction module 1102 is specifically used to calculate the distance between the remaining edge pixel points and the first line segment formed by any two edge pixel points; determine the edge pixel points whose distance to the first line segment is less than or equal to a preset distance threshold as the target pixel points corresponding to the first line segment; determine the first line segment with the largest number of corresponding target pixel points as the second line segment; and fit a straight line based on the target pixel points corresponding to the second line segment to obtain the fitted straight line as the image edge segment of the image of the product to be tested.

[0197] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.

[0198] Fig.12 A schematic block diagram of an example electronic device 1200 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0199] like Fig.12 As shown, the device 1200 includes a computing unit 1201, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1202 or a computer program loaded from a storage unit 1208 into a random access memory (RAM) 1203. In the RAM 1203, various programs and data required for the operation of the device 1200 can also be stored. The computing unit 1201, the ROM 1202, and the RAM 1203 are connected to each other via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.

[0200] A number of components in the device 1200 are connected to the I / O interface 1205, including: an input unit 1206, such as a keyboard, a mouse, etc.; an output unit 1207, such as various types of displays, speakers, etc.; a storage unit 1208, such as a disk, an optical disk, etc.; and a communication unit 1209, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1209 allows the device 1200 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0201] The computing unit 1201 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1201 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1201 performs the various methods and processes described above, such as the measurement method. For example, in some embodiments, the measurement method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 1208. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1200 via the ROM 1202 and / or the communication unit 1209. When the computer program is loaded into the RAM 1203 and executed by the computing unit 1201, one or more steps of the measurement method described above may be performed. Alternatively, in other embodiments, the computing unit 1201 may be configured to perform the measurement method in any other appropriate manner (e.g., by means of firmware).

[0202] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0203] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0204] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0205] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0206] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0207] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0208] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0209] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0210] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A measurement method, characterized in that: The method comprises: Acquire an image of the product to be tested; Extracting image edge segments of the image of the product to be tested; Based on the image edge segments, determining a first target image region and a second target image region in the image of the product to be tested, wherein the first target image region is an overlapping image region between target components representing the product to be tested, and the second target image region is an image region representing the target components of the product to be tested; Based on the image edge line segment and the first target image area, determining a third target image area in the image of the product to be tested, wherein the third target area represents an image area of ​​a surface feature of a target component of the product to be tested; Determine first offset information between the first target image area and the second target image area, and determine second offset information between the first target image area and the third target image area; The first offset information and the second offset information are associated with the product to be tested.

2. The method according to claim 1, characterized in that The step of obtaining the image of the product to be tested comprises: Collect color images of the product to be tested; The color image is preprocessed to obtain a corresponding grayscale image as the image of the product to be tested.

3. The method according to claim 2, characterized in that The preprocessing of the color image to obtain a corresponding grayscale image as the image of the product to be tested includes: Downsampling the color image to obtain a downsampled image; Splitting each color channel of the downsampled image, and determining a weight corresponding to each color channel based on scene information corresponding to the product to be tested; A grayscale image corresponding to the downsampled image is determined based on the weights corresponding to the color channels, and the grayscale image is used as the image of the product to be tested.

4. The method according to claim 1, characterized in that The step of extracting image edge segments of the image of the product to be tested comprises: Performing denoising processing on the image of the product to be tested to obtain a denoised image; Performing binarization processing on the denoised image to obtain a binarized image; Extracting each edge pixel point in the binary image; Based on the straight line fitting of each edge pixel point, the image edge segment of the image of the product to be tested is obtained.

5. The method according to claim 4, characterized in that The step of fitting straight lines based on the edge pixel points to obtain image edge segments of the image of the product to be tested includes: For a first line segment formed by any two edge pixels, calculating the distance between each remaining edge pixel and the first line segment; Determine an edge pixel point whose distance to the first line segment is less than or equal to a preset distance threshold as a target pixel point corresponding to the first line segment; Determine the first line segment with the largest number of corresponding target pixels as the second line segment; A straight line is fitted based on each target pixel point corresponding to the second line segment, and the fitted straight line is obtained as the image edge line segment of the image of the product to be tested.

6. The method according to claim 1, characterized in that The determining, based on the image edge segments, a first target image region and a second target image region in the image of the product to be tested comprises: Performing correction processing on the image of the product to be tested according to the image edge segments to obtain a corrected image; Determine a first rectangle in the image of the product to be tested based on the pixel coordinates at both ends of the image edge segment; Determine a first target image area in the image of the product to be tested according to the first rectangle; A second target image area in the image of the product to be tested is determined according to the first target image area.

7. The method according to claim 6, characterized in that The step of screening the first target image area in the image of the product to be tested according to the first rectangle includes: Performing segmentation processing on the image region corresponding to the first rectangle based on a first preset global threshold to obtain a first segmented image region; Performing a scattering process on the first segmented image region to obtain a plurality of sub-image regions, and obtaining a first image group consisting of the plurality of sub-image regions; A first target image area is determined according to the first image group.

8. A measuring device, characterized in that: The device comprises: An image determination module, used to obtain an image of a product to be tested; An edge extraction module, used to extract image edge segments of the image of the product to be tested; A first region determination module is used to determine a first target image region and a second target image region in the image of the product to be tested based on the image edge segment, wherein the first target image region is an overlapping image region between target components representing the product to be tested, and the second target image region is an image region representing the target components of the product to be tested; A second region determination module, configured to determine a third target image region in the image of the product to be tested based on the image edge segment and the first target image region; An offset information determination module is used to determine first offset information between the first target image area and the second target image area, and to determine second offset information between the first target image area and the third target image area; The association module is used to associate the first offset information and the second offset information with the product to be tested.

9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to make a computer execute the method according to any one of claims 1-7.