Ellipse edge detection method based on normal vector constraint

Through the elliptical edge detection method based on normal vector constraints, binocular cameras and deep learning segmentation, sector partitioning and histogram equalization processing, combined with normal vector and gradient information, the RANSAC algorithm is used to fit the elliptical edge, solving the accuracy and speed problems in the existing elliptical detection algorithm, and achieving high-precision and real-time elliptical edge detection.

CN120495327AActive Publication Date: 2025-08-15ZHEJIANG UNIV
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510520534.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-24
Publication Date
2025-08-15
Estimated Expiration
2045-04-24

AI Technical Summary

Technical Problem

The existing ellipse detection algorithms have problems such as the fitted ellipse profile does not exactly coincide with the actual profile, the error detection of non-ellipse targets, the detection takes a long time and it is difficult to meet the real-time requirements.

Method used

The elliptical edge detection method based on normal vector constraints is adopted, images are collected through binocular cameras, deep learning segmentation, sector partitioning and histogram equalization are used, and local non-maximum suppression is performed in combination with normal vector and gradient information, and the optimal elliptical edge is fitted using the RANSAC algorithm.

Benefits of technology

It improves the accuracy and speed of elliptical edge detection, enhances the significance of edge features, and ensures the accuracy and real-time detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120495327A_ABST
    Figure CN120495327A_ABST
Patent Text Reader

Abstract

The invention discloses an ellipse edge detection method based on normal vector constraint. The method comprises the steps that firstly, a binocular camera is used for collecting an ellipse-containing target image, a coarse ellipse image is obtained after segmentation, and an equalized ellipse local fan-shaped image is obtained after fan-shaped partitioning and equalization processing; and then performing normal vector constraint and local non-maximum suppression processing to obtain candidate arc segments, finally performing error screening to obtain an optimal arc segment set, fitting the optimal arc segment set into an optimal ellipse, and finally detecting the edge of the ellipse. According to the method, a fan-shaped mask is introduced, histogram equalization is carried out, the ellipse edge gradient is enhanced, and the edge features are more remarkable; local non-maximum suppression is carried out according to the normal vector direction, so that the edge detection precision is improved; according to the method, a higher selection probability is set for a long arc section, and the arc sections with overlapped polar angle ranges are removed, so that the arc section closest to the edge is screened out, the ellipse fitting precision is improved, and the ellipse edge is detected more accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to an ellipse edge detection method, in particular to an ellipse edge detection method based on normal vector constraints. Background Art

[0002] In recent years, ellipse detection, a key task in fields such as machine vision and pattern recognition, has been crucial for the development of technologies such as camera calibration, pose detection, object segmentation, and iris recognition. However, existing ellipse detection algorithms generally face a series of problems, including incomplete overlap between the fitted ellipse contour and the actual contour, false detection of non-elliptical objects, and time-consuming detection that fails to meet real-time requirements.

[0003] Currently, mainstream ellipse detection methods can be categorized into three categories: clustering and voting-based methods, optimization-based methods, and edge-connection-based methods. The Hough transform's principle is to transform lines and curves represented by equations in space into points in parameter space. The parameters of the ellipse are determined by searching for local peaks in the accumulator space through feature voting. However, because an ellipse requires five parameters, the Hough transform requires significant computational resources and is extremely time-consuming. Ellipse detection methods based on edge connection extract arc segment information from image edge detection results and then utilize the geometric properties of ellipses to detect ellipses. Arc segments contain more information than discrete points and better reflect the geometric shape of an ellipse, thus offering higher accuracy. Optimization-based ellipse detection methods utilize the least squares method to optimize the objective function based on the input image and ultimately complete the fitting of the ellipse. While these studies have improved ellipse detection, they still face challenges such as false detection of non-elliptical objects, inaccurate ellipse edge information, and a high computational cost. Summary of the Invention

[0004] In order to solve the problems existing in the background technology, the present invention provides an ellipse edge detection method based on normal vector constraints.

[0005] The technical solution adopted in the present invention is:

[0006] The ellipse edge detection method based on normal vector constraint of the present invention is characterized by comprising:

[0007] Step 1) Use a binocular camera to capture a target image containing an ellipse, obtain a coarse ellipse image after segmentation, and then perform sector partitioning and equalization on the coarse ellipse image to obtain several equalized ellipse local sector images.

[0008] Step 2) Each equalized elliptical local sector image is subjected to normal vector constraint and local non-maximum suppression processing to obtain several candidate arc segments.

[0009] Step 3) After error screening of each candidate arc segment, the optimal arc segment set is obtained and fitted into an optimal ellipse, and finally the edge of the ellipse is detected.

[0010] The step 1) is as follows:

[0011] In step 1.1), the target image containing the ellipse is segmented using a semantic segmentation method based on deep learning to obtain a coarse ellipse image containing only a single ellipse. The coarse ellipse image is subjected to mask dilation and erosion processing to obtain an ellipse edge ring mask.

[0012] Step 1.2) Establish a polar coordinate system on the coarse ellipse image, divide the ellipse edge ring mask into n sector masks according to the polar angle, and perform an AND operation on each sector mask and the coarse ellipse image to obtain n ellipse local sector images.

[0013] Step 1.3) Perform histogram equalization on each elliptical local sector image to obtain n equalized elliptical local sector images.

[0014] The step 2) is as follows:

[0015] Step 2.1) For each equalized elliptical local sector image, obtain the normal vector of each pixel in the equalized elliptical local sector image, and use the Sobel operator to obtain the pixel gradient of each pixel. After performing a dot product between the normal vector and the pixel gradient of each pixel and converting them to the range of 0-255, obtain the grayscale value of the current pixel.

[0016] Step 2.2) Based on the grayscale values of each pixel and its eight-connected neighborhood pixels, edge extraction is performed using local non-maximum suppression processing to screen out several candidate arc segments.

[0017] The step 2.2) is as follows:

[0018] For each pixel, the relative coordinate set Q of the eight-connected neighborhood pixels of the pixel is obtained as follows:

[0019] Q={(x i -1,y i -1),(x i ,y i -1),(x i +1,y i -1),(x i -1,y i ),

[0020] (x i +1,y i ),(x i -1,y i +1),(xi ,y i +1),(x i +1,y i +1)}

[0021] Among them, x i and y i They represent the x-axis and y-axis coordinates of the i-th pixel in the image coordinate system of the rough ellipse image.

[0022] Get the gray value set P of each pixel in the relative coordinate set Q of the eight-connected neighborhood pixels, P = {p k |k=1,2,...,8},p k Represent the grayscale value of the kth pixel in the relative coordinate set Q of the eight-connected neighborhood pixels; then obtain the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the rough ellipse image.

[0023] The candidate point set S is divided according to the gray value set P of each pixel in the relative coordinate set Q of the eight-connected neighborhood pixels and the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the rough ellipse image as follows:

[0024]

[0025] According to the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the rough ellipse image, the current pixel is divided into the corresponding candidate point set S, and the grayscale value of the current pixel is compared with each grayscale value in the candidate point set S. If the grayscale value of the current pixel is greater than each grayscale value in the candidate point set S, the grayscale value of the current pixel is the local maximum and remains unchanged. Otherwise, the grayscale value of the current pixel is set to zero to remove pixels with too low grayscale. Finally, several arc segments composed of pixels with unchanged grayscale values are used as candidate arc segments.

[0026] The step 3) is as follows:

[0027] Step 3.1) First, select c candidate arc segments that are longer than the preset length from the candidate arc segments as long arc segments, obtain the average error of each long arc segment, and then confirm the error constraint. The long arc segments that meet the error constraint are retained as the initial arc segments for preliminary screening.

[0028] Step 3.2) Each initial arc segment is screened using the length-constrained random sample consensus RANSAC (Random Sample Consensus) algorithm to obtain the optimal arc segment set and fit the optimal ellipse, thereby detecting the edge of the ellipse.

[0029] In the step 3.1), the average error value Err of each long arc segment is avg as follows:

[0030]

[0031] Among them, Err e represents the error value of the e-th long arc segment; d represents the total number of pixels in the e-th long arc segment; B x i and B y i They represent the x-axis and y-axis coordinates of the i-th pixel point in the elliptical coordinate system B. The elliptical coordinate system B is established with the minor axis and major axis of the thick ellipse as the x-axis and y-axis respectively, and the center of the circle as the origin. a and b represent the lengths of the major axis and minor axis of the thick ellipse respectively.

[0032] According to the average error Err of each long arc segment avg The error constraints confirmed are as follows:

[0033] Err max >Err e >Err min

[0034] Err max =Err avg +Th Err

[0035] Err min =Err avg -Th Err

[0036] Among them, Err max and Err min Respectively represent the upper and lower limits of error, Th Err Indicates the error threshold.

[0037] The step 3.2) is as follows:

[0038] Step 3.2.1) For each initial arc segment, first calculate the polar angles of the pixels at the two endpoints of the initial arc segment and obtain the maximum polar angle θ of the initial arc segment respectively. max and the first polar angle minimum θ min , if θ is not satisfied max -θ min >180, no processing is performed, otherwise continue to judge and obtain the polar angle of each pixel point in the current initial arc segment, thereby obtaining the second polar angle maximum value θ' max and the second polar angle minimum θ' min , if θ is not satisfied min >θ' min And θ max <θ' max, no processing is performed, otherwise the initial arc segment is divided into two initial sub-arc segments, and the polar angle θ of each pixel point in the first initial sub-arc segment is i Satisfy θ' min <θ i <θ min , the polar angle θ of each pixel in the second initial sub-arc segment i Satisfy θ max <θ i <θ' max , each undivided initial arc segment and each initial sub-arc segment is taken as the first arc segment.

[0039] Step 3.2.2) Each first arc segment is divided into the first polar angle minimum value θ min Sort from small to large, if satisfied Then the jth and j+1th first arc segments are divided into the same first arc segment group, and They respectively represent the maximum value of the first polar angle of the j-th first arc segment and the minimum value of the first polar angle of the j+1-th first arc segment, and the first arc segment group includes one or more first arc segments.

[0040] Step 3.2.3) According to the length of each first arc segment in each first arc segment group, use the length-constrained random sample consistent RANSAC algorithm to screen out several first arc segments. If there are multiple first arc segments belonging to the same first arc segment group among the screened out first arc segments, one of the first arc segments is randomly retained, and finally the screened out first arc segments are used as the second arc segments, thereby constructing the second arc segment set R.

[0041] Step 3.2.4) Use the second arc segment set R to fit the first ellipse, and calculate the average error Err of each second arc segment relative to the first ellipse avg , filter out the error value greater than the error average Err avg The second arc segment is then used to fit the second ellipse, and the same steps of the first ellipse are repeated until the current error average obtained during the g-th iteration is less than the minimum error average in the g-th iteration process, then the currently retained second arc segment is constructed as the optimal arc segment set, otherwise the iteration is stopped after the preset number of iterations, and the currently retained second arc segment is constructed as the optimal arc segment set; otherwise, steps 2) to 3) are repeated.

[0042] Step 3.2.5) An optimal ellipse is fitted based on the optimal arc segment set. The ellipse parameters of the optimal ellipse, including the center coordinates, inclination angle, and ab axis, can be confirmed, and the ellipse edge can be finally detected.

[0043] The electronic device of the present invention comprises: a memory and a processor coupled to each other, wherein the memory stores program data, and the processor calls the program data to execute the method described above.

[0044] The computer-readable storage medium of the present invention stores program data thereon, and when the program data is executed by a processor, the method described above is implemented.

[0045] This paper uses a deep learning-based semantic segmentation method to generate a coarse ellipse. The ellipse image is then sliced into sectors and histogram equalized to enhance edge gradients. The normal vector of the coarse ellipse at each pixel is calculated and dot-producted with the image gradient. Local non-maximum suppression is performed on the ellipse normal information to obtain candidate arc segments. Preliminary screening is performed based on the arc segment length and error relative to the coarse ellipse. Ellipses are then fitted using the length-constrained RANSAC algorithm to obtain the optimal set of arc segments and the final ellipse parameters. This approach offers the advantages of speed and high accuracy.

[0046] The beneficial effects of the present invention are:

[0047] 1) The present invention introduces a sector mask and performs histogram equalization on the local sector image of the ellipse, thereby enhancing the edge gradient of the ellipse and making the edge features more prominent.

[0048] 2) The present invention calculates the dot product of the gradient of each pixel of the elliptical sector image and the elliptical normal vector, and performs local non-maximum suppression according to the direction of the normal vector, thereby improving the accuracy of edge detection.

[0049] 3) The present invention uses the length-constrained RANSAC algorithm to fit the ellipse, sets a higher selection probability for long arc segments, and then removes arc segments with overlapping polar angle ranges from the selected arc segment set, thereby screening out the arc segments closest to the edge and improving the accuracy of ellipse fitting. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 is a flow chart of the method of the present invention;

[0051] Figure 2 Schematic diagram of dividing the sector mask of the present invention;

[0052] Figure 3 Schematic diagram of calculating the dot product of pixel gradient and ellipse normal vector in the present invention;

[0053] Figure 4 It is a schematic diagram of local non-maximum suppression of the present invention. DETAILED DESCRIPTION

[0054] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0055] like Figure 1 As shown, the ellipse edge detection method based on normal vector constraint of the present invention includes:

[0056] Step 1) Use a binocular camera to capture a target image containing an ellipse, segment it to obtain a coarse ellipse image, and then perform sector-wise partitioning and equalization on the coarse ellipse image to obtain several equalized ellipse local sector images, as follows:

[0057] Step 1.1) Segment the target image containing the ellipse using a deep learning-based semantic segmentation method to obtain a coarse ellipse image containing only a single ellipse. Perform mask dilation and erosion on the coarse ellipse image to obtain an annular mask of the ellipse edge. If one or more ellipses exist in the target image containing the ellipse, such as a target image containing several countersunk holes, the annular area on the inner wall of the countersunk hole is the elliptical area. After segmentation, several separate coarse ellipses are obtained, i.e., each countersunk hole is segmented separately. The deep learning-based semantic segmentation method can specifically use a U-Net, DeepLab model, etc., and operate on each coarse ellipse to detect the ellipse edge.

[0058] Step 1.2) Establish a polar coordinate system on the rough ellipse image, such as Figure 2 As shown in FIG, the mask is divided according to the polar angle to form n sector masks, that is, the ellipse edge ring mask is divided into n sector masks according to the polar angle, and each sector mask is ANDed with the coarse ellipse image to obtain n ellipse local sector images.

[0059] The polar angles for segmenting the sector mask are as follows:

[0060]

[0061] Among them, θ i represents the polar angle of the i-th pixel; x i and y i represent the x-axis and y-axis coordinates of the i-th pixel point in the image coordinate system of the coarse ellipse image; Ox and Oy represent the x-axis and y-axis coordinates of the center of the coarse ellipse in the image coordinate system of the coarse ellipse image.

[0062] Set the polar angle to 360*(j+1)>θ i The pixels within the range of *n>360*j are included in the jth sector mask.

[0063] Step 1.3) Perform histogram equalization on each elliptical local sector image to obtain n equalized elliptical local sector images.

[0064] Step 2) After normal vector constraint and local non-maximum suppression processing are performed on each equalized elliptical local sector image, several candidate arc segments are obtained, as follows:

[0065] Step 2.1) For each equalized elliptical local sector image, obtain the normal vector of each pixel in the equalized elliptical local sector image, and use the Sobel operator to obtain the pixel gradient of each pixel, such as Figure 3 As shown, the normal vector and pixel gradient of each pixel are dot-producted and converted to the range of 0-255 to obtain the grayscale value of the current pixel.

[0066] The normal vector of a pixel is calculated as follows:

[0067] First, the minor axis and major axis of the thick ellipse are x-axis and y-axis respectively, and the center of the circle is the origin. The coordinate system transformation matrix of the elliptical coordinate system B is defined to transform the elliptical coordinate system B to the image coordinate system A. as follows:

[0068]

[0069] in, Indicates the inclination of the rough ellipse.

[0070] Transform the coordinates of pixel i in the image coordinate system A to the elliptical coordinate system B as follows:

[0071]

[0072] in, Represents the coordinate system transformation matrix from image coordinate system A to elliptical coordinate system B; B x i and B y i Respectively represent the x-axis and y-axis coordinates of the i-th pixel point in the elliptical coordinate system B, A x i and A y i Respectively represent the x-axis and y-axis coordinates of the i-th pixel point in the image coordinate system A, A Ox and A Oy represents the x-axis and y-axis coordinates of the center of the thick ellipse in the image coordinate system A.

[0073] Then the slope k of the ellipse normal passing through pixel i is i as follows:

[0074]

[0075] Where a and b represent the lengths of the major and minor axes of the thick ellipse, respectively.

[0076] Then the ellipse normal vector of pixel point i in ellipse coordinate system B is B n i as follows:

[0077]

[0078] The ellipse normal vector in the ellipse coordinate system B is transformed to the image coordinate system A as follows:

[0079]

[0080] in, A n i is the ellipse normal vector of pixel point i in the image coordinate system A.

[0081] Step 2.2) Based on the grayscale values of each pixel and its eight-connected neighborhood pixels, edge extraction is performed using local non-maximum suppression to screen out several candidate arc segments as follows:

[0082] For each pixel, the relative coordinate set Q of the eight-connected neighborhood pixels of the pixel is obtained as follows:

[0083] Q={(x i -1,y i -1),(x i ,y i -1),(x i +1,y i -1),(x i -1,y i ),

[0084] (x i +1,y i ),(x i -1,y i +1),(x i ,y i +1),(x i +1,y i +1)}

[0085] Among them, x i and y i They represent the x-axis and y-axis coordinates of the i-th pixel in the image coordinate system of the rough ellipse image.

[0086] Get the gray value set P of each pixel in the relative coordinate set Q of the eight-connected neighborhood pixels, P = {p k |k=1,2,...,8},p k Represents the gray value of the kth pixel in the relative coordinate set Q of the eight-connected neighborhood pixels; then obtains the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the rough ellipse image, α=arctan(k i )+90.

[0087] The candidate point set S is divided according to the gray value set P of each pixel in the relative coordinate set Q of the eight-connected neighborhood pixels and the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the rough ellipse image as follows:

[0088]

[0089] According to the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the rough ellipse image, the current pixel is divided into the corresponding candidate point set S, and the grayscale value of the current pixel is compared with each grayscale value in the candidate point set S. If the grayscale value of the current pixel is greater than each grayscale value in the candidate point set S, the grayscale value of the current pixel is the local maximum and remains unchanged. Otherwise, the grayscale value of the current pixel is set to zero to remove pixels with too low grayscale. Finally, several arc segments composed of pixels with unchanged grayscale values are used as candidate arc segments, such as Figure 4 shown.

[0090] Step 3) After error screening of each candidate arc segment, the optimal arc segment set is obtained and fitted into an optimal ellipse, and the edge of the ellipse is finally detected, as follows:

[0091] Step 3.1) First, select c candidate arcs that are longer than the preset length from the candidate arcs as long arcs, obtain the average error of each long arc, and then confirm the error constraint. The long arcs that meet the error constraint are retained as the initial arcs for preliminary screening. The average error of each long arc Err avg as follows:

[0092]

[0093] Among them, Err e represents the error value of the e-th long arc segment; d represents the total number of pixels in the e-th long arc segment; B x i and B y i They represent the x-axis and y-axis coordinates of the i-th pixel point in the elliptical coordinate system B. The elliptical coordinate system B is established with the minor axis and major axis of the thick ellipse as the x-axis and y-axis respectively, and the center of the circle as the origin. a and b represent the lengths of the major axis and minor axis of the thick ellipse respectively.

[0094] According to the average error Err of each long arc segment avg The error constraints confirmed are as follows:

[0095] Err max >Err e >Err min

[0096] Err max =Err avg +ThErr

[0097] Err min =Err avg -Th Err

[0098] Among them, Err max and Err min Respectively represent the upper and lower limits of error, Th Err Indicates the error threshold.

[0099] Step 3.2) Each initial arc segment is screened using the length-constrained random sample consensus RANSAC algorithm to obtain the optimal arc segment set and fit the optimal ellipse, thereby detecting the edge of the ellipse, as follows:

[0100] Step 3.2.1) For each initial arc segment, first calculate the polar angles of the pixels at the two endpoints of the initial arc segment and obtain the maximum polar angle θ of the initial arc segment respectively. max and the first polar angle minimum θ min , if θ is not satisfied max -θ min >180, no processing is performed, otherwise continue to judge and obtain the polar angle of each pixel point in the current initial arc segment, thereby obtaining the second polar angle maximum value θ' max and the second polar angle minimum θ' min , if θ is not satisfied min >θ' min And θ max <θ' max , no processing is performed, otherwise the initial arc segment is divided into two initial sub-arc segments, and the polar angle θ of each pixel point in the first initial sub-arc segment is i Satisfy θ' min <θ i <θ min , the polar angle θ of each pixel in the second initial sub-arc segment i Satisfy θ max <θ i <θ' max , each undivided initial arc segment and each initial sub-arc segment is taken as the first arc segment.

[0101] Step 3.2.2) Each first arc segment is divided into the first polar angle minimum value θ min Sort from small to large, if satisfied Then the jth and j+1th first arc segments are divided into the same first arc segment group, and They respectively represent the maximum value of the first polar angle of the j-th first arc segment and the minimum value of the first polar angle of the j+1-th first arc segment, and the first arc segment group includes one or more first arc segments.

[0102] Step 3.2.3) According to the length of each first arc segment in each first arc segment group, use the length-constrained random sample consistent RANSAC algorithm to screen out several first arc segments. If there are multiple first arc segments belonging to the same first arc segment group among the screened out first arc segments, one of the first arc segments is randomly retained, and finally the screened out first arc segments are used as the second arc segments, thereby constructing the second arc segment set R.

[0103] The length (number of pixels) of each first arc segment is recorded as l j , the total length of all arcs is recorded as l total In the RANSAC fitting algorithm based on length constraints, the probability of each first arc being selected is p j For p j =l j / l total , according to probability p j Select a group of first arc segments, if there are multiple p in the same group j When an arc is selected, one is randomly retained.

[0104] Step 3.2.4) Use the second arc segment set R to fit the first ellipse, and calculate the average error Err of each second arc segment relative to the first ellipse avg , filter out the error value greater than the error average Err avg The second arc segment is then used to fit the second ellipse, and the same steps of the first ellipse are repeated until the current error average obtained during the g-th iteration is less than the minimum error average in the g-th iteration process, then the currently retained second arc segment is constructed as the optimal arc segment set, otherwise the iteration is stopped after the preset number of iterations, and the currently retained second arc segment is constructed as the optimal arc segment set; otherwise, steps 2) to 3) are repeated.

[0105] Step 3.2.5) An optimal ellipse is fitted based on the optimal arc segment set. The ellipse parameters of the optimal ellipse, including the center coordinates, inclination angle, and ab axis, can be confirmed, and the ellipse edge can be finally detected.

[0106] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems or computer program products. Therefore, the application can adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) that contain computer-usable program code. The scheme in the embodiments of the present application can be implemented in various computer languages. The application is described according to the flow chart of the method, system and computer program product of the embodiments of the present application.

[0107] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concepts. Therefore, the present invention is intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.

[0108] Obviously, those skilled in the art may make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the equivalent technology of the present invention, the present application is intended to include these modifications and variations.

Claims

1. A method for detecting ellipse edges based on normal vector constraints, characterized in that: include: Step 1) using a binocular camera to capture a target image containing an ellipse, segmenting the image to obtain a coarse ellipse image, and then performing sector-wise partitioning and equalization on the coarse ellipse image to obtain a number of equalized ellipse local sector images; Step 2) performing normal vector constraint and local non-maximum suppression processing on each equalized elliptical local sector image to obtain a number of candidate arc segments; Step 3) After error screening of each candidate arc segment, the optimal arc segment set is obtained and fitted into an optimal ellipse, and finally the edge of the ellipse is detected.

2. The ellipse edge detection method based on normal vector constraint according to claim 1, characterized in that: The step 1) is as follows: Step 1.1) Segment the target image containing the ellipse using a deep learning-based semantic segmentation method to obtain a coarse ellipse image containing only a single ellipse. Perform mask dilation and erosion on the coarse ellipse image to obtain an ellipse edge ring mask. Step 1.2) Establish a polar coordinate system on the coarse ellipse image, divide the ellipse edge ring mask into n sector masks according to the polar angle, and perform an AND operation on each sector mask and the coarse ellipse image to obtain n ellipse local sector images; Step 1.3) Perform histogram equalization on each elliptical local sector image to obtain n equalized elliptical local sector images.

3. The ellipse edge detection method based on normal vector constraint according to claim 1, characterized in that: The step 2) is as follows: Step 2.1) For each equalized elliptical local sector image, obtain the normal vector of each pixel in the equalized elliptical local sector image, and use the Sobel operator to obtain the pixel gradient of each pixel. After performing a dot product between the normal vector and the pixel gradient of each pixel and converting them to the range of 0-255, obtain the grayscale value of the current pixel; Step 2.2) Based on the grayscale values of each pixel and its eight-connected neighborhood pixels, edge extraction is performed using local non-maximum suppression processing to screen out several candidate arc segments.

4. The ellipse edge detection method based on normal vector constraint according to claim 3, characterized in that: The step 2.2) is as follows: For each pixel, the relative coordinate set Q of the eight-connected neighborhood pixels of the pixel is obtained as follows: Q={(x i -1,and i -1),(x i ,and i -1),(x i +1,and i -1),(x i -1,and i ), (x i +1,and i ),(x i -1,and i +1),(x i ,and i +1),(x i +1,and i +1)} Among them, x i and y i Respectively represent the x-axis and y-axis coordinates of the i-th pixel point in the image coordinate system of the rough ellipse image; Get the gray value set P of each pixel in the relative coordinate set Q of the eight-connected neighborhood pixels, P = {p k |k=1,2,...,8},p k Represent the grayscale value of the kth pixel in the relative coordinate set Q of the eight-connected neighborhood pixels; then obtain the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the rough ellipse image; The candidate point set S is divided according to the gray value set P of each pixel in the relative coordinate set Q of the eight-connected neighborhood pixels and the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the rough ellipse image as follows: According to the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the rough ellipse image, the current pixel is divided into the corresponding candidate point set S, and the grayscale value of the current pixel is compared with each grayscale value in the candidate point set S. If the grayscale value of the current pixel is greater than each grayscale value in the candidate point set S, the grayscale value of the current pixel is the local maximum and remains unchanged. Otherwise, the grayscale value of the current pixel is set to zero. Finally, several arc segments composed of pixels with unchanged grayscale values are used as candidate arc segments.

5. The ellipse edge detection method based on normal vector constraint according to claim 1, characterized in that: The step 3) is as follows: Step 3.1) First, select c candidate arc segments that are longer than a preset length from the candidate arc segments as long arc segments, obtain the average error of each long arc segment, and then confirm the error constraint. The long arc segments that meet the error constraint are retained as the initial arc segments for preliminary screening; Step 3.2) Each initial arc segment is screened using the length-constrained random sample consensus RANSAC algorithm to obtain the optimal arc segment set and fit the optimal ellipse, thereby detecting the edge of the ellipse.

6. The ellipse edge detection method based on normal vector constraint according to claim 5, characterized in that: In the step 3.1), the average error value Err of each long arc segment is avg as follows: Among them, Err e represents the error value of the e-th long arc segment; d represents the total number of pixels in the e-th long arc segment; B x i and B y i They represent the x-axis and y-axis coordinates of the i-th pixel point in the elliptical coordinate system B. The elliptical coordinate system B is established with the minor axis and major axis of the thick ellipse as the x-axis and y-axis respectively, and the center of the circle as the origin. a and b represent the lengths of the major axis and minor axis of the thick ellipse respectively; According to the average error Err of each long arc segment avg The error constraints confirmed are as follows: Err max >Err e >Err min Among them, Err max and Err min Respectively represent the upper and lower limits of error, Th Err Indicates the error threshold.

7. The ellipse edge detection method based on normal vector constraint according to claim 5, characterized in that: The step 3.2) is as follows: Step 3.2.1) For each initial arc segment, first calculate the polar angles of the pixels at the two endpoints of the initial arc segment and obtain the maximum polar angle θ of the initial arc segment respectively. max and the first polar angle minimum θ min , if θ is not satisfied max -θ min >180, no processing is performed, otherwise continue to judge and obtain the polar angle of each pixel point in the current initial arc segment, thereby obtaining the second polar angle maximum value θ' max and the second polar angle minimum θ' min , if θ is not satisfied min >θ' min And θ max <θ' max , no processing is performed, otherwise the initial arc segment is divided into two initial sub-arc segments, and the polar angle θ of each pixel point in the first initial sub-arc segment is i Satisfy θ' min <θ i <θ min , the polar angle θ of each pixel in the second initial sub-arc segment i Satisfy θ max <θ i <θ' max , taking each undivided initial arc segment and each initial sub-arc segment as the first arc segment; Step 3.2.2) Each first arc segment is divided into the first polar angle minimum value θ min Sort from small to large, if satisfied Then the jth and j+1th first arc segments are divided into the same first arc segment group, and They respectively represent the maximum value of the first polar angle of the j-th first arc segment and the minimum value of the first polar angle of the j+1-th first arc segment, where the first arc segment group includes one or more first arc segments; Step 3.2.3) Based on the lengths of the first arcs in each first arc group, a number of first arcs are selected using a length-constrained random sample consistent RANSAC algorithm. If multiple first arcs belonging to the same first arc group exist among the selected first arcs, one of the first arcs is randomly retained. The selected first arcs are ultimately used as second arcs, thereby constructing a second arc set R. Step 3.2.4) Use the second arc segment set R to fit the first ellipse, and calculate the average error Err of each second arc segment relative to the first ellipse avg , filter out the error value greater than the error average Err avg The second arc segment is then used to fit the second ellipse, and the same steps as the first ellipse are repeated until the current error average obtained at the g-th iteration is less than the minimum error average in the g-th iteration process, then the currently retained second arc segment is constructed as the optimal arc segment set, otherwise the iteration is stopped until the preset number of iterations is reached, and the currently retained second arc segment is constructed as the optimal arc segment set; Step 3.2.5) Fit the optimal ellipse based on the optimal arc segment set and finally detect the ellipse edge.

8. An electronic device, characterized in that: include: A memory and a processor coupled to each other, wherein the memory stores program data, and the processor calls the program data to execute the method according to any one of claims 1 to 7.

9. A computer-readable storage medium having program data stored thereon, characterized in that: When the program data is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Tooth-shaped structure assembling and measuring method based on monocular vision

    CN113405451A

  • Binocular recognition visual detection method for intelligent manufacturing production line

    CN117764983A

  • Multi-constraint circular hole detection method based on two-section contour clustering

    CN118333944A

  • Ellipse detection method and system based on segmental arc combination and point cloud reconstruction method

    CN119273734A

  • Edge detection method using arbitrary angle

    WO2019041590A1