A single camera-based round hole edge feature extraction method
By extracting image contours using a monocular camera and performing ellipse fitting, the problems of high computational resources and insufficient real-time performance in existing technologies are solved, and efficient extraction of circular hole edge features is achieved.
Patent Information
- Application Number
- CN202211259820.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-14
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2042-10-14
AI Technical Summary
Existing methods for binocular vision measurement and artificial intelligence-based extraction of circular hole edge features have high computational resource requirements and insufficient real-time performance, thus failing to meet control requirements.
Using a monocular camera, the system extracts the image contour, processes the bounding rectangle, generates ellipse parameters, and fits the least squares method. It then evaluates the number of overlapping points and the algebraic distance between the ellipse and the contour in real time, and selects the optimal ellipse as the edge of the circular hole.
It improves the real-time performance of feature extraction, reduces the computational resource requirements, and meets the real-time requirements.
Smart Images

Figure CN115830333B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image recognition, and in particular to a method, device, electronic device, and computer-readable storage medium for extracting circular hole edge features based on a monocular camera. Background Art
[0002] Circular hole features are a common shape feature seen during the filling process of objects. In graphics, such features can be roughly viewed as circular features. However, circular features do not appear as circles on the imaging plane. In most cases, they appear as projections of the circle in a certain direction. Therefore, if you want to use a visual sensor to capture the position of such features in three-dimensional space, the first step is to accurately find the corresponding elliptical feature in space and apply the corresponding ellipse fitting algorithm to the boundary of the feature to obtain the various parameters of the fitted ellipse. The main problem with the currently commonly used binocular vision measurement or edge feature extraction methods based on artificial intelligence is that they require high computing resources and their real-time performance cannot meet control requirements.
[0003] Therefore, one or more methods are needed to solve the above problems.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the Invention
[0005] The purpose of the present disclosure is to provide a method, device, electronic device and computer-readable storage medium for circular hole edge feature extraction based on a monocular camera, thereby overcoming one or more problems caused by the limitations and defects of related technologies to at least some extent.
[0006] According to one aspect of the present disclosure, a method for extracting circular hole edge features based on a monocular camera is provided, comprising:
[0007] Extracting contours from the image to be detected, and sorting the contours according to their areas, selecting the contour with the largest area in the sorted contours as the contour to be fitted, processing the contour to be fitted into a circumscribed rectangle, and sorting the circumscribed rectangles according to their areas, and using the long side and short side of the circumscribed rectangle with the smallest area in the sorted rectangles as the major axis and minor axis, respectively, of the first ellipse corresponding to the contour to be fitted;
[0008] Selecting two groups of arbitrary points on the contour to be fitted, generating center point coordinates of the first ellipse according to a preset geometric formula based on the intersection of tangent lines of the two groups of arbitrary points on the first ellipse, performing data screening on the image point set on the contour to be fitted based on the center point coordinates, and generating a first angle between the major axis of the first ellipse and the horizontal axis of the coordinate system;
[0009] generating a parametric equation of the first ellipse based on the major axis, minor axis, center point coordinates, and a first angle between the major axis and the horizontal axis of the coordinate system of the first ellipse; varying the first angle between the major axis and the horizontal axis of the coordinate system from 0 to 180 degrees according to the parametric equation; evaluating and recording in real time the number of overlapping points between the generated ellipse and the contour when the first angle between the major axis and the horizontal axis of the coordinate system varies from 0 to 180 degrees; selecting the ellipse with the largest number of overlapping points with the contour as the second ellipse; recording the angle between the major axis of the second ellipse and the horizontal axis of the coordinate system as the second angle; and recording the number of overlapping points between the second ellipse and the contour as the first number of overlapping points;
[0010] Taking the major axis, minor axis, center point coordinates, and the second angle between the major axis and the horizontal axis of the coordinate system of the second ellipse as initial values, a range of preset parameters is selected to generate a set of major axes to be fitted, a set of minor axes to be fitted, a set of center point coordinates to be fitted, and a set of angles between the major axis to be fitted and the horizontal axis of the coordinate system, and respectively generate a third ellipse with the major axis set to be fitted, the minor axis set to be fitted, the set of center point coordinates to be fitted, and the set of angles between the major axis to be fitted and the horizontal axis of the coordinate system, and fit it to the contour, evaluate in real time and calculate the algebraic distance between the third ellipse and the contour based on the least squares method, and select the third ellipse corresponding to the minimum value of the algebraic distance as the edge of the circular hole of the image to be detected.
[0011] In an exemplary embodiment of the present disclosure, the method further includes:
[0012] Extracting contours in the image to be detected and determining the number of the contours;
[0013] When the number of the contours is 1, performing ellipse fitting on the contours based on the least squares method to generate a third ellipse;
[0014] When the number of the contours is greater than 1, the contours are sorted according to their areas, and the contour with the largest area in the sorted contours is selected as the contour to be fitted.
[0015] In an exemplary embodiment of the present disclosure, the method further includes:
[0016] Selecting two groups of arbitrary points on the contour to be fitted, and generating, based on the intersection of the tangent lines of the first group of arbitrary points in the two groups on the first ellipse, a line connecting the intersection and the midpoint of the arc of the first group of arbitrary points as a first straight line with a center point;
[0017] Based on the intersection of the tangent lines of the second group of arbitrary points in the two groups of arbitrary points on the first ellipse, generating a second straight line as a center point connecting the intersection and the midpoint of the arc of the second group of arbitrary points;
[0018] The intersection of the first center point straight line and the second center point straight line is used as the center point coordinates of the first ellipse.
[0019] In an exemplary embodiment of the present disclosure, the method further includes:
[0020] Using the major axis, minor axis, center point coordinates, and the second angle between the major axis and the transverse axis of the coordinate system of the second ellipse as initial values, and selecting a range of preset parameters, generating a set of major axes to be fitted, a set of minor axes to be fitted, a set of center point coordinates to be fitted, and a set of angles between the major axis to be fitted and the transverse axis of the coordinate system, respectively, generating a third ellipse using the set of major axes to be fitted, the set of minor axes to be fitted, the set of center point coordinates to be fitted, and the set of angles between the major axis to be fitted and the transverse axis of the coordinate system, and fitting the third ellipse to the contour, and evaluating and recording the number of overlapping points between the third ellipse and the contour;
[0021] The number of overlapping points between the third ellipse and the contour is compared with the first number of overlapping points. If the number of overlapping points between the third ellipse and the contour is less than the first number of overlapping points, the third ellipse is discarded; if the number of overlapping points between the third ellipse and the contour is greater than the first number of overlapping points, the algebraic distance between the third ellipse and the contour is evaluated in real time and calculated based on the least squares method, and the third ellipse corresponding to the minimum value of the algebraic distance is selected as the edge of the circular hole of the image to be detected.
[0022] In an exemplary embodiment of the present disclosure, the method further includes:
[0023] comparing the number of overlapping points between the third ellipse and the contour with a preset second number of overlapping points;
[0024] If the number of overlapping points between the third ellipse and the contour is greater than a preset second number of overlapping points, the third ellipse is selected as the circular hole edge of the image to be detected;
[0025] If the number of overlapping points between the third ellipse and the contour is less than a preset second number of overlapping points, the third ellipse is discarded.
[0026] In an exemplary embodiment of the present disclosure, the method further includes:
[0027] When the number of contours is greater than 1, if the number of overlapping points between the third ellipse and the contour is less than a preset second number of overlapping points, the third ellipse is discarded and the contour with the second largest contour area in the contour area sorting is selected as the contour to be fitted.
[0028] In one aspect of the present disclosure, a device for extracting circular hole edge features based on a monocular camera is provided, comprising:
[0029] a major-minor axis calculation module, configured to extract contours from the image to be detected, sort the contours according to their areas, select the contour with the largest area in the sorted contours as the contour to be fitted, process the contours to be fitted as circumscribed rectangles, sort the circumscribed rectangles according to their areas, and use the long side and short side of the circumscribed rectangle with the smallest area in the sorted rectangles as the major axis and minor axis, respectively, of the first ellipse corresponding to the contour to be fitted;
[0030] an angle calculation module, configured to select two groups of arbitrary points on the contour to be fitted, generate the coordinates of the center point of the first ellipse based on an intersection of tangent lines of the two groups of arbitrary points on the first ellipse according to a preset geometric formula, perform data screening on the image point set on the contour to be fitted based on the center point coordinates, and generate a first angle between the major axis of the first ellipse and the horizontal axis of the coordinate system;
[0031] a first fitting module, configured to generate a parametric equation of the first ellipse based on the major axis, minor axis, center point coordinates, and a first angle between the major axis and the transverse axis of the coordinate system of the first ellipse; vary the first angle between the major axis and the transverse axis of the coordinate system from 0 to 180 degrees according to the parametric equation; evaluate and record in real time the number of coincidence points between the generated ellipse and the contour when the first angle between the major axis and the transverse axis of the coordinate system varies from 0 to 180 degrees; select the ellipse with the largest number of coincidence points with the contour as the second ellipse; record the angle between the major axis of the second ellipse and the transverse axis of the coordinate system as the second angle; and record the number of coincidence points between the second ellipse and the contour as the first number of coincidence points;
[0032] The second fitting module is used to use the major axis, minor axis, center point coordinates, and the second angle between the major axis and the horizontal axis of the coordinate system of the second ellipse as initial values, and select a range of preset parameters to generate a set of major axes to be fitted, a set of minor axes to be fitted, a set of center point coordinates to be fitted, and a set of angles between the major axis to be fitted and the horizontal axis of the coordinate system, and respectively generate a third ellipse using the set of major axes to be fitted, the set of minor axes to be fitted, the set of center point coordinates to be fitted, and the set of angles between the major axis to be fitted and the horizontal axis of the coordinate system, and fit it to the contour, evaluate in real time and calculate the algebraic distance between the third ellipse and the contour based on the least squares method, and select the third ellipse corresponding to the minimum value of the algebraic distance as the edge of the circular hole in the image to be detected.
[0033] In one aspect of the present disclosure, there is provided an electronic device, comprising:
[0034] processor; and
[0035] A memory having computer-readable instructions stored thereon, wherein the computer-readable instructions, when executed by the processor, implement the method according to any one of the above items.
[0036] In one aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method according to any one of the above items is implemented.
[0037] In an exemplary embodiment of the present disclosure, a method for extracting circular hole edge features based on a monocular camera is provided. The method comprises: extracting a contour in an image to be detected, determining the major and minor axes of a first ellipse corresponding to the contour to be fitted; calculating the coordinates of the center point of the first ellipse and a first angle between its major axis and the horizontal axis of the coordinate system; varying the first angle from 0 to 180 degrees, evaluating and recording the number of points of overlap with the contour in real time, selecting the ellipse with the largest number of points of overlap with the contour as the second ellipse, and recording the second angle and the first number of points of overlap; generating a third ellipse within a preset parameter range and fitting it to the contour; evaluating and calculating the algebraic distance between the third ellipse and the contour in real time using the least squares method, and selecting the third ellipse corresponding to the minimum value of the algebraic distance as the circular hole edge in the image to be detected. The present disclosure utilizes a monocular vision sensor for identification, improving the real-time performance of feature extraction and reducing costs.
[0038] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The above and other features and advantages of the present disclosure will become more apparent by describing in detail example embodiments thereof with reference to the accompanying drawings.
[0040] Figure 1 A flowchart of a method for extracting circular hole edge features based on a monocular camera according to an exemplary embodiment of the present disclosure is shown;
[0041] Figure 2 The figure shows an overall flow chart of a circular hole edge feature extraction method based on a monocular camera according to an exemplary embodiment of the present disclosure;
[0042] Figure 3 A schematic block diagram of a circular hole edge feature extraction device based on a monocular camera according to an exemplary embodiment of the present disclosure is shown;
[0043] Figure 4 A block diagram schematically illustrates an electronic device according to an exemplary embodiment of the present disclosure; and
[0044] Figure 5A schematic diagram schematically illustrates a computer-readable storage medium according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0045] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be embodied in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete and will fully convey the concepts of the example embodiments to those skilled in the art. Like reference numerals in the drawings represent like or similar parts, and thus repetitive description thereof will be omitted.
[0046] In addition, the described features, structures or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure can be practiced without one or more of the specific details, or other methods, components, materials, devices, steps, etc. can be adopted. In other cases, well-known structures, methods, devices, implementations, materials or operations are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0047] The blocks shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically separate entities. Specifically, these functional entities may be implemented in software, or in one or more software-hardened modules, or in different networks and / or processor devices and / or microcontroller devices.
[0048] In this example embodiment, a circular hole edge feature extraction method based on a monocular camera is first provided; Figure 1 As shown in , the circular hole edge feature extraction method based on a monocular camera may include the following steps:
[0049] Step S110: extracting contours from the image to be detected, sorting the contours according to their areas, selecting the contour with the largest area among the sorted contours as the contour to be fitted, processing the contours to be fitted into circumscribed rectangles, and sorting the circumscribed rectangles according to their areas, and using the long side and short side of the circumscribed rectangle with the smallest area among the sorted rectangles as the major axis and minor axis, respectively, of the first ellipse corresponding to the contour to be fitted;
[0050] Step S120: selecting two groups of arbitrary points on the contour to be fitted, generating the coordinates of the center point of the first ellipse according to a preset geometric formula based on the intersection of tangent lines of the two groups of arbitrary points on the first ellipse, performing data screening on the image point set on the contour to be fitted based on the center point coordinates, and generating a first angle between the major axis of the first ellipse and the horizontal axis of the coordinate system;
[0051] Step S130: generating a parametric equation of the first ellipse based on the major axis, minor axis, center point coordinates, and the first angle between the major axis and the horizontal axis of the coordinate system of the first ellipse; varying the first angle between the major axis and the horizontal axis of the coordinate system from 0 to 180 degrees based on the parametric equation; evaluating and recording in real time the number of points of overlap between the generated ellipse and the contour when the first angle between the major axis and the horizontal axis of the coordinate system varies from 0 to 180 degrees; selecting the ellipse with the greatest number of points of overlap with the contour as the second ellipse; recording the angle between the major axis of the second ellipse and the horizontal axis of the coordinate system as the second angle; and recording the number of points of overlap between the second ellipse and the contour as the first number of points of overlap;
[0052] Step S140, using the major axis, minor axis, center point coordinates, and the second angle between the major axis and the horizontal axis of the coordinate system of the second ellipse as initial values, and selecting a range of preset parameters to generate a set of major axes to be fitted, a set of minor axes to be fitted, a set of center point coordinates to be fitted, and a set of angles between the major axis to be fitted and the horizontal axis of the coordinate system, and respectively generate a third ellipse with the set of major axes to be fitted, the set of minor axes to be fitted, the set of center point coordinates to be fitted, and the set of angles between the major axis to be fitted and the horizontal axis of the coordinate system, and fit it to the contour, evaluate in real time and calculate the algebraic distance between the third ellipse and the contour based on the least squares method, and select the third ellipse corresponding to the minimum value of the algebraic distance as the edge of the circular hole in the image to be detected.
[0053] In an exemplary embodiment of the present disclosure, a method for extracting circular hole edge features based on a monocular camera is provided. The method comprises: extracting a contour in an image to be detected, determining the major and minor axes of a first ellipse corresponding to the contour to be fitted; calculating the coordinates of the center point of the first ellipse and a first angle between its major axis and the horizontal axis of the coordinate system; varying the first angle from 0 to 180 degrees, evaluating and recording the number of points of overlap with the contour in real time, selecting the ellipse with the largest number of points of overlap with the contour as the second ellipse, and recording the second angle and the first number of points of overlap; generating a third ellipse within a preset parameter range and fitting it to the contour; evaluating and calculating the algebraic distance between the third ellipse and the contour in real time using the least squares method, and selecting the third ellipse corresponding to the minimum value of the algebraic distance as the circular hole edge in the image to be detected. The present disclosure utilizes a monocular vision sensor for identification, improving the real-time performance of feature extraction and reducing costs.
[0054] Next, a method for extracting circular hole edge features based on a monocular camera in this exemplary embodiment will be further described. Figure 2 The figure shows the overall flow chart of the present disclosure.
[0055] In step S110, the contours in the image to be detected can be extracted, and the contours are sorted according to the contour area. The contour with the largest contour area in the contour area sorting is selected as the contour to be fitted, and the contour to be fitted is processed as a circumscribed rectangle, and the circumscribed rectangles are sorted according to the rectangular area. The long side and short side of the circumscribed rectangle with the smallest circumscribed area in the rectangular area sorting are respectively used as the major axis and minor axis of the first ellipse corresponding to the contour to be fitted.
[0056] In this exemplary embodiment, the method further includes:
[0057] Extracting contours in the image to be detected and determining the number of the contours;
[0058] When the number of the contours is 1, performing ellipse fitting on the contours based on the least squares method to generate a third ellipse;
[0059] When the number of the contours is greater than 1, the contours are sorted according to their areas, and the contour with the largest area in the sorted contours is selected as the contour to be fitted.
[0060] In the embodiment of this example, the contour is extracted and the number of contours is determined. If the number of contours is 1, the contour is assumed to be an elliptical contour, and the least squares method is directly used for ellipse fitting. If the number of contours is not 1, the minimum circumscribed rectangle of the largest contour is found, and the length and width of the minimum circumscribed rectangle are calculated, which are approximated as the major and minor axes of the ellipse.
[0061] In step S120, two groups of arbitrary points on the contour to be fitted can be selected, and based on the intersection of the tangents of the two groups of arbitrary points on the first ellipse, the center point coordinates of the first ellipse are generated according to a preset geometric formula. Based on the center point coordinates, data screening is performed on the image point set on the contour to be fitted to generate a first angle between the major axis of the first ellipse and the horizontal axis of the coordinate system.
[0062] In this exemplary embodiment, the method further includes:
[0063] Selecting two groups of arbitrary points on the contour to be fitted, and generating, based on the intersection of the tangent lines of the first group of arbitrary points in the two groups on the first ellipse, a line connecting the intersection and the midpoint of the arc of the first group of arbitrary points as a first straight line with a center point;
[0064] Based on the intersection of the tangent lines of the second group of arbitrary points in the two groups of arbitrary points on the first ellipse, generating a second straight line as a center point connecting the intersection and the midpoint of the arc of the second group of arbitrary points;
[0065] The intersection of the first center point straight line and the second center point straight line is used as the center point coordinates of the first ellipse.
[0066] In this exemplary embodiment, the contour determination method is as follows: Assume that points B (x1, y1) and C (x2, y2) are two common points on an ellipse, and draw a tangent to the ellipse through these two points. If the tangents are parallel, then it is easy to determine that the center of the ellipse is the midpoint of line segment BC. If the tangents are not parallel, assume that the tangents through points B and C intersect at A (a1, a2), and M (m1, m2) is the midpoint of chord BC. Then, the center of the ellipse must be on line AM. The relevant equation for line AM is expressed as follows:
[0067] y(a1-m1)=x(a2-m2)+m2a1-m1a2
[0068]
[0069]
[0070]
[0071]
[0072] By constructing a straight line represented by the above formula, in the parameter space of Hough transform, only two parameter accumulators are needed for the straight line, and the accumulator unit with the highest count received is the candidate for the ellipse center.
[0073] Determination of the remaining parameters: After the ellipse center is determined, the remaining image point set can be screened for the second time to keep it consistent with the estimated ellipse center. The points on the ellipse are
[0074] x 2 +By 2 +2Dxy+C=0,BD 2 >0
[0075] Similarly, by partially differentiating the above equation with respect to x, we get
[0076]
[0077] After the five parameters required for the ellipse equation are determined, we can solve the geometric parameters of the ellipse in the two-dimensional plane according to the following formula.
[0078]
[0079]
[0080]
[0081]
[0082]
[0083] Where: x e ,y e where a represents the horizontal and vertical coordinates of the center of the ellipse, a represents the major and minor semi-axis of the ellipse, and b represents the angle between the major axis of the ellipse and the x-axis.
[0084] In step S130, a parametric equation of the first ellipse can be generated based on the major axis, minor axis, center point coordinates, and the first angle between the major axis and the horizontal axis of the coordinate system of the first ellipse. According to the parametric equation, the first angle between the major axis and the horizontal axis of the coordinate system is changed from 0 to 180 degrees. The number of overlapping points between the ellipse generated when the first angle between the major axis and the horizontal axis of the coordinate system changes from 0 to 180 degrees and the contour is evaluated and recorded in real time. The ellipse with the largest number of overlapping points with the contour is selected as the second ellipse, and the angle between the major axis of the second ellipse and the horizontal axis of the coordinate system is recorded as the second angle. The number of overlapping points between the second ellipse and the contour is the first number of overlapping points.
[0085] In this exemplary embodiment, the method further includes:
[0086] Using the major axis, minor axis, center point coordinates, and the second angle between the major axis and the transverse axis of the coordinate system of the second ellipse as initial values, and selecting a range of preset parameters, generating a set of major axes to be fitted, a set of minor axes to be fitted, a set of center point coordinates to be fitted, and a set of angles between the major axis to be fitted and the transverse axis of the coordinate system, respectively, generating a third ellipse using the set of major axes to be fitted, the set of minor axes to be fitted, the set of center point coordinates to be fitted, and the set of angles between the major axis to be fitted and the transverse axis of the coordinate system, and fitting the third ellipse to the contour, and evaluating and recording the number of overlapping points between the third ellipse and the contour;
[0087] The number of overlapping points between the third ellipse and the contour is compared with the first number of overlapping points. If the number of overlapping points between the third ellipse and the contour is less than the first number of overlapping points, the third ellipse is discarded; if the number of overlapping points between the third ellipse and the contour is greater than the first number of overlapping points, the algebraic distance between the third ellipse and the contour is evaluated in real time and calculated based on the least squares method, and the third ellipse corresponding to the minimum value of the algebraic distance is selected as the edge of the circular hole of the image to be detected.
[0088] In the embodiment of this example, in view of the good robustness of the Hough transform method, the center of the ellipse is solved by performing a Hough transform on the found contour according to the above formula. The solved center is used as the center, and the major and minor axes estimated in the first step are used. Due to the symmetry of the ellipse itself, we only need to statistically compare the number of points that coincide with the contour when the angle between the major axis and the x-axis changes from [0°, 180°], select the one with the highest degree of overlap, and preliminarily determine the angle range.
[0089] In step S140, the major axis, minor axis, center point coordinates, and the second angle between the major axis and the horizontal axis of the coordinate system of the second ellipse can be used as initial values, and a set of major axes to be fitted, a set of minor axes to be fitted, a set of center point coordinates to be fitted, and a set of angles between the major axis to be fitted and the horizontal axis of the coordinate system can be generated according to a preset parameter selection range. A third ellipse is generated using the major axis set to be fitted, the minor axis set to be fitted, the center point coordinate set to be fitted, and the set of angles between the major axis to be fitted and the horizontal axis of the coordinate system, and is fitted to the contour. The algebraic distance between the third ellipse and the contour is evaluated in real time and calculated based on the least squares method, and the third ellipse corresponding to the minimum value of the algebraic distance is selected as the edge of the circular hole in the image to be detected.
[0090] In this exemplary embodiment, the method further includes:
[0091] comparing the number of overlapping points between the third ellipse and the contour with a preset second number of overlapping points;
[0092] If the number of overlapping points between the third ellipse and the contour is greater than a preset second number of overlapping points, the third ellipse is selected as the circular hole edge of the image to be detected;
[0093] If the number of overlapping points between the third ellipse and the contour is less than a preset second number of overlapping points, the third ellipse is discarded.
[0094] In this exemplary embodiment, the method further includes:
[0095] When the number of contours is greater than 1, if the number of overlapping points between the third ellipse and the contour is less than a preset second number of overlapping points, the third ellipse is discarded and the contour with the second largest contour area in the contour area sorting is selected as the contour to be fitted.
[0096] In the embodiment of this example, based on the roughly determined ellipse, random numbers are set around the estimated parameters of the major and minor axes, angles, and centers. All those with a degree of overlap lower than that of step 2 are deleted, and those with a degree of overlap higher than that of step 2 are solved for algebraic distance using the least squares method, and the one with the smallest distance is retained as the fitting result.
[0097] It should be noted that although the steps of the method disclosed herein are depicted in a particular order in the accompanying drawings, this does not require or imply that the steps must be performed in that particular order, or that all steps must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one, and / or one step may be decomposed into multiple steps.
[0098] In addition, in this exemplary embodiment, a circular hole edge feature extraction device based on a monocular camera is also provided. Figure 3 As shown, the circular hole edge feature extraction device 300 based on a monocular camera may include: a major and minor axis calculation module 310, an angle calculation module 320, a first fitting module 330, and a second fitting module 340.
[0099] The major and minor axis calculation module 310 is used to extract contours from the image to be detected, sort the contours according to their areas, select the contour with the largest area in the sorted contours as the contour to be fitted, process the contour to be fitted as a circumscribed rectangle, sort the circumscribed rectangles according to their areas, and use the long side and short side of the circumscribed rectangle with the smallest area in the sorted rectangles as the major axis and minor axis, respectively, of the first ellipse corresponding to the contour to be fitted;
[0100] An angle calculation module 320 is configured to select two groups of arbitrary points on the contour to be fitted, generate the coordinates of the center point of the first ellipse based on the intersection of tangent lines of the two groups of arbitrary points on the first ellipse according to a preset geometric formula, perform data screening on the image point set on the contour to be fitted based on the center point coordinates, and generate a first angle between the major axis of the first ellipse and the horizontal axis of the coordinate system;
[0101] A first fitting module 330 is configured to generate a parametric equation of the first ellipse based on the major axis, minor axis, center point coordinates, and a first angle between the major axis and the horizontal axis of the coordinate system of the first ellipse; vary the first angle between the major axis and the horizontal axis of the coordinate system from 0 to 180 degrees according to the parametric equation; evaluate and record in real time the number of points of overlap between the generated ellipse and the contour when the first angle between the major axis and the horizontal axis of the coordinate system varies from 0 to 180 degrees; select the ellipse with the largest number of points of overlap with the contour as the second ellipse; record the angle between the major axis of the second ellipse and the horizontal axis of the coordinate system as the second angle; and record the number of points of overlap between the second ellipse and the contour as the first number of points of overlap;
[0102] The second fitting module 340 is used to use the major axis, minor axis, center point coordinates, and the second angle between the major axis and the horizontal axis of the coordinate system of the second ellipse as initial values, and select a range of preset parameters to generate a set of major axes to be fitted, a set of minor axes to be fitted, a set of center point coordinates to be fitted, and a set of angles between the major axis to be fitted and the horizontal axis of the coordinate system, and respectively generate a third ellipse using the set of major axes to be fitted, the set of minor axes to be fitted, the set of center point coordinates to be fitted, and the set of angles between the major axis to be fitted and the horizontal axis of the coordinate system, and fit it to the contour, evaluate in real time and calculate the algebraic distance between the third ellipse and the contour based on the least squares method, and select the third ellipse corresponding to the minimum value of the algebraic distance as the edge of the circular hole in the image to be detected.
[0103] The specific details of each of the above-mentioned circular hole edge feature extraction device modules based on a monocular camera have been described in detail in the corresponding circular hole edge feature extraction method based on a monocular camera, so they will not be repeated here.
[0104] It should be noted that although the above detailed description mentions several modules or units of a monocular camera-based circular hole edge feature extraction device 300, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units for embodiment.
[0105] In addition, in an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0106] Those skilled in the art will appreciate that various aspects of the present invention may be implemented as systems, methods, or program products. Accordingly, various aspects of the present invention may be implemented as a complete hardware embodiment, a complete software embodiment (including firmware, microcode, etc.), or a combination of hardware and software embodiments, which may be collectively referred to herein as "circuits," "modules," or "systems."
[0107] Refer to the following Figure 4 An electronic device 400 according to such an embodiment of the present invention will be described. Figure 4 The electronic device 400 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present invention.
[0108] like Figure 4As shown, electronic device 400 is implemented as a general-purpose computing device. Components of electronic device 400 may include, but are not limited to, the aforementioned at least one processing unit 410, the aforementioned at least one storage unit 420, a bus 430 connecting various system components (including storage unit 420 and processing unit 410), and a display unit 440.
[0109] The storage unit stores program codes that can be executed by the processing unit 410, so that the processing unit 410 performs the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Methods” section of this specification. For example, the processing unit 410 may perform the following steps: Figure 1 Steps S110 to S140 shown in FIG.
[0110] The storage unit 420 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 4201 and / or a cache memory unit 4202 , and may further include a read-only memory unit (ROM) 4203 .
[0111] The storage unit 420 may also include a program / utility 4204 having a set (at least one) of program modules 4203, such program modules 4205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include an implementation of a network environment.
[0112] Bus 450 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0113] The electronic device 400 can also communicate with one or more external devices 470 (e.g., a keyboard, a pointing device, a Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 400, and / or any device that enables the electronic device 400 to communicate with one or more other computing devices (e.g., a router, a modem, etc.). Such communication can occur via an input / output (I / O) interface 450. Furthermore, the electronic device 400 can communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 460. As shown, the network adapter 460 communicates with other modules of the electronic device 400 via the bus 450. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 400, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0114] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
[0115] In exemplary embodiments of the present disclosure, a computer-readable storage medium is also provided, storing a program product capable of implementing the aforementioned methods of this specification. In some possible embodiments, various aspects of the present invention may also be implemented in the form of a program product comprising program code. When the program product is executed on a terminal device, the program code is configured to cause the terminal device to perform the steps according to various exemplary embodiments of the present invention described in the "Exemplary Methods" section of this specification.
[0116] refer to Figure 5 As shown, a program product 500 for implementing the above method according to an embodiment of the present invention is described. The program product 500 may be a portable compact disc read-only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0117] The program product may be implemented in any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0118] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0119] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0120] The program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, and the like, as well as conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0121] Furthermore, the above-described figures are merely illustrative of the processes included in the method according to exemplary embodiments of the present invention and are not intended to be limiting. It is readily understood that the processes illustrated in the above-described figures do not indicate or limit the temporal order of these processes. Furthermore, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0122] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow from the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the claims.
[0123] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A circular hole edge feature extraction method based on a monocular camera, characterized in that: The method comprises: Extracting contours from the image to be detected, and sorting the contours according to their areas, selecting the contour with the largest area in the sorted contours as the contour to be fitted, processing the contour to be fitted into a circumscribed rectangle, and sorting the circumscribed rectangles according to their areas, and using the long side and short side of the circumscribed rectangle with the smallest area in the sorted rectangles as the major axis and minor axis, respectively, of the first ellipse corresponding to the contour to be fitted; Selecting two groups of arbitrary points on the contour to be fitted, generating center point coordinates of the first ellipse according to a preset geometric formula based on the intersection of tangent lines of the two groups of arbitrary points on the first ellipse, performing data screening on the image point set on the contour to be fitted based on the center point coordinates, and generating a first angle between the major axis of the first ellipse and the horizontal axis of the coordinate system; generating a parametric equation of the first ellipse based on the major axis, minor axis, center point coordinates, and a first angle between the major axis and the horizontal axis of the coordinate system of the first ellipse; varying the first angle between the major axis and the horizontal axis of the coordinate system from 0 to 180 degrees according to the parametric equation; evaluating and recording in real time the number of overlapping points between the generated ellipse and the contour when the first angle between the major axis and the horizontal axis of the coordinate system varies from 0 to 180 degrees; selecting the ellipse with the largest number of overlapping points with the contour as the second ellipse; recording the angle between the major axis of the second ellipse and the horizontal axis of the coordinate system as the second angle; and recording the number of overlapping points between the second ellipse and the contour as the first number of overlapping points; Taking the major axis, minor axis, center point coordinates, and the second angle between the major axis and the horizontal axis of the coordinate system of the second ellipse as initial values, a range of preset parameters is selected to generate a set of major axes to be fitted, a set of minor axes to be fitted, a set of center point coordinates to be fitted, and a set of angles between the major axis to be fitted and the horizontal axis of the coordinate system, and respectively generate a third ellipse with the major axis set to be fitted, the minor axis set to be fitted, the set of center point coordinates to be fitted, and the set of angles between the major axis to be fitted and the horizontal axis of the coordinate system, and fit it to the contour, evaluate in real time and calculate the algebraic distance between the third ellipse and the contour based on the least squares method, and select the third ellipse corresponding to the minimum value of the algebraic distance as the edge of the circular hole of the image to be detected.
2. The method according to claim 1, wherein The method further comprises: Extracting contours in the image to be detected and determining the number of the contours; When the number of the contours is 1, performing ellipse fitting on the contours based on the least squares method to generate a third ellipse; When the number of the contours is greater than 1, the contours are sorted according to their areas, and the contour with the largest area in the sorted contours is selected as the contour to be fitted.
3. The method according to claim 1, wherein The method further comprises: Selecting two groups of arbitrary points on the contour to be fitted, and generating, based on the intersection of the tangent lines of the first group of arbitrary points in the two groups on the first ellipse, a line connecting the intersection and the midpoint of the arc of the first group of arbitrary points as a first straight line with a center point; Based on the intersection of the tangent lines of the second group of arbitrary points in the two groups of arbitrary points on the first ellipse, generating a second straight line as a center point connecting the intersection and the midpoint of the arc of the second group of arbitrary points; The intersection of the first center point straight line and the second center point straight line is used as the center point coordinates of the first ellipse.
4. The method according to claim 1, wherein The method further comprises: Using the major axis, minor axis, center point coordinates, and the second angle between the major axis and the transverse axis of the coordinate system of the second ellipse as initial values, and selecting a range of preset parameters, generating a set of major axes to be fitted, a set of minor axes to be fitted, a set of center point coordinates to be fitted, and a set of angles between the major axis to be fitted and the transverse axis of the coordinate system, respectively, generating a third ellipse using the set of major axes to be fitted, the set of minor axes to be fitted, the set of center point coordinates to be fitted, and the set of angles between the major axis to be fitted and the transverse axis of the coordinate system, and fitting the third ellipse to the contour, and evaluating and recording the number of overlapping points between the third ellipse and the contour; The number of overlapping points between the third ellipse and the contour is compared with the first number of overlapping points. If the number of overlapping points between the third ellipse and the contour is less than the first number of overlapping points, the third ellipse is discarded; if the number of overlapping points between the third ellipse and the contour is greater than the first number of overlapping points, the algebraic distance between the third ellipse and the contour is evaluated in real time and calculated based on the least squares method, and the third ellipse corresponding to the minimum value of the algebraic distance is selected as the edge of the circular hole of the image to be detected.
5. The method according to claim 2, wherein The method further comprises: comparing the number of overlapping points between the third ellipse and the contour with a preset second number of overlapping points; If the number of overlapping points between the third ellipse and the contour is greater than a preset second number of overlapping points, the third ellipse is selected as the circular hole edge of the image to be detected; If the number of overlapping points between the third ellipse and the contour is less than a preset second number of overlapping points, the third ellipse is discarded.
6. The method according to claim 5, wherein The method further comprises: When the number of contours is greater than 1, if the number of overlapping points between the third ellipse and the contour is less than a preset second number of overlapping points, the third ellipse is discarded and the contour with the second largest contour area in the contour area sorting is selected as the contour to be fitted.
7. A circular hole edge feature extraction device based on a monocular camera, characterized in that: The device comprises: a major-minor axis calculation module, configured to extract contours from the image to be detected, sort the contours according to their areas, select the contour with the largest area in the sorted contours as the contour to be fitted, process the contours to be fitted as circumscribed rectangles, sort the circumscribed rectangles according to their areas, and use the long side and short side of the circumscribed rectangle with the smallest area in the sorted rectangles as the major axis and minor axis, respectively, of the first ellipse corresponding to the contour to be fitted; an angle calculation module, configured to select two groups of arbitrary points on the contour to be fitted, generate the coordinates of the center point of the first ellipse based on an intersection of tangent lines of the two groups of arbitrary points on the first ellipse according to a preset geometric formula, perform data screening on the image point set on the contour to be fitted based on the center point coordinates, and generate a first angle between the major axis of the first ellipse and the horizontal axis of the coordinate system; a first fitting module, configured to generate a parametric equation of the first ellipse based on the major axis, minor axis, center point coordinates, and a first angle between the major axis and the transverse axis of the coordinate system of the first ellipse; vary the first angle between the major axis and the transverse axis of the coordinate system from 0 to 180 degrees according to the parametric equation; evaluate and record in real time the number of coincidence points between the generated ellipse and the contour when the first angle between the major axis and the transverse axis of the coordinate system varies from 0 to 180 degrees; select the ellipse with the largest number of coincidence points with the contour as the second ellipse; record the angle between the major axis of the second ellipse and the transverse axis of the coordinate system as the second angle; and record the number of coincidence points between the second ellipse and the contour as the first number of coincidence points; The second fitting module is used to use the major axis, minor axis, center point coordinates, and the second angle between the major axis and the horizontal axis of the coordinate system of the second ellipse as initial values, and select a range of preset parameters to generate a set of major axes to be fitted, a set of minor axes to be fitted, a set of center point coordinates to be fitted, and a set of angles between the major axis to be fitted and the horizontal axis of the coordinate system, and respectively generate a third ellipse using the set of major axes to be fitted, the set of minor axes to be fitted, the set of center point coordinates to be fitted, and the set of angles between the major axis to be fitted and the horizontal axis of the coordinate system, and fit it to the contour, evaluate in real time and calculate the algebraic distance between the third ellipse and the contour based on the least squares method, and select the third ellipse corresponding to the minimum value of the algebraic distance as the edge of the circular hole in the image to be detected.
8. An electronic device, characterized in that: include processor; and A memory having computer-readable instructions stored thereon, wherein the computer-readable instructions are executed by the processor to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the method according to any one of claims 1 to 6 when executed by a processor.
Citation Information
Patent Citations
Multi-ellipse detection and evaluation algorithm and device based on image gradient information, terminal and readable storage medium
CN111311593A
Method and system for automatically capturing an object using a mobile terminal
US20140321752A1