A method and device for measuring the size of irregular objects

By using the Harris corner point and Canny edge detection algorithm in large distortion scenarios, combined with chess corner point adjustment and dichotomy iterative calculation, the problem of low measurement accuracy of irregular object size under large distortion lenses is solved, and simplified camera calibration is achieved and high-precision measurements.

CN118134992BActive Publication Date: 2025-02-07XIAN TECH UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410115608.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-27
Publication Date
2025-02-07
Estimated Expiration
2044-01-27

AI Technical Summary

Technical Problem

In large distortion scenarios, the prior art is difficult to effectively correct lens distortion, resulting in low measurement accuracy of irregular object sizes and even inability to measure.

Method used

Through the Harris corner point detection algorithm and the Canny edge detection algorithm, the corner point of the chess grid calibration board and the outermost edge coordinates of the object are determined, combined with the adjustment of the chess grid corner point and the dichotomy method to loop iterate the intersection distance, and finally according to the chess grid, the chess grid is based on the chess grid. Quantity and proportion calculate object size.

Benefits of technology

Nonlinear distortion caused by large distortion lenses is needed, which simplifies camera calibration problems, reduces model complexity, and improves the accuracy and feasibility of measuring non-regular object sizes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118134992B_ABST
    Figure CN118134992B_ABST
Patent Text Reader

Abstract

The invention discloses a method and device for measuring the size of irregular objects, and relates to the field of optical measurement. The method is used to solve the problem that the method for measuring the size of irregular objects is complicated and has low precision when the lens with nonlinear distortion is too large. The method comprises: extracting the edge of the object from the image of the irregular object obtained by a large distortion camera to obtain the outermost edge coordinates of the irregular object; adding the four outermost edge coordinates corresponding to the longitudinal coordinates and the horizontal coordinates respectively included in the irregular object to the outermost edge point set; obtaining the four corner point coordinates of each outermost edge coordinate on the chessboard calibration plate according to the outermost edge coordinates and the chessboard corner points, and the four corner point coordinates belong to the image edge coordinate set; connecting the four corner point coordinates corresponding to each outermost edge coordinate diagonally to obtain the intersection point, traversing to determine the distance between each intersection point and the corresponding outermost edge coordinate, until the distance between each intersection point and the corresponding outermost edge coordinate is less than a third set value; obtaining the size of the irregular object according to the number of complete chessboards between the outermost edge points in the horizontal direction, the number of complete chessboards between the outermost edge points in the vertical direction, and the proportion of the area where the outermost edge point is located to the chessboard.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of optical measurement, and more specifically to a method and device for measuring the size of an irregular object. Background Art

[0002] Visual measurement technology has been widely used in the industrial field since the 1980s due to its non-contact, high-precision, automatic and efficient characteristics. The measurement of some large irregular objects, such as the height of trees, the size of equipment and components in the assembly process, etc., requires the camera to have a very large field of view to capture the overall clear appearance. Generally, the larger the field of view, the larger the field of view, and a large field of view will cause serious distortion. How to complete the measurement of object size in a large distortion scene is an urgent problem to be solved.

[0003] Many scholars at home and abroad have conducted research on the above-mentioned problems. For example, some people use the Levenberg-Marquardt method to iteratively optimize the internal and external parameters of the camera, and perform high-precision correction on the distorted image with a large field of view after eliminating bad points. Some people use the correction relationship to traverse each distortion point in the correction field to solve the distortion problem of large distortion lenses in the longitudinal direction, and control the correction range of the edge part through controllable parameters in the horizontal direction. The correction amount is obtained by combining trigonometric calculation and parameter transformation. Some people propose a method to correct the distortion of large distortion scenes using a double ellipse model, which has a good correction effect. Some people propose a measurement method based on fisheye lens to solve the problems of large measurement errors and inconvenient measurements in existing tree height measurement methods. This method is based on the equidistant projection model of the distortion coefficient, uses the Scaramuzza fisheye camera calibration method to solve the parameters and establish a measurement system model, and uses image processing technology to achieve tree height measurement.

[0004] However, the above methods all correct the distortion of large distortion lenses, and subsequent processing can only be performed after correction. The distortion model is usually nonlinear and requires a more complex algorithm model to correct it. In addition, the image corrected by the algorithm will have artifacts or blurs to varying degrees at the edge of the image, resulting in reduced measurement accuracy of the object size or even inability to measure the object. Summary of the invention

[0005] The embodiment of the present invention provides a method and device for measuring the size of an irregular object, which are used to solve the problem that the method for measuring the size of an irregular object is complex and has low precision when the distortion of a lens with nonlinear distortion is too large.

[0006] An embodiment of the present invention provides a method for measuring the size of an irregular object, comprising:

[0007] Determine the checkerboard corner points included in the checkerboard calibration plate by using the Harris corner point detection algorithm, extract the outline of the checkerboard calibration plate based on the Canny edge detection algorithm, and obtain an image edge coordinate set;

[0008] Extracting the edge of the object from the image of the irregular object acquired by the large distortion camera to obtain the outermost edge coordinates of the irregular object; adding the four outermost edge coordinates corresponding to the ordinate and the abscissa of the irregular object to the outermost edge point set;

[0009] Obtaining four corner point coordinates of each of the outermost edge coordinates on the chessboard calibration plate according to the outermost edge coordinates and the chessboard corner points, wherein the four corner point coordinates belong to the image edge coordinate set; diagonally connecting the four corner point coordinates corresponding to each of the outermost edge coordinates to obtain intersection points, and traversing to determine the distance between each intersection point and the corresponding outermost edge coordinate until the distance between each intersection point and the corresponding outermost edge coordinate is less than a third set value;

[0010] The size of the irregular object is obtained according to the number of complete chess squares between the outermost edge points in the horizontal direction, the number of complete chess squares between the outermost edge points in the vertical direction and the proportion of the area where the outermost edge points are located to the chess squares.

[0011] Preferably, the traversal to determine the distance between each intersection point and the corresponding outermost edge coordinate until the distance between each intersection point and the corresponding outermost edge coordinate is less than a third set value specifically includes:

[0012] If the distance between each intersection point and the corresponding outermost edge coordinate is not less than the third set value, when Px <E.x k And Py>Ey k , adjust the coordinates of the four corner points using the following formula:

[0013]

[0014] When Px>Ex k And Py>Ey k , adjust the coordinates of the four corner points using the following formula:

[0015]

[0016] When Px>Ex k And Py<Ey k , adjust the coordinates of the four corner points using the following formula:

[0017]

[0018] When Px<Ex kAnd Py<Ey k , adjust the coordinates of the four corner points using the following formula:

[0019]

[0020] Among them, P represents the intersection point, C1, C2, C3, and C4 represent the coordinates of the four corner points. num(C u ) and num(C v ) represents point C u With C v In the chessboard edge coordinate set U(x i ,y i ) in the position, bis(C u , C v ) indicates that in U(x i ,y i ) Point C u With C v The coordinate point that divides the interval into two.

[0021] Preferably, the adjusting the coordinates of the four corner points specifically includes:

[0022] According to Ex k , Ey k Determine the positional relationship between the outermost edge coordinates corresponding to the outermost edge coordinates and the intersection point corresponding to the outermost edge coordinates on the chessboard calibration plate coordinates, and determine the number of iterations required to adjust the coordinates of the four corner points according to the positional relationship:

[0023] When k = 1, , the number of iterations increases by 1; or

[0024] If k = 2, , the number of iterations increases by 1; or

[0025] If k = 3, , the number of iterations increases by 1; or

[0026] If k = 4, , the number of iterations increases by 1.

[0027] Preferably, the length and width of the irregular object are obtained according to the number of complete chess squares between the outermost edge points in the horizontal direction and the outermost edge points in the vertical direction and the proportion of the chess squares occupied by the area where the final edge point is located, which specifically includes:

[0028] A model is established based on the number of complete chess squares between the horizontal outermost edge point and the vertical outermost edge point and the proportion of the chess squares occupied by the area where the final edge point is located. The length and width of the irregular object are obtained based on the above model. The model is as follows:

[0029]

[0030] Where j = 1, 2, Represents point E(x k ,y k ) The required calculation area accounts for the proportion of the chess grid, BD size Represents the actual size of a single chess grid. When j = 1, N j Indicates the number of complete chessboards between the outermost edge points in the vertical direction, l j represents the height of the irregular object; when j=2, N j Indicates the number of complete chessboards between the outermost edge points in the horizontal direction, l j Indicates the length of the irregular object.

[0031] Preferably, the determining of the chessboard corner points included in the chessboard calibration plate by using the Harris corner point detection algorithm specifically includes:

[0032] Determine the corner point response function corresponding to each pixel point included in the chessboard calibration plate by using the Harris corner point detection algorithm, perform non-maximum simulation on the corner point response function, and determine the pixel point corresponding to the corner point response function greater than a first threshold as the chessboard corner point;

[0033] The angular response function is as follows:

[0034] R=detST-k(trST) 2

[0035] in, G x and G y Represents the gradient of the pixel points in the x and y directions in the image coordinate system, det ST represents the determinant, k represents the empirical coefficient.

[0036] Preferably, extracting the edge of the object from the image of the irregular object acquired by the large distortion camera to obtain the coordinates of the outermost edge of the irregular object specifically includes:

[0037] Based on U 2 -Net image segmentation algorithm to obtain a foreground image of an irregular object acquired by a large distortion camera, and a Canny edge detection algorithm to extract the object edge from the foreground image;

[0038] Compare the horizontal coordinates of the edge of the object with the horizontal coordinates included in the outline of the checkerboard calibration plate, and take the two points with the smallest distances from the horizontal coordinates included in the outline of the checkerboard calibration plate as the outermost edge points;

[0039] The ordinate of the edge of the object is compared with the ordinate included in the outline of the checkerboard calibration plate, and the two points with the smallest distance from the ordinate included in the outline of the checkerboard calibration plate are taken as the outermost edge points.

[0040] An embodiment of the present invention provides a device for measuring the size of an irregular object, comprising:

[0041] A first obtaining unit is used to determine the chessboard corner points included in the chessboard calibration plate by using a Harris corner point detection algorithm, extract the outline of the chessboard calibration plate based on a Canny edge detection algorithm, and obtain an image edge coordinate set;

[0042] An adding unit is used to extract the edge of the object from the irregular object image obtained by the large distortion camera to obtain the outermost edge coordinates of the irregular object; and add the four outermost edge coordinates corresponding to the ordinate and the abscissa of the irregular object to the outermost edge point set;

[0043] a determination unit, configured to obtain four corner point coordinates of each of the outermost edge coordinates on the chessboard calibration plate according to the outermost edge coordinates and the chessboard corner points, wherein the four corner point coordinates belong to the image edge coordinate set; diagonally connect the four corner point coordinates corresponding to each of the outermost edge coordinates to obtain intersection points, and traverse to determine the distance between each intersection point and the corresponding outermost edge coordinate until the distance between each intersection point and the corresponding outermost edge coordinate is less than a third set value;

[0044] The second obtaining unit is used to obtain the size of the irregular object according to the number of complete chess squares between the outermost edge points in the horizontal direction, the number of complete chess squares between the outermost edge points in the vertical direction and the proportion of the area where the outermost edge points are located to the chess squares.

[0045] An embodiment of the present invention provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes any one of the above-mentioned methods for measuring the size of an irregular object.

[0046] An embodiment of the present invention provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor executes any one of the above-mentioned methods for measuring the size of an irregular object.

[0047] The embodiment of the present invention provides a method and device for measuring the size of an irregular object. The method comprises: determining the chessboard corner points included in a chessboard calibration plate by using a Harris corner point detection algorithm, extracting the contour of the chessboard calibration plate based on a Canny edge detection algorithm, and obtaining an image edge coordinate set; extracting the object edge from an irregular object image obtained by a large distortion camera to obtain the outermost edge coordinates of the irregular object; adding four outermost edge coordinates corresponding to the longitudinal coordinates and the abscissas included in the irregular object to the outermost edge point set; and determining the outermost edge coordinates according to the outermost edge coordinates and the chessboard corner points. The four corner point coordinates of each of the outermost edge coordinates on the chessboard calibration plate are obtained, and the four corner point coordinates belong to the image edge coordinate set; the four corner point coordinates corresponding to each of the outermost edge coordinates are diagonally connected to obtain intersections, and the distance between each intersection and the corresponding outermost edge coordinate is traversed to determine until the distance between each intersection and the corresponding outermost edge coordinate is less than a third set value; the size of the irregular object is obtained according to the number of complete chess squares between the outermost edge points in the horizontal direction, the number of complete chess squares between the outermost edge points in the vertical direction, and the proportion of the area where the outermost edge point is located to the chess squares. The proposed irregular object measurement method uses a large distortion lens to shoot the irregular object to be measured and the chessboard image, obtains the outermost edge point and chessboard corner point of the irregular object, uses the binary method to iteratively calculate the Euclidean distance between the intersection of the chessboard corner point connection point and the outermost edge point, so that it is less than a certain range, and finally calculates the number of complete chessboards between the outermost edge points in the horizontal and vertical directions, and combines the proportion of the area where the outermost edge point is located in the chessboard to obtain the object size, thereby overcoming the difficulty in establishing a nonlinear distortion model of a large distortion lens, which leads to the difficulty and low precision of measuring the size of irregular objects. The present invention does not need to consider the nonlinear distortion caused by the correction of the large distortion lens, simplifies the camera calibration problem under large distortion conditions in visual measurement, and reduces the model complexity when using a large distortion lens to measure irregular objects. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0049] Figure 1 A schematic diagram of a flow chart of a method for measuring the size of an irregular object provided by an embodiment of the present invention;

[0050] Figure 2 A schematic diagram of chessboard corner point detection provided by an embodiment of the present invention;

[0051] Figure 3A schematic diagram of chessboard edge extraction provided by an embodiment of the present invention;

[0052] Figure 4 A schematic diagram of obtaining the outermost edge points of an irregular object provided by an embodiment of the present invention;

[0053] Figure 5 A schematic diagram of dividing a chessboard area where the outermost edge point is located provided in an embodiment of the present invention;

[0054] Figure 6 A schematic diagram of using the binary search method to iteratively calculate the distance between the intersection of the lines connecting the corner points of a chessboard and the outermost edge point provided by an embodiment of the present invention;

[0055] Figure 7 A schematic structural diagram of a device for measuring the size of an irregular object provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0056] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0057] Figure 1 A schematic diagram of a method for measuring the size of an irregular object provided by an embodiment of the present invention; Figure 1 As shown, a method for measuring the size of an irregular object provided by an embodiment of the present invention mainly includes the following steps:

[0058] Step 101: determine the checkerboard corner points included in the checkerboard calibration plate by using the Harris corner point detection algorithm, extract the outline of the checkerboard calibration plate based on the Canny edge detection algorithm, and obtain the image edge coordinate set (U(x i ,y j ),0 <i<h,0<j<w,i∈N * , where the image size is h×w);

[0059] Step 102: extract the edge of the object from the image of the irregular object acquired by the large distortion camera to obtain the outermost edge coordinates of the irregular object; add the four outermost edge coordinates corresponding to the ordinate and abscissa of the irregular object to the outermost edge point set (d k ∈E(x k ,y k ));

[0060] Step 103, obtaining four corner point coordinates of each of the outermost edge coordinates on the chessboard calibration plate according to the outermost edge coordinates and the chessboard corner points, wherein the four corner point coordinates belong to the image edge coordinate set; diagonally connecting the four corner point coordinates corresponding to each of the outermost edge coordinates to obtain intersection points, and traversing to determine the distance between each intersection point and the corresponding outermost edge coordinate until the distance between each intersection point and the corresponding outermost edge coordinate is less than a third set value;

[0061] Step 104, the size of the irregular object is obtained according to the number of complete squares between the outermost edge points in the horizontal direction, the number of complete squares between the outermost edge points in the vertical direction, and the proportion of the outermost edge area to the squares.

[0062] In step 101, the checkerboard corner points included in the checkerboard calibration plate are first determined by using the Harris corner point detection algorithm. Specifically, Figure 2 On the chessboard calibration plate image shown in the figure, assume that the gradients of the pixels in the x-direction and the y-direction are G x and G y , using the Gaussian filter function f u,v The image is filtered for noise and the structure tensor is constructed as described in formula (1):

[0063]

[0064] Among them, ST represents the structure tensor, f u,v represents the Gaussian filter function, G xy Represents the product of two gradient directions, G xy =G x ×G y .

[0065] Furthermore, based on the Harris corner detection algorithm, the following corner response function is obtained:

[0066] R=detST-k(trST) 2 (2)

[0067] Where R represents the angular response function, det ST represents the determinant of the matrix ST, trST represents the trajectory of the matrix ST, k represents the empirical coefficient, which is generally 0.04 to 0.06.

[0068] Furthermore, each pixel is compared with the R value of the pixels in the area, and the R value of the pixel that is not a maximum value is set to 0. Then, the pixels with R values ​​greater than the first threshold are marked as corner points, which are chessboard corner points.

[0069] In step 101, the outline of the checkerboard calibration plate is extracted based on the Canny edge detection algorithm to obtain an image edge coordinate set. Specifically, in order to reduce the impact of noise on the edge detection result, in the embodiment of the present invention, a 5×5 Gaussian convolution kernel template is used to convolve the grayscale image of the checkerboard calibration plate, and Gaussian smoothing filtering is performed; the edge gradient in the x-direction and y-direction is calculated using the Sobel edge difference operator, and the gradient amplitude G and the gradient direction θ are calculated based on the gradient and the gradient amplitude is standardized; the local maximum value of the pixel gradient amplitude is found along the gradient direction, and non-maximum elements are suppressed.

[0070] Furthermore, the OTSU algorithm is used to determine the high threshold, and half of the high threshold is used as the low threshold. The edge pixel points with gradient amplitudes higher than the high threshold and lower than the low threshold are suppressed to obtain the image edge coordinate set of the checkerboard calibration plate. Figure 3 The outline of the checkerboard calibration plate is shown.

[0071] In the embodiment of the present invention, the image edge coordinate set is represented as U(x i ,y j ), where 0<i<h, 0<j<w, i∈N * , the image size of the checkerboard calibration plate is h×w.

[0072] In step 102, the edge of the object is extracted from the image of the irregular object acquired by the large distortion camera to obtain the outermost edge coordinates of the irregular object, specifically including: based on U 2 -Net image segmentation algorithm obtains a foreground image of an irregular object acquired by a large distortion camera, and uses the Canny edge detection algorithm to extract the object edge from the foreground image.

[0073] Furthermore, the horizontal coordinates of the edge points of the object are compared with the horizontal coordinates included in the outline of the checkerboard calibration plate, and the two points with the smallest distances from the horizontal coordinates included in the outline of the checkerboard calibration plate are taken as the outermost edge points; the vertical coordinates of the edge of the object are compared with the vertical coordinates included in the outline of the checkerboard calibration plate, and the two points with the smallest distances from the vertical coordinates included in the outline of the checkerboard calibration plate are taken as the outermost edge points. Figure 4 The d1, d2, d3, and d4 shown are the four outermost edge points on the determined irregular object image.

[0074] For example, if the size of the image is h×w, the horizontal coordinates of the edge points of the object are compared with 0 and h, and the two points with the smallest distances between 0 and h are selected as the outermost edge points; the vertical coordinates of the edge points of the object are compared with 0 and w, and the two points with the smallest distances between 0 and w are selected as the outermost edge points.

[0075] Further, the four outermost edge coordinates corresponding to the longitudinal coordinates and the horizontal coordinates of the irregular object are added to the outermost edge point set. For example, the two outermost edge points for calculating the longitudinal dimension are d1 and d2 respectively, and the two outermost edge points for calculating the horizontal dimension are d3 and d4 respectively. The four outermost edge coordinate points are added to the outermost edge set, where the outermost edge set is: E(x k ,y k ), the four outermost edge coordinate points added to the outermost edge point set can be expressed as: d k ∈E(x k ,y k ), k=1, 2, 3, 4.

[0076] In step 103, the coordinates of the four corner points of each outermost edge coordinate on the chessboard calibration board are obtained according to the outermost edge coordinates and the chessboard calibration board including the chessboard corner points, such as Figure 5 As shown, each outermost edge point (d1, d2, d3, d4) corresponds to four corner point coordinates (C1, C2, C3, C4). In the embodiment of the present invention, the four corner point coordinates belong to the image edge coordinate set.

[0077] Furthermore, the four corner point coordinates corresponding to each outermost edge coordinate are connected diagonally, so that an intersection point of the four corner point coordinates can be obtained, such as Figure 6 As shown, the intersection point in the figure is P, and the coordinates of the four corner points in the figure are C1, C2, C3, and C4, respectively. The distance between each intersection point and its corresponding outermost edge coordinate is determined in turn. When the Euclidean distance between the intersection point and its corresponding outermost edge coordinate is greater than 0.1 pixel, the four corner point coordinates need to be adjusted until the distance between the intersection of the four corner point coordinates and their corresponding outermost edge coordinate is less than a third set value, where the third set value is a Euclidean distance less than 0.1 pixel.

[0078] In the embodiment of the present invention, when the coordinates of the four corner points are adjusted according to the positional relationship between the intersection point and the outermost edge coordinates corresponding thereto, the following four situations are included:

[0079] 1) If Px<Ex k And Py>Ey k , then adjust the coordinates of the four corner points using the following formula:

[0080]

[0081] It should be noted that Px and Py here represent the horizontal and vertical coordinates of the intersection respectively. k and Ey k Respectively represent the horizontal and vertical coordinates of the outermost edge point.

[0082] in, num(C u ) and num(C v ) represents point C u With C v In the chessboard edge coordinate set U(x i ,y i ) in the position, bis(C u , C v ) indicates that in U(x i ,y i ) Point C u With C v The coordinate point that divides the interval into two.

[0083] 2) If Px>Ex k And Py>Ey k , then adjust the coordinates of the four corner points using the following formula:

[0084]

[0085] 3) If Px>Ex k And Py<Ey k , then adjust the coordinates of the four corner points using the following formula:

[0086]

[0087] 4) If Px<Ex k And Py<Ey k , then adjust the coordinates of the four corner points using the following formula:

[0088]

[0089] It should be noted that due to Ex k and Ey k In the embodiment of the present invention, the approximate position of the outermost edge point in the chessboard calibration plate can be determined according to the specific values ​​corresponding to the abscissa and ordinate of the outermost edge point. Based on this, the number of iterations required to adjust the coordinates of the four corner points can be determined according to the intersection of the coordinates of the four corner points and the orientation of a certain outermost edge coordinate. Specifically, when k=1, When , the number of iterations ε increases by 1; if k = 2, When , the number of iterations ε increases by 1; if k = 3, When , the number of iterations ε increases by 1; if k = 4, When , the number of iterations ε increases by 1.

[0090] It should be noted that, in this embodiment, there are a total of four outermost edge coordinates, so the above steps need to be repeated three times until the Euclidean distance between the intersection of the four corner point coordinates corresponding to each outermost edge coordinate and the outermost edge coordinate is less than 0.1 pixel.

[0091] In step 105, a model as shown below is established based on the number of complete squares included between the most edge points in the horizontal direction, the number of complete squares included between the most outer edge points in the vertical direction, and the proportion of the area where the most outer edge points are located in the squares, and the size of the irregular object is obtained based on the model.

[0092]

[0093] Where j = 1, 2, Represents point E(x k ,y k ) The required calculation area accounts for the proportion of the chess grid, BD size Represents the actual size of a single chess grid. When j = 1, N j Indicates the number of complete chessboards between the outermost edge points in the vertical direction, l j represents the height of the irregular object; when j=2, N j Indicates the number of complete chessboards between the outermost edge points in the horizontal direction, l j Indicates the length of the irregular object.

[0094] The irregular object measurement method proposed in the present invention uses a large distortion lens to shoot the irregular object to be measured and the chessboard image, obtains the outermost edge point and the chessboard corner point of the irregular object, and uses the binary method to iteratively calculate the Euclidean distance between the intersection of the chessboard corner point connection point and the outermost edge point, so that it is less than a certain range, and finally calculates the number of complete chessboards between the outermost edge points in the horizontal and vertical directions, and combines the proportion of the area where the outermost edge point is located in the chessboard to obtain the object size, thereby overcoming the difficulty in establishing a nonlinear distortion model of a large distortion lens, which leads to the difficulty and low precision of measuring the size of irregular objects. The present invention does not need to consider the nonlinear distortion caused by the correction of the large distortion lens, simplifies the camera calibration problem under large distortion conditions in visual measurement, and reduces the model complexity when using a large distortion lens to measure irregular objects.

[0095] Based on the same inventive concept, an embodiment of the present invention provides a device for measuring the size of an irregular object. Since the principle of solving the technical problem of the device is similar to that of a method for measuring the size of an irregular object, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0096] Figure 7 A schematic diagram of a device for measuring the size of an irregular object provided by an embodiment of the present invention is shown in FIG. Figure 7As shown, the device includes a first obtaining unit 701, an adding unit 702, a determining unit 703 and a second obtaining unit 704.

[0097] The first obtaining unit 701 is used to determine the chessboard corner points included in the chessboard calibration plate by using the Harris corner point detection algorithm, extract the outline of the chessboard calibration plate based on the Canny edge detection algorithm, and obtain an image edge coordinate set;

[0098] An adding unit 702 is used to extract the edge of the object from the irregular object image obtained by the large distortion camera to obtain the outermost edge coordinates of the irregular object; and add the four outermost edge coordinates corresponding to the ordinate and the abscissa of the irregular object to the outermost edge point set;

[0099] A determination unit 703 is configured to obtain four corner point coordinates of each of the outermost edge coordinates on the chessboard calibration plate according to the outermost edge coordinates and the chessboard corner points, wherein the four corner point coordinates belong to the image edge coordinate set; diagonally connect the four corner point coordinates corresponding to each of the outermost edge coordinates to obtain intersection points, and traverse to determine the distance between each intersection point and the corresponding outermost edge coordinate until the distance between each intersection point and the corresponding outermost edge coordinate is less than a third set value;

[0100] The second obtaining unit 704 is used to obtain the size of the irregular object according to the number of complete squares between the outermost edge points in the horizontal direction, the number of complete squares between the outermost edge points in the vertical direction and the proportion of the area where the outermost edge points are located to the squares.

[0101] It should be understood that the units included in the above irregular object size measurement device are only logical divisions based on the functions implemented by the device. In practical applications, the above units can be superimposed or split. In addition, the functions implemented by the irregular object size measurement device provided in this embodiment correspond to the irregular object size measurement method provided in the above embodiment. The more detailed processing flow implemented by the device has been described in detail in the above method embodiment 1 and will not be described in detail here.

[0102] Another embodiment of the present invention further provides a computer device, comprising: a processor and a memory; the memory is used to store computer program code, and the computer program code includes computer instructions; when the processor executes the computer instructions, the electronic device executes each step of measuring the size of irregular objects in the method flow shown in the above method embodiment.

[0103] Another embodiment of the present invention further provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed on a computer device, the computer device executes each step of measuring the size of an irregular object in the method flow shown in the above method embodiment.

[0104] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0105] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for measuring the size of an irregular object, characterized in that: include: Determine the checkerboard corner points included in the checkerboard calibration plate by using the Harris corner point detection algorithm, extract the outline of the checkerboard calibration plate based on the Canny edge detection algorithm, and obtain an image edge coordinate set; Extracting the edge of the object from the image of the irregular object acquired by the large distortion camera to obtain the outermost edge coordinates of the irregular object; adding the four outermost edge coordinates corresponding to the ordinate and the abscissa of the irregular object to the outermost edge point set; Obtaining four corner point coordinates of each of the outermost edge coordinates on the chessboard calibration plate according to the outermost edge coordinates and the chessboard corner points, wherein the four corner point coordinates belong to the image edge coordinate set; diagonally connecting the four corner point coordinates corresponding to each of the outermost edge coordinates to obtain intersection points, and traversing to determine the distance between each intersection point and the corresponding outermost edge coordinate until the distance between each intersection point and the corresponding outermost edge coordinate is less than a third set value; The size of the irregular object is obtained according to the number of complete chess squares between the outermost edge points in the horizontal direction, the number of complete chess squares between the outermost edge points in the vertical direction, and the ratio of the area where the outermost edge points are located to the chess squares; The traversal to determine the distance between each intersection point and the corresponding outermost edge coordinate until the distance between each intersection point and the corresponding outermost edge coordinate is less than a third set value specifically includes: If the distance between each intersection point and the corresponding outermost edge coordinate is not less than the third set value, when Px <E.x k And Py>Ey k , adjust the coordinates of the four corner points using the following formula: When Px>Ex k And Py>Ey k , adjust the coordinates of the four corner points using the following formula: When Px>Ex k And Py <E.y k , adjust the coordinates of the four corner points using the following formula: When Px <E.x k And Py <E.y k , adjust the coordinates of the four corner points using the following formula: The adjusting of the coordinates of the four corner points specifically includes: According to Ex k , Ey k Determine the positional relationship between the outermost edge coordinates corresponding to the outermost edge coordinates and the intersection point corresponding to the outermost edge coordinates on the chessboard calibration plate coordinates, and determine the number of iterations required to adjust the coordinates of the four corner points according to the positional relationship: When k = 1, , the number of iterations increases by 1; or If k = 2, , the number of iterations increases by 1; or If k = 3, , the number of iterations increases by 1; or If k = 4, When , the number of iterations increases by 1; Among them, P represents the intersection point, C1, C2, C3, and C4 represent the coordinates of the four corner points. num(C u ) and num(C v ) represents point C u With C v In the chessboard edge coordinate set U(x i ,y i ) in the position, bis(C u ,C v ) indicates that in U(x i ,y i ) Point C u With C v The coordinate point that divides the interval into two.

2. The method for measuring the size of an irregular object according to claim 1, characterized in that: According to the number of complete chess squares between the horizontal outermost edge point and the vertical outermost edge point and the proportion of the chess squares occupied by the area where the final edge point is located, the length and width of the irregular object are obtained, including: A model is established based on the number of complete chess squares between the horizontal outermost edge point and the vertical outermost edge point and the proportion of the chess squares occupied by the area where the final edge point is located. The length and width of the irregular object are obtained based on the above model. The model is as follows: Where j = 1, 2, Represents point E(x k ,y k ) The required calculation area accounts for the proportion of the chess grid, BD size Represents the actual size of a single chess grid. When j = 1, N j Indicates the number of complete chessboards between the outermost edge points in the vertical direction, l j represents the height of the irregular object; when j=2, N j Indicates the number of complete chessboards between the outermost edge points in the horizontal direction, l j Indicates the length of the irregular object.

3. The method for measuring the size of an irregular object according to claim 1, characterized in that: The step of determining the chessboard corner points included in the chessboard calibration plate by using the Harris corner point detection algorithm specifically includes: Determine the corner point response function corresponding to each pixel point included in the chessboard calibration plate by using the Harris corner point detection algorithm, perform non-maximum simulation on the corner point response function, and determine the pixel point corresponding to the corner point response function greater than a first threshold as the chessboard corner point; The angular response function is as follows: R=detST-k(trST) 2 in, G x and G y Represents the gradient of the pixel points in the x and y directions in the image coordinate system, detST represents the determinant, k represents the empirical coefficient.

4. The method for measuring the size of an irregular object according to claim 1, characterized in that: The step of extracting the edge of the object from the image of the irregular object acquired by the large distortion camera to obtain the outermost edge coordinates of the irregular object specifically includes: Based on U 2 -Net image segmentation algorithm to obtain a foreground image of an irregular object acquired by a large distortion camera, and a Canny edge detection algorithm to extract the object edge from the foreground image; Compare the horizontal coordinates of the edge of the object with the horizontal coordinates included in the outline of the checkerboard calibration plate, and take the two points with the smallest distances from the horizontal coordinates included in the outline of the checkerboard calibration plate as the outermost edge points; The ordinate of the edge of the object is compared with the ordinate included in the outline of the checkerboard calibration plate, and the two points with the smallest distance from the ordinate included in the outline of the checkerboard calibration plate are taken as the outermost edge points.

5. A device for measuring the size of irregular objects, characterized in that: include: A first obtaining unit is used to determine the chessboard corner points included in the chessboard calibration plate by using a Harris corner point detection algorithm, extract the outline of the chessboard calibration plate based on a Canny edge detection algorithm, and obtain an image edge coordinate set; An adding unit is used to extract the edge of the object from the irregular object image obtained by the large distortion camera to obtain the outermost edge coordinates of the irregular object; and add the four outermost edge coordinates corresponding to the ordinate and the abscissa of the irregular object to the outermost edge point set; a determination unit, configured to obtain four corner point coordinates of each of the outermost edge coordinates on the chessboard calibration plate according to the outermost edge coordinates and the chessboard corner points, wherein the four corner point coordinates belong to the image edge coordinate set; diagonally connect the four corner point coordinates corresponding to each of the outermost edge coordinates to obtain intersection points, and traverse to determine the distance between each intersection point and the corresponding outermost edge coordinate until the distance between each intersection point and the corresponding outermost edge coordinate is less than a third set value; The second obtaining unit is used to obtain the size of the irregular object according to the number of complete chess squares between the outermost edge points in the horizontal direction, the number of complete chess squares between the outermost edge points in the vertical direction, and the proportion of the area where the outermost edge points are located to the chess squares; The determining unit is specifically used for: If the distance between each intersection point and the corresponding outermost edge coordinate is not less than the third set value, when Px <E.x k And Py>Ey k , adjust the coordinates of the four corner points using the following formula: When Px>Ex k And Py>Ey k , adjust the coordinates of the four corner points using the following formula: When Px>Ex k And Py <E.y k , adjust the coordinates of the four corner points using the following formula: When Px <E.x k And Py <E.y k , adjust the coordinates of the four corner points using the following formula: The determining unit is further configured to: According to Ex k , Ey k Determine the positional relationship between the outermost edge coordinates corresponding to the outermost edge coordinates and the intersection point corresponding to the outermost edge coordinates on the chessboard calibration plate coordinates, and determine the number of iterations required to adjust the coordinates of the four corner points according to the positional relationship: When k = 1, , the number of iterations increases by 1; or If k = 2, , the number of iterations increases by 1; or If k = 3, , the number of iterations increases by 1; or If k = 4, When , the number of iterations increases by 1; Among them, P represents the intersection point, C1, C2, C3, and C4 represent the coordinates of the four corner points. num(C u ) and num(C v ) represents point C u With C v In the chessboard edge coordinate set U(x i ,y i ) in the position, bis(C u ,C v ) indicates that in U(x i ,y i ) Point C u With C v The coordinate point that divides the interval into two.

6. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the irregular object size measurement method according to any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that: A computer program is stored, and when the computer program is executed by a processor, the processor executes the irregular object size measurement method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Lens distortion correcting method and system used for automatic optical detection

    CN105701776A

  • Galvanometer scanning system calibration method based on double checkerboards

    CN111536902A