Contour determination method and device

By segmenting and combining the contours of the target object in industrial detection, the problem of excessive contour segmentation and fitting errors in the prior art is solved, and the accuracy of the contours, detection efficiency and accuracy are improved.

CN119850528APending Publication Date: 2025-04-18BEIJING LUSTER LIGHTTECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411850683.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

The prior art uses a contour approximation method based on a polyline in industrial detection, which easily oversegments of curved contours, resulting in large fitting errors and reducing the accuracy and accuracy of detection.

Method used

A contour determination method is proposed. By segmenting the contour of the target object in the acquired image, the fitted line segments and the fitted arcs are obtained, and the fitted line segments obtained by the first segment are quadratic, and the final fitted line segments are combined to improve the accuracy and smoothness of the contour.

Benefits of technology

It improves the accuracy and smoothness of the fitted contours, simplifies the data structure, reduces storage and processing costs, and improves the efficiency, accuracy and accuracy of industrial inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119850528A_ABST
    Figure CN119850528A_ABST
Patent Text Reader

Abstract

The invention discloses a contour determination method and device, and belongs to the technical field of industrial detection. The contour determination method comprises the following steps: processing each first candidate line segment corresponding to the contour of a target object in an obtained first image, and obtaining a first fitting contour of contour segments corresponding to any two adjacent first candidate line segments in at least one first candidate line segment; processing each first candidate line segment and the contour segment corresponding to the first candidate line segment to obtain a second fitting contour of the contour segment corresponding to the first candidate line segment; and carrying out merging processing on any adjacent first candidate line segment and second candidate line segment, and / or any adjacent two second candidate line segments, and obtaining a target fitting contour corresponding to the target object. According to the contour determination method, the precision and the smoothness of the contour obtained through fitting are improved, the subsequent storage and processing cost is reduced, and the efficiency, the precision and the accuracy of subsequent industrial detection are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of industrial detection technology, and in particular, relates to a contour determination method and device. Background Art

[0002] In the process of industrial inspection, it is usually necessary to extract the contour of the inspection object for industrial inspection, for example, defect detection based on the contour of the inspection object. In the related art, there is a method of approximating the input contour based on a broken line, but this method will over-segment the curved contour, and the error between the segmented contour and the actual contour is large, thereby reducing the precision and accuracy of industrial inspection. Summary of the invention

[0003] The present application aims to solve at least one of the technical problems existing in the related art. To this end, the present application proposes a contour determination method and device, which improves the precision and smoothness of the contour obtained by fitting, simplifies the data structure, reduces the subsequent storage and processing costs, and improves the efficiency, precision and accuracy of subsequent industrial detection.

[0004] In a first aspect, the present application provides a contour determination method, the method comprising:

[0005] Processing each first candidate line segment corresponding to the contour of the target object in the acquired first image, obtaining a first fitting contour of a contour segment corresponding to any two adjacent first candidate line segments among at least one of the first candidate line segments; the first fitting contour includes the any two adjacent first candidate line segments or first candidate arcs, and the first candidate line segment is obtained by processing a plurality of contour points of the target object;

[0006] Processing each of the first candidate line segments and the contour segment corresponding to the first candidate line segment to obtain a second fitting contour of the contour segment corresponding to the first candidate line segment; the second fitting contour includes the first candidate line segment, or at least two second candidate line segments, or at least one second candidate arc, and the at least two second candidate line segments are obtained by processing the contour segment corresponding to the first candidate line segment;

[0007] Any adjacent first candidate line segment and second candidate line segment, and / or any adjacent two second candidate line segments are merged to obtain a target fitting contour corresponding to the target object; the target fitting contour includes at least one of at least one coherent candidate line segment and at least one candidate arc.

[0008] According to the contour determination method provided in the embodiment of the present application, by segmenting the contour, the fitting line segments and fitting arcs corresponding to the contour of the target object can be obtained, and then the fitting line segments obtained by the first segmentation are segmented a second time to obtain the fitting contour obtained by the second segmentation, and the line segments finally fitted are merged to obtain the target fitting contour corresponding to the target object, which improves the accuracy and smoothness of the contour obtained by fitting, simplifies the data structure, reduces the subsequent storage and processing costs, and improves the efficiency, precision and accuracy of subsequent industrial detection.

[0009] In an embodiment of the present application, a contour determination method is provided, wherein any adjacent first candidate line segment and second candidate line segment, and / or any adjacent two second candidate line segments are merged to obtain a target fitting contour corresponding to the target object, including:

[0010] Perform fitting processing on all contour points corresponding to the any adjacent first candidate line segments and second candidate line segments to obtain third candidate arcs corresponding to all the contour points;

[0011] When the maximum distance between the third candidate arc and the contour segments corresponding to all the contour points is smaller than the maximum distance between the first candidate line segment and the second candidate line segment and the contour segment, the third candidate arc is determined as the target fitting contour of the contour segment corresponding to any adjacent first candidate line segment and second candidate line segment.

[0012] In an embodiment of the present application, a contour determination method is provided, wherein any adjacent first candidate line segment and second candidate line segment, and / or any adjacent two second candidate line segments are merged to obtain a target fitting contour corresponding to the target object, including:

[0013] In the case that the first candidate line segments corresponding to the two any adjacent second candidate line segments are different, fitting processing is performed on all contour points corresponding to the two any adjacent second candidate line segments to obtain fourth candidate arcs corresponding to all the contour points;

[0014] When the maximum distance between the fourth candidate arc and the contour segments corresponding to all the contour points is less than the maximum distance between the two second candidate line segments and the contour segment, the fourth candidate arc is determined as the target fitting contour of the contour segment corresponding to any two adjacent second candidate line segments.

[0015] In an embodiment of the present application, a contour determination method is provided, wherein the processing of each of the first candidate line segments and the contour segment corresponding to the first candidate line segment to obtain a second fitting contour of the contour segment corresponding to the first candidate line segment includes:

[0016] Obtaining a difference between each of the first candidate line segments and a contour segment corresponding to the first candidate line segment;

[0017] The contour segment corresponding to the first candidate line segment is processed based on the difference to obtain a second fitting contour corresponding to the contour segment.

[0018] In an embodiment of the present application, a contour determination method is provided, wherein the contour segment corresponding to the first candidate line segment is processed based on the difference to obtain a second fitting contour corresponding to the contour segment, including:

[0019] When the difference is less than or equal to an error threshold, the first candidate line segment is determined as the second fitting contour of the contour segment corresponding to the first candidate line segment.

[0020] In an embodiment of the present application, a contour determination method is provided, wherein the contour segment corresponding to the first candidate line segment is processed based on the difference to obtain a second fitting contour corresponding to the contour segment, including:

[0021] When the difference is greater than the error threshold, fitting is performed on all contour points included in the contour segment corresponding to the first candidate line segment to obtain at least two second candidate line segments corresponding to the contour segment;

[0022] Performing fitting processing on all contour points corresponding to any two adjacent second candidate line segments among the at least two second candidate line segments to obtain second candidate arcs of the contour segments corresponding to the any two adjacent second candidate line segments;

[0023] When the maximum distance between the second candidate arc and the contour segment is smaller than the maximum distance between any two adjacent second candidate line segments and the contour segment, determining the second candidate arc as the second fitting contour of the contour segment corresponding to the first candidate line segment;

[0024] When the maximum distance between the second candidate arc and the contour segment is greater than or equal to the maximum distance between any two adjacent second candidate line segments and the contour segment, the two adjacent second candidate line segments are determined as the second fitting contour of the contour segment corresponding to the first candidate line segment.

[0025] In an embodiment of the present application, a contour determination method is provided, wherein the first candidate line segments corresponding to the contour of the target object in the acquired first image are processed to obtain a first fitting contour of a contour segment corresponding to any two adjacent first candidate line segments of at least one of the first candidate line segments, including:

[0026] Fitting all contour points corresponding to any two adjacent first candidate line segments in at least one of the first candidate line segments to obtain a first candidate arc of all contour points corresponding to the any two adjacent first candidate line segments;

[0027] When the maximum distance between the first candidate arc and the contour segments corresponding to all the contour points is smaller than the maximum distance between any two adjacent first candidate line segments and the contour segment, determining the first candidate arc as the first fitting contour;

[0028] When the maximum distance between the first candidate arc and the contour segments corresponding to all the contour points is greater than or equal to the maximum distance between any two adjacent first candidate line segments and the contour segment, the any two adjacent first candidate line segments are determined as the first fitting contour.

[0029] In a second aspect, the present application provides a contour determination device, the device comprising:

[0030] A first processing module is used to process each first candidate line segment corresponding to the contour of the target object in the acquired first image, and obtain a first fitting contour of a contour segment corresponding to any two adjacent first candidate line segments among at least one of the first candidate line segments; the first fitting contour includes the any two adjacent first candidate line segments or first candidate arcs, and the first candidate line segment is obtained by processing a plurality of contour points of the target object;

[0031] a second processing module, configured to process each of the first candidate line segments and the contour segment corresponding to the first candidate line segment, to obtain a second fitting contour of the contour segment corresponding to the first candidate line segment; the second fitting contour includes the first candidate line segment, or at least two second candidate line segments, or at least one second candidate arc, and the at least two second candidate line segments are obtained by processing the contour segment corresponding to the first candidate line segment;

[0032] The third processing module is used to merge any adjacent first candidate line segments and second candidate line segments, and / or any two adjacent second candidate line segments to obtain a target fitting contour corresponding to the target object; the target fitting contour includes at least one of at least one coherent candidate line segment and at least one candidate arc.

[0033] According to the contour determination device provided in the embodiment of the present application, by segmenting the contour, the fitting line segments and fitting arcs corresponding to the contour of the target object can be obtained, and then the fitting line segments obtained by the first segmentation are segmented for the second time to obtain the fitting contour obtained by the second segmentation, and the line segments finally fitted are merged to obtain the target fitting contour corresponding to the target object, which improves the accuracy and smoothness of the contour obtained by fitting, simplifies the data structure, reduces the subsequent storage and processing costs, and improves the efficiency, precision and accuracy of subsequent industrial detection.

[0034] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the contour determination method as described in the first aspect above is implemented.

[0035] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the contour determination method as described in the first aspect above is implemented.

[0036] The above one or more technical solutions in the embodiments of the present application have at least one of the following technical effects:

[0037] By segmenting the contour, the fitting line segments and fitting arcs corresponding to the contour of the target object can be obtained, and then the fitting line segments obtained by the first segmentation are segmented a second time to obtain the fitting contour obtained by the second segmentation, and the final fitted line segments are merged to obtain the target fitting contour corresponding to the target object, which improves the accuracy and smoothness of the fitted contour, simplifies the data structure, reduces the subsequent storage and processing costs, and improves the efficiency, precision and accuracy of subsequent industrial detection.

[0038] Furthermore, by performing secondary segmentation on the first candidate line segment that does not meet the fineness requirement, a second fitting contour corresponding to the contour segment is obtained, thereby improving the accuracy of the overall fitting contour. This method is suitable for objects with complex contours and shape changes and has a wide range of applicable scenarios.

[0039] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:

[0041] Figure 1 It is one of the flowcharts of the contour determination method provided in the embodiment of the present application;

[0042] Figure 2 This is the second flow chart of the contour determination method provided in the embodiment of the present application;

[0043] Figure 3 This is one of the result schematic diagrams of the contour determination method provided in the embodiment of the present application;

[0044] Figure 4 This is the second result schematic diagram of the contour determination method provided in the embodiment of the present application;

[0045] Figure 5 This is the third result schematic diagram of the contour determination method provided in the embodiment of the present application;

[0046] Figure 6 This is the fourth result schematic diagram of the contour determination method provided in the embodiment of the present application;

[0047] Figure 7 This is the fifth result schematic diagram of the contour determination method provided in the embodiment of the present application;

[0048] Figure 8 is a schematic diagram of the structure of a contour determination device provided in an embodiment of the present application;

[0049] Fig. 9 It is a hardware schematic diagram of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0050] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0051] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0052] The contour determination method, contour determination device, electronic device and readable storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.

[0053] The contour determination method may be applied to a terminal, and may be specifically executed by hardware or software in the terminal.

[0054] The terminal includes, but is not limited to, a portable communication device such as a mobile phone or tablet computer with a touch-sensitive surface (e.g., a touch screen display and / or a touch pad). It should also be understood that in some embodiments, the terminal may not be a portable communication device, but a desktop computer with a touch-sensitive surface (e.g., a touch screen display and / or a touch pad).

[0055] In the following various embodiments, a terminal including a display and a touch-sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, a mouse and a joystick.

[0056] The contour determination method provided in the embodiment of the present application may be executed by an electronic device or a functional module or functional entity in the electronic device that can implement the contour determination method. The electronic devices mentioned in the embodiment of the present application include but are not limited to mobile phones, tablet computers, computers, cameras, and wearable devices. The contour determination method provided in the embodiment of the present application is described below using the electronic device as an example of the execution subject.

[0057] like Figure 1 As shown, the contour determination method includes: step 110, step 120 and step 130.

[0058] Step 110: Process each first candidate line segment corresponding to the contour of the target object in the acquired first image, and obtain a first fitting contour of a contour segment corresponding to any two adjacent first candidate line segments in at least one first candidate line segment;

[0059] In this step, the first image is obtained by capturing an image of the target object.

[0060] The target object may include a product to be tested in an industrial testing scenario, for example, the target object may be a battery cell to be tested.

[0061] A contour point set of the target object in the first image may be extracted, and the contour point set may be processed to obtain segmentation line segments corresponding to the contour of the target object in the first image.

[0062] The first candidate line segment is obtained by processing a plurality of contour points of the target object.

[0063] At least one first candidate line segment is connected end to end and can be used to represent the contour of the target object in the first image.

[0064] like Figure 5As shown, the outline of the target object can be approximately fitted into a polygon, and the polygon includes a plurality of first candidate line segments (such as Figure 5 shown by the blue and green lines).

[0065] A Douglas–Peucker algorithm may be used to perform line segment approximation to obtain at least one first candidate line segment corresponding to the contour of the target object in the first image.

[0066] Curve fitting can be performed on any two adjacent first candidate line segments of at least one first candidate line segment to obtain the first candidate arc of the contour segment corresponding to the any two adjacent first candidate line segments, and then the difference between the fitted contour and the contour segment obtained before and after the curve fitting can be compared to obtain a fitted contour that is closer to the actual contour and determine it as the first fitted contour corresponding to the any two adjacent first candidate line segments.

[0067] The first fitting contour may include any two adjacent first candidate line segments or first candidate arcs.

[0068] In the actual implementation process, for example, at least one first candidate line segment includes adjacent first candidate line segments L1, first candidate line segment L2 and first candidate line segment L3, L1 and L2 can be subjected to curve fitting processing to obtain the first candidate arc line s1 corresponding to L1 and L2, L2 and L3 can be subjected to curve fitting processing to obtain the first candidate arc line s2 corresponding to L2 and L3, and then the difference x1 between s1 and the contour segments corresponding to L1 and L2, the difference x2 between L1 and L2 and their corresponding contour segments, the difference x3 between s2 and the contour segments corresponding to L2 and L3, and the difference x4 between L2 and L3 and their corresponding contour segments can be calculated.

[0069] When x2 is greater than x1, it can be determined that the fitted s1 is closer to the contour segment corresponding to L1 and L2. When x4 is greater than x3, it can be determined that the fitted s2 is closer to the contour segment corresponding to L2 and L3. Then the sizes of x2 and x4 can be compared. When x2 is less than x4, s1 can be determined as the first fitted contour of the contour segment corresponding to L1 and L2; when x2 is greater than x4, s2 can be determined as the first fitted contour of the contour segment corresponding to L2 and L3.

[0070] In some embodiments, step 110 may include:

[0071] Fitting all contour points corresponding to any two adjacent first candidate line segments in at least one first candidate line segment to obtain a first candidate arc of all contour points corresponding to any two adjacent first candidate line segments;

[0072] When the maximum distance between the first candidate arc and the contour segments corresponding to all contour points is less than the maximum distance between any two adjacent first candidate line segments and the contour segment, the first candidate arc is determined as the first fitting contour;

[0073] When the maximum distance between the first candidate arc and the contour segments corresponding to all contour points is greater than or equal to the maximum distance between any two adjacent first candidate line segments and the contour segment, any two adjacent first candidate line segments are determined as the first fitting contour.

[0074] In this embodiment, all first candidate line segments can be traversed to obtain two adjacent first candidate line segments, and then all contour points corresponding to the two adjacent first candidate line segments can be organized and fitted to obtain the first candidate arcs of all contour points corresponding to the two adjacent first candidate line segments.

[0075] The first candidate arc may include a circular arc or an elliptical arc, which may be selected based on user needs.

[0076] For example, a user input may be received, and the user input is used to determine the fitting type, and the fitting type may include a line segment, a circular arc, or an elliptical arc.

[0077] When the fitting type input by the user is a line segment, the first candidate line segment may be directly determined as the first fitting contour.

[0078] like Figure 6 As shown, when the fitting type input by the user is an arc, at least one first candidate line segment can be obtained first, and then the contour points corresponding to two adjacent first candidate line segments are processed to obtain their corresponding first candidate arc lines, which are arcs.

[0079] like Figure 7 As shown, when the fitting type input by the user is an elliptical arc, at least one first candidate line segment can be obtained first, and then the contour points corresponding to two adjacent first candidate line segments are processed to obtain their corresponding first candidate arc lines, which are elliptical arcs.

[0080] The maximum distance between two adjacent first candidate line segments and the contour segment may be the maximum value of the distances between each first candidate line segment and its corresponding contour segment.

[0081] The maximum distance D1 between the fitted first candidate arc and the contour segment, and the maximum distance D2 between two adjacent first candidate line segments and the contour segment can be calculated. When D1 is less than D2, it can be determined that the fitted first candidate arc is closer to the actual contour segment, and the first candidate arc can be determined as the first fitted contour corresponding to the contour segment; when D1 is greater than or equal to D2, the two adjacent first candidate line segments can be determined as the first fitted contours of their corresponding contour segments.

[0082] After traversing all first candidate line segments, until the number of first candidate line segments does not change or is 1, stop segmenting the arc (elliptical arc).

[0083] According to the contour determination method provided in the embodiment of the present application, the first candidate arc is obtained by performing arc fitting processing on the contour points corresponding to any two adjacent first candidate line segments, and the difference between the arc obtained by fitting and the actual contour is compared with the difference between the two first candidate line segments and the actual contour. The fitting result with the smaller difference is determined as the first fitting contour. A fitting result that is closer to the actual contour can be obtained, and on the basis of meeting the contour fitting requirements, the number of contour segments obtained by fitting is reduced, thereby improving the efficiency of subsequent industrial inspection processing.

[0084] Step 120: Process each first candidate line segment and the contour segment corresponding to the first candidate line segment to obtain a second fitting contour of the contour segment corresponding to the first candidate line segment;

[0085] In this step, if fine segmentation is required, the line segments in the result obtained by the first segmentation may be segmented into secondary circular arcs or elliptical arcs.

[0086] The second fitting contour includes the first candidate line segment, or at least two second candidate line segments, or at least one second candidate arc.

[0087] When the difference between the first candidate line segment and the contour segment corresponding to the first candidate line segment meets the precision requirement, the first candidate line segment may be retained, that is, the first candidate line segment may be determined as the second fitting contour corresponding to the contour segment.

[0088] When the difference between the first candidate line segment and the contour segment corresponding to the first candidate line segment does not meet the fineness requirement, the first candidate line segment may be finely segmented to obtain at least two second candidate line segments.

[0089] The at least two second candidate line segments are obtained by processing the contour segments corresponding to the first candidate line segments.

[0090] For two adjacent second candidate line segments, curve fitting can be continued to obtain second candidate arcs, and based on the difference between the contours before and after curve fitting and the actual contour, the second fitting contour can be determined from the two adjacent second candidate line segments and the second candidate arcs.

[0091] Step 130: merge any adjacent first candidate line segment and second candidate line segment, and / or any adjacent two second candidate line segments to obtain a target fitting contour corresponding to the target object;

[0092] In this step, the contour of the target object in the first image is segmented twice to obtain one or more of a first candidate line segment, a second candidate line segment, a first candidate arc, and a second candidate arc corresponding to the contour.

[0093] After two segmentation processes, if there is a first candidate line segment corresponding to the contour, any adjacent first candidate line segment and second candidate line segment can be merged and fitted, for example, the adjacent first candidate line segment and second candidate line segment can be merged into a candidate arc.

[0094] Two adjacent second candidate line segments that meet the conditions may be merged into one candidate arc.

[0095] The target fitting contour includes at least one of at least one continuous candidate line segment and at least one candidate arc line.

[0096] like Figure 3 As shown in the figure, the red and yellow lines are the candidate arcs obtained by fitting, and the blue and green lines are the candidate line segments obtained by fitting. Figure 3 By merging adjacent candidate line segments in Figure 4 Target fit outline shown.

[0097] According to the contour determination method provided in the embodiment of the present application, by segmenting the contour, the fitting line segments and fitting arcs corresponding to the contour of the target object can be obtained, and then the fitting line segments obtained by the first segmentation are segmented a second time to obtain the fitting contour obtained by the second segmentation, and the line segments finally fitted are merged to obtain the target fitting contour corresponding to the target object, which improves the accuracy and smoothness of the contour obtained by fitting, simplifies the data structure, reduces the subsequent storage and processing costs, and improves the efficiency, precision and accuracy of subsequent industrial detection.

[0098] In some embodiments, step 130 may include:

[0099] Perform fitting processing on all contour points corresponding to any adjacent first candidate line segments and second candidate line segments to obtain third candidate arcs corresponding to all contour points;

[0100] When the maximum distance between the third candidate arc and the contour segments corresponding to all contour points is smaller than the maximum distance between the first candidate line segment and the second candidate line segment and the contour segment, the third candidate arc is determined as the target fitting contour of the contour segments corresponding to any adjacent first candidate line segment and the second candidate line segment.

[0101] In this embodiment, for the first candidate line segment obtained after the first segmentation and the second candidate line segment obtained after the second segmentation, two adjacent line segments may be merged.

[0102] The third candidate arc line is obtained by performing curve fitting processing on all contour points corresponding to the adjacent first candidate line segments and the second candidate line segments.

[0103] The fitting error corresponding to the third candidate arc and the fitting errors corresponding to the first candidate line segment and the second candidate line segment can be calculated. For example, the maximum distance between the third candidate arc and the contour segment can be calculated, and the maximum distance between the first candidate line segment and the second candidate line segment and the contour segment can be calculated. When the fitting error corresponding to the third candidate arc is smaller, the third candidate arc can be determined as the target fitting contour corresponding to the contour segment.

[0104] When the fitting error corresponding to the third candidate arc is larger, the adjacent first candidate line segment and the second candidate line segment may be determined as the target fitting contour corresponding to the contour segment.

[0105] After traversing the fitting results corresponding to all contour segments, the final target fitting contour corresponding to the target object can be obtained.

[0106] In some embodiments, step 130 may include:

[0107] When the first candidate line segments corresponding to any two adjacent second candidate line segments are different, fitting is performed on all contour points corresponding to any two adjacent second candidate line segments to obtain fourth candidate arcs corresponding to all contour points;

[0108] When the maximum distance between the fourth candidate arc and the contour segments corresponding to all contour points is less than the maximum distance between the two second candidate line segments and the contour segment, the fourth candidate arc is determined as the target fitting contour of the contour segment corresponding to any two adjacent second candidate line segments.

[0109] In this embodiment, when two adjacent second candidate line segments are obtained by segmenting different first candidate line segments, curve fitting processing can be performed on all contour points corresponding to the two adjacent second candidate line segments to obtain fourth candidate arcs corresponding to all contour points.

[0110] Similarly, the fitting error of the fourth candidate arc and the fitting errors corresponding to two adjacent second candidate line segments can be calculated, and the fitting errors of the two can be compared, and the fitting result corresponding to the smaller fitting error can be determined as the target fitting contour corresponding to the contour segment.

[0111] In some embodiments, step 120 may include:

[0112] Obtaining the difference between each first candidate line segment and the contour segment corresponding to the first candidate line segment;

[0113] The contour segment corresponding to the first candidate line segment is processed based on the difference to obtain a second fitting contour corresponding to the contour segment.

[0114] In this embodiment, for the first candidate line segments obtained by the first segmentation, the difference between each first candidate line segment and its corresponding contour segment may be calculated.

[0115] For example, the maximum distance between the first candidate line segment and its corresponding contour segment may be calculated.

[0116] In some embodiments, processing the contour segment corresponding to the first candidate line segment based on the difference to obtain the second fitting contour corresponding to the contour segment may include:

[0117] When the difference is less than or equal to the error threshold, the first candidate line segment is determined as the second fitting contour of the contour segment corresponding to the first candidate line segment.

[0118] In this embodiment, when the difference is less than or equal to the error threshold, it means that the first candidate line segment obtained by the first segmentation can meet the segmentation precision requirement, and there is no need to perform a secondary segmentation on the first candidate line segment. The first candidate line segment can be determined as the second fitting contour of its corresponding contour segment.

[0119] The error threshold can be user-defined, and the fitting errors corresponding to the line segments and arcs included in the target fitting contour finally obtained can be less than or equal to the error threshold.

[0120] In some embodiments, processing the contour segment corresponding to the first candidate line segment based on the difference to obtain the second fitting contour corresponding to the contour segment may include:

[0121] When the difference is greater than the error threshold, fitting is performed on all contour points included in the contour segment corresponding to the first candidate line segment to obtain at least two second candidate line segments corresponding to the contour segment;

[0122] Performing fitting processing on all contour points corresponding to any two adjacent second candidate line segments among the at least two second candidate line segments to obtain second candidate arcs of the contour segments corresponding to any two adjacent second candidate line segments;

[0123] When the maximum distance between the second candidate arc and the contour segment is less than the maximum distance between any two adjacent second candidate line segments and the contour segment, the second candidate arc is determined as the second fitting contour of the contour segment corresponding to the first candidate line segment;

[0124] When the maximum distance between the second candidate arc and the contour segment is greater than or equal to the maximum distance between any two adjacent second candidate line segments and the contour segment, the two adjacent second candidate line segments are determined as the second fitting contour of the contour segment corresponding to the first candidate line segment.

[0125] In this embodiment, when the difference is greater than the error threshold, it means that the first candidate line segment obtained by the first segmentation does not meet the precision requirement set by the user, and the first candidate line segment may be segmented a second time.

[0126] For example, all contour points corresponding to the first candidate line segments may be fitted into two adjacent second candidate line segments.

[0127] Then, curve fitting is performed on all contour points corresponding to two adjacent second candidate line segments, and the fitting error corresponding to the fitting contour before the curve fitting process is compared with the fitting error corresponding to the fitting contour obtained after the curve fitting process, and the fitting contour corresponding to the smaller fitting error is determined as the second fitting contour corresponding to the contour segment.

[0128] According to the contour determination method provided in the embodiment of the present application, by performing secondary segmentation on the first candidate line segment that does not meet the fineness requirement, a second fitting contour corresponding to the contour segment is obtained, thereby improving the accuracy of the overall fitting contour. The method is suitable for objects with complex contours and shape changes and has a wide range of applicable scenarios.

[0129] Combine the following Figure 2 The overall process of the contour determination method provided in the embodiment of the present application is described in detail.

[0130] like Figure 2 As shown, the classification mode and segmentation precision requirement input by the user can be received.

[0131] Among them, two distance thresholds can be set to characterize the segmentation precision requirement. For example, the set maximum distance 1 can be used to limit the precision of the first segmentation, so that the fitting error of the fitting contour obtained by the first segmentation is within the maximum distance 1. The set maximum distance 2 can be used to limit the precision of the second segmentation. Generally, the maximum distance 2 can be set to be smaller than the maximum distance 1, such as Figure 5-Figure 7 As shown, the maximum distance 1 can be set to 4 and the maximum distance 2 can be set to 2, so that the fitting errors of the fitting contours obtained by the second segmentation are all within the maximum distance 2.

[0132] Abnormal points on the contour can be removed. For example, the contour points can be traversed and smoothed using a smoothing algorithm (such as a moving average method or a Gaussian filter method) to ensure that the processed contour points maintain their original basic shape and features. In the actual execution process, the parameter SmoothCont>0 can be set.

[0133] Then, the contour of the target object may be approximated by line segments and divided into a plurality of first candidate line segments.

[0134] When the segmentation mode input by the user is the lines mode, multiple first candidate line segments can be directly output, such as Figure 5 shown.

[0135] When the segmentation mode input by the user is Line_circles or Line_ellipses, circular arc or elliptical arc fitting and merging can be performed: for two adjacent first candidate line segments, curve fitting can be performed on all their corresponding contour points to obtain the first candidate arc. If the maximum distance from the first candidate arc to the contour segment is less than the maximum distance from the two first candidate line segments to the contour segment, the two first candidate line segments are replaced by circular arcs. This process is iterated until the number of first candidate line segments does not change or is 1, then the arc segmentation is stopped.

[0136] When the maximum distance 2 (dMaxLineDist2) is greater than or equal to the maximum distance 1 (dMaxLineDist1), the fitting contour obtained by the first segmentation can be directly output without further fine segmentation.

[0137] When the maximum distance 2 (dMaxLineDist2) is smaller than the maximum distance 1 (dMaxLineDist1), secondary circular arc or elliptical arc segmentation can be performed.

[0138] For the first candidate line segment obtained by the first segmentation, polygonal approximation can be performed again on the contour points corresponding to the first candidate line segment to segment it into at least two second candidate line segments, and circular arcs or elliptical arcs can be merged on the newly created second candidate line segments to obtain a second fitting contour.

[0139] After two segmentations, the currently obtained fitting contour may include: a first candidate arc, a first candidate line segment, a second candidate arc, and a second candidate line segment.

[0140] Then, two adjacent second candidate line segments that are not obtained by segmenting the same first candidate line segment are merged by circular arcs or elliptical arcs, and adjacent first candidate line segments and second candidate line segments are merged by circular arcs or elliptical arcs to obtain a target fitting contour.

[0141] The contour determination device provided in the present application is described below. The contour determination device described below and the contour determination method described above can be referenced to each other.

[0142] The contour determination method provided in the embodiment of the present application may be executed by a contour determination device. In the embodiment of the present application, the contour determination device provided in the embodiment of the present application is described by taking the contour determination method executed by the contour determination device as an example.

[0143] The embodiment of the present application also provides a contour determination device.

[0144] like Figure 8 As shown, the contour determination device includes: a first processing module 810, a second processing module 820 and a third processing module 830.

[0145] The first processing module 810 is used to process each first candidate line segment corresponding to the contour of the target object in the acquired first image, and obtain a first fitting contour of the contour segment corresponding to any two adjacent first candidate line segments in at least one first candidate line segment; the first fitting contour includes any two adjacent first candidate line segments or first candidate arcs, and the first candidate line segment is obtained by processing multiple contour points of the target object;

[0146] The second processing module 820 is used to process each first candidate line segment and the contour segment corresponding to the first candidate line segment to obtain a second fitting contour of the contour segment corresponding to the first candidate line segment; the second fitting contour includes the first candidate line segment, or at least two second candidate line segments, or at least one second candidate arc, and the at least two second candidate line segments are obtained by processing the contour segment corresponding to the first candidate line segment;

[0147] The third processing module 830 is used to merge any adjacent first candidate line segments and second candidate line segments, and / or any two adjacent second candidate line segments to obtain a target fitting contour corresponding to the target object; the target fitting contour includes at least one of at least one coherent candidate line segment and at least one candidate arc.

[0148] According to the contour determination device provided in the embodiment of the present application, by segmenting the contour, the fitting line segments and fitting arcs corresponding to the contour of the target object can be obtained, and then the fitting line segments obtained by the first segmentation are segmented for the second time to obtain the fitting contour obtained by the second segmentation, and the line segments finally fitted are merged to obtain the target fitting contour corresponding to the target object, which improves the accuracy and smoothness of the contour obtained by fitting, simplifies the data structure, reduces the subsequent storage and processing costs, and improves the efficiency, precision and accuracy of subsequent industrial detection.

[0149] In some embodiments, the third processing module 830 may also be used to:

[0150] Perform fitting processing on all contour points corresponding to any adjacent first candidate line segments and second candidate line segments to obtain third candidate arcs corresponding to all contour points;

[0151] When the maximum distance between the third candidate arc and the contour segments corresponding to all contour points is smaller than the maximum distance between the first candidate line segment and the second candidate line segment and the contour segment, the third candidate arc is determined as the target fitting contour of the contour segments corresponding to any adjacent first candidate line segment and the second candidate line segment.

[0152] In some embodiments, the third processing module 830 may also be used to:

[0153] When the first candidate line segments corresponding to any two adjacent second candidate line segments are different, fitting is performed on all contour points corresponding to any two adjacent second candidate line segments to obtain fourth candidate arcs corresponding to all contour points;

[0154] When the maximum distance between the fourth candidate arc and the contour segments corresponding to all contour points is less than the maximum distance between the two second candidate line segments and the contour segment, the fourth candidate arc is determined as the target fitting contour of the contour segment corresponding to any two adjacent second candidate line segments.

[0155] In some embodiments, the second processing module 820 may also be used to:

[0156] Obtaining the difference between each first candidate line segment and the contour segment corresponding to the first candidate line segment;

[0157] The contour segment corresponding to the first candidate line segment is processed based on the difference to obtain a second fitting contour corresponding to the contour segment.

[0158] In some embodiments, the second processing module 820 may also be used to:

[0159] When the difference is less than or equal to the error threshold, the first candidate line segment is determined as the second fitting contour of the contour segment corresponding to the first candidate line segment.

[0160] In some embodiments, the second processing module 820 may also be used to:

[0161] When the difference is greater than the error threshold, fitting is performed on all contour points included in the contour segment corresponding to the first candidate line segment to obtain at least two second candidate line segments corresponding to the contour segment;

[0162] Performing fitting processing on all contour points corresponding to any two adjacent second candidate line segments among the at least two second candidate line segments to obtain second candidate arcs of the contour segments corresponding to any two adjacent second candidate line segments;

[0163] When the maximum distance between the second candidate arc and the contour segment is less than the maximum distance between any two adjacent second candidate line segments and the contour segment, the second candidate arc is determined as the second fitting contour of the contour segment corresponding to the first candidate line segment;

[0164] When the maximum distance between the second candidate arc and the contour segment is greater than or equal to the maximum distance between any two adjacent second candidate line segments and the contour segment, the two adjacent second candidate line segments are determined as the second fitting contour of the contour segment corresponding to the first candidate line segment.

[0165] In some embodiments, the first processing module 810 may also be used to:

[0166] Fitting all contour points corresponding to any two adjacent first candidate line segments in at least one first candidate line segment to obtain a first candidate arc of all contour points corresponding to any two adjacent first candidate line segments;

[0167] When the maximum distance between the first candidate arc and the contour segments corresponding to all contour points is less than the maximum distance between any two adjacent first candidate line segments and the contour segment, the first candidate arc is determined as the first fitting contour;

[0168] When the maximum distance between the first candidate arc and the contour segments corresponding to all contour points is greater than or equal to the maximum distance between any two adjacent first candidate line segments and the contour segment, any two adjacent first candidate line segments are determined as the first fitting contour.

[0169] The contour determination device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0170] The contour determination device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an IOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0171] The contour determination device provided in the embodiment of the present application can achieve Figures 1 to 7 To avoid repetition, the various processes implemented by the method embodiment are not described here.

[0172] In some embodiments, Fig. 9 As shown, an embodiment of the present application also provides an electronic device 900, including a processor 901, a memory 902, and a computer program stored in the memory 902 and executable on the processor 901. When the program is executed by the processor 901, each process of the above-mentioned contour determination method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0173] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0174] On the other hand, the present application also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the various processes of the above-mentioned contour determination method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0175] On the other hand, the present application also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, it is implemented to perform the various processes of the above-mentioned contour determination method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0176] On the other hand, an embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned contour determination method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0177] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0178] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0179] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution can be essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.

[0180] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A contour determination method, characterized in that: include: Processing each first candidate line segment corresponding to the contour of the target object in the acquired first image, obtaining a first fitting contour of a contour segment corresponding to any two adjacent first candidate line segments among at least one of the first candidate line segments; the first fitting contour includes the any two adjacent first candidate line segments or first candidate arcs, and the first candidate line segment is obtained by processing a plurality of contour points of the target object; Processing each of the first candidate line segments and the contour segment corresponding to the first candidate line segment to obtain a second fitting contour of the contour segment corresponding to the first candidate line segment; the second fitting contour includes the first candidate line segment, or at least two second candidate line segments, or at least one second candidate arc, and the at least two second candidate line segments are obtained by processing the contour segment corresponding to the first candidate line segment; Any adjacent first candidate line segment and second candidate line segment, and / or any adjacent two second candidate line segments are merged to obtain a target fitting contour corresponding to the target object; the target fitting contour includes at least one of at least one coherent candidate line segment and at least one candidate arc.

2. The contour determination method according to claim 1, characterized in that: The merging of any adjacent first candidate line segment and second candidate line segment, and / or any adjacent two second candidate line segments to obtain a target fitting contour corresponding to the target object includes: Perform fitting processing on all contour points corresponding to the any adjacent first candidate line segments and second candidate line segments to obtain third candidate arcs corresponding to all the contour points; When the maximum distance between the third candidate arc and the contour segments corresponding to all contour points is smaller than the maximum distance between the first candidate line segment and the second candidate line segment and the contour segment, the third candidate arc is determined as the target fitting contour of the contour segment corresponding to any adjacent first candidate line segment and second candidate line segment.

3. The contour determination method according to claim 1, characterized in that: The merging of any adjacent first candidate line segment and second candidate line segment, and / or any adjacent two second candidate line segments to obtain a target fitting contour corresponding to the target object includes: In the case that the first candidate line segments corresponding to the two any adjacent second candidate line segments are different, fitting processing is performed on all contour points corresponding to the two any adjacent second candidate line segments to obtain fourth candidate arcs corresponding to all the contour points; When the maximum distance between the fourth candidate arc and the contour segments corresponding to all the contour points is less than the maximum distance between the two second candidate line segments and the contour segment, the fourth candidate arc is determined as the target fitting contour of the contour segment corresponding to any two adjacent second candidate line segments.

4. The contour determination method according to any one of claims 1 to 3, characterized in that: The processing of each of the first candidate line segments and the contour segment corresponding to the first candidate line segment to obtain a second fitting contour of the contour segment corresponding to the first candidate line segment includes: Obtaining a difference between each of the first candidate line segments and a contour segment corresponding to the first candidate line segment; The contour segment corresponding to the first candidate line segment is processed based on the difference to obtain a second fitting contour corresponding to the contour segment.

5. The contour determination method according to claim 4, characterized in that: The processing of the contour segment corresponding to the first candidate line segment based on the difference to obtain a second fitting contour corresponding to the contour segment includes: When the difference is less than or equal to an error threshold, the first candidate line segment is determined as the second fitting contour of the contour segment corresponding to the first candidate line segment.

6. The contour determination method according to claim 4, characterized in that: The processing of the contour segment corresponding to the first candidate line segment based on the difference to obtain a second fitting contour corresponding to the contour segment includes: When the difference is greater than the error threshold, fitting is performed on all contour points included in the contour segment corresponding to the first candidate line segment to obtain at least two second candidate line segments corresponding to the contour segment; Performing fitting processing on all contour points corresponding to any two adjacent second candidate line segments among the at least two second candidate line segments to obtain second candidate arcs of the contour segments corresponding to the any two adjacent second candidate line segments; When the maximum distance between the second candidate arc and the contour segment is smaller than the maximum distance between any two adjacent second candidate line segments and the contour segment, determining the second candidate arc as the second fitting contour of the contour segment corresponding to the first candidate line segment; When the maximum distance between the second candidate arc and the contour segment is greater than or equal to the maximum distance between any two adjacent second candidate line segments and the contour segment, the two adjacent second candidate line segments are determined as the second fitting contour of the contour segment corresponding to the first candidate line segment.

7. The contour determination method according to any one of claims 1 to 3, characterized in that: The step of processing the first candidate line segments corresponding to the contour of the target object in the acquired first image to obtain a first fitting contour of a contour segment corresponding to any two adjacent first candidate line segments of at least one of the first candidate line segments includes: Fitting all contour points corresponding to any two adjacent first candidate line segments in at least one of the first candidate line segments to obtain a first candidate arc of all contour points corresponding to the any two adjacent first candidate line segments; When the maximum distance between the first candidate arc and the contour segments corresponding to all the contour points is smaller than the maximum distance between any two adjacent first candidate line segments and the contour segment, determining the first candidate arc as the first fitting contour; When the maximum distance between the first candidate arc and the contour segments corresponding to all the contour points is greater than or equal to the maximum distance between any two adjacent first candidate line segments and the contour segment, the any two adjacent first candidate line segments are determined as the first fitting contour.

8. A contour determination device, characterized in that: include: A first processing module is used to process each first candidate line segment corresponding to the contour of the target object in the acquired first image, and obtain a first fitting contour of a contour segment corresponding to any two adjacent first candidate line segments among at least one of the first candidate line segments; the first fitting contour includes the any two adjacent first candidate line segments or first candidate arcs, and the first candidate line segment is obtained by processing a plurality of contour points of the target object; a second processing module, configured to process each of the first candidate line segments and the contour segment corresponding to the first candidate line segment, to obtain a second fitting contour of the contour segment corresponding to the first candidate line segment; the second fitting contour includes the first candidate line segment, or at least two second candidate line segments, or at least one second candidate arc, and the at least two second candidate line segments are obtained by processing the contour segment corresponding to the first candidate line segment; The third processing module is used to merge any adjacent first candidate line segments and second candidate line segments, and / or any two adjacent second candidate line segments to obtain a target fitting contour corresponding to the target object; the target fitting contour includes at least one of at least one coherent candidate line segment and at least one candidate arc.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the contour determination method according to any one of claims 1 to 7 is implemented.

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

Citation Information

Patent Citations

  • Method and device for determining straight line outline of scanned object and storage medium

    CN109785335A

  • Contour molded line extraction and segmentation method and system of leaf-shaped hole image, equipment and storage medium

    CN113781508A

  • Outline dividing system

    JP1993342341A