Automatic primitive identification method
By putting forward an automatic recognition method in the visual measurement technology of the machine, using image filtering, adaptive threshold segmentation and fitting technology to automatically identify the outline of the image, solving the problem of users manually adding measurement tools and low efficiency of ROI. Efficient measurement process.
Patent Information
- Application Number
- CN202411381525.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-01-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In machine vision measurement technology, users need to manually add measurement tools and ROI, especially when there are a large number of elements on the image, which is inefficient and cumbersome.
Proposal an automatic recognition method of Graphic Earnate, by obtaining the measurement image to be measured, filtering and adaptive threshold segmentation, extract the contour, and automatically identify the image contour through circular fitting and straight line fitting.
The steps to automatically identify the map on the part size measuring instrument, replacing the artificial labeling measurement area, and greatly improved the measurement efficiency.
Smart Images

Figure CN119380074A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of automatic primitive recognition, and in particular to an automatic primitive recognition method. Background Art
[0002] As an important branch of artificial intelligence, machine vision technology has developed rapidly in recent years. This technology mainly uses computers to simulate human visual functions, extracts information from images of objective objects through image processing and pattern recognition, processes and understands it, and finally applies it to actual detection, measurement and control.
[0003] At present, machine vision measurement technology has been widely used in all walks of life. The common steps of image measurement based on machine vision are: after the camera collects the image of the object to be measured, the user selects a circle, arc or straight line measurement tool to define the detection range on the image, and then the software performs edge detection and primitive fitting according to the range set by the user; although this operation method can realize the measurement function, when there are a large number of primitives on the image, it is inefficient for the user to add measurement tools, and the operation is cumbersome; for example: when the image measuring instrument captures the image of the part, the user needs to set the ROI (Region of Interest), and the background algorithm extracts the edge of the part according to the ROI, and uses the fitting algorithm to fit the edge into the corresponding primitive; when there are a large number of primitives in the part, the method of adding ROI by the user is inefficient and cumbersome. Summary of the invention
[0004] The purpose of the present invention is to provide a method for automatically identifying graphic elements to solve the problems raised in the above-mentioned background technology.
[0005] In order to solve the above technical problems, the present invention provides the following technical solutions: a method for automatically identifying graphic elements, the method comprising the following steps:
[0006] S10, obtaining an image to be measured, filtering the image, performing adaptive threshold segmentation, and extracting contours;
[0007] S20, performing circle fitting on the extracted contour, and dividing it into a circle contour and a combined contour; if the extracted contour is a circle contour, directly executing step S50; if the extracted contour is a combined contour, executing step S30;
[0008] S30, initializing the cutoff point, dividing the combined contour into a straight line and an arc, and performing straight line fitting and arc fitting on the straight line and the arc respectively;
[0009] S40, updating the initialization truncation point in the combined contour to obtain the long contour segment of the straight line and the arc;
[0010] S50, outputting the circle fitting result of the circle contour and the straight line and arc fitting results corresponding to the long contour segment in the combined contour; wherein the circle fitting result is a fitted circle; and the straight line and arc fitting results are a fitted straight line and a fitted arc.
[0011] Compared with the prior art, the beneficial effects achieved by the present invention are as follows: a method for automatic primitive recognition is proposed, which performs adaptive threshold segmentation on an image, automatically extracts the image contour, and automatically recognizes the extracted image contour by means of circle fitting and line fitting, and outputs the fitting result after recognition, so that its application on a part dimension measuring instrument replaces the step of manually marking the measurement area, thereby greatly improving the measurement efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 It is an edge contour image extracted in an embodiment of a method for automatic recognition of graphic elements of the present invention;
[0013] Figure 2 It is a truncation point acquisition strategy diagram in an embodiment of a method for automatic identification of graphic elements of the present invention;
[0014] Among them, s represents Figure 2 The extracted edge contours. DETAILED DESCRIPTION
[0015] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0016] In this embodiment: a method for automatic identification of primitives is provided. When there are a large number of primitives in a part, the method of adding ROI by the user is inefficient and cumbersome, so a demand for automatic identification of ROI and assisting user operation is proposed; after the image is acquired, the algorithm automatically identifies the primitives that may exist in the image according to the image features and the minimum straight line length and minimum round angle coefficient input by the user, and displays them as ROI areas on the image, and then the user checks, adds, modifies, and deletes them, so as to help the user quickly complete the measurement settings; the method includes the following steps:
[0017] S10, obtaining an image to be measured, filtering the image, performing adaptive threshold segmentation, and extracting contours.
[0018] Specifically, the user inputs image segmentation parameters, obtains the image to be measured, filters the obtained image to be measured, performs adaptive threshold segmentation, and extracts contours; wherein the contours are divided into circular contours and combined contours; the image segmentation parameters include a minimum straight line length and a minimum circular angle coefficient.
[0019] In this embodiment, the image of the part to be measured is obtained, the image is filtered using Gaussian filtering, and the image is adaptively segmented by the Otsu method. After the threshold segmentation is completed, the contour extraction operator of the opencv algorithm library is used to extract the edge contour of the image to obtain Figure 1 The edge profile image is shown.
[0020] It should be noted that the contour is a closed line, which is composed of two adjacent pixel points; in this method, the contour is divided into two types: circular contour and combined contour. The circular contour means that the contour is composed of a complete circle; the combined contour means that the contour is composed of a series of straight lines and arcs; this method automatically identifies and processes the two types of contours respectively.
[0021] It should be noted that the minimum straight line length represents the minimum straight line detection length, and straight lines shorter than this length will be discarded; the minimum circular angle coefficient has a value range of [0,1], which is used to describe the range of the contour segment continuously covering the circumference. When the coefficient is 1, the contour segment must continuously cover the entire circle to be recognized as a circular contour. When the coefficient is 0.5, the contour segment continuously covers half of the circumference to be recognized as a circular contour.
[0022] S20, performing circle fitting on the extracted contour, and dividing it into a circular contour and a combined contour; if the extracted contour is a circular contour, directly executing step S50; if the extracted contour is a combined contour, executing step S30.
[0023] Specifically, the contour is divided into a circular contour and a combined contour, and a circle fitting is performed on the extracted contour according to the least squares method to obtain a fitted primitive of the extracted contour; the circular contour and the combined contour are screened out according to the inlier ratio and the inlier connected domain of the fitted primitive; if the screened contour is a combined contour, step S30 is executed; if the screened contour is a circular contour, step S50 is executed; wherein, the inlier represents a contour point whose distance to the fitted primitive is within the inlier threshold range; the inlier ratio represents the ratio of the number of inliers of the fitted primitive to the number of contour points of the fitted primitive; the inlier connected domain represents the ratio of the distance between two consecutive inliers on the fitted primitive to the circumference of the fitted primitive.
[0024] It should be noted that, according to step S10, a series of contours are extracted, including circular contours and combined contours; according to step S20, all circular contours are screened out, and the remaining contours are defined as combined contours.
[0025] Furthermore, the circle fitting method is:
[0026] Establish a coordinate system about the X-axis and the Y-axis, and let the expression of the fitting circle be:
[0027] (Xa) 2 +(Yb) 2 =r 2
[0028] Then order:
[0029]
[0030] The calculation results are:
[0031]
[0032] Where a and b represent the center of the fitted circle, r represents the fitted radius of the circle, N represents the number of contour points of the fitted primitive, and X i and Y i They respectively represent the coordinates of the i-th contour point; i represents the index of the midpoint of the contour; i=1, 2, ..., N; C, D, E, G, and H are the intermediate variables of the circle fitting process respectively.
[0033] It should be noted that the commonly used methods for circle detection in the industry include Hough transform method, random sampling consistency method, fitting method, etc. This method determines the circle based on the fitting method. Its basic principle is: when the contour is a circle, after fitting the contour into a circle, the distance between the points on the contour and the fitting circle should be within a threshold T d If the condition is met, it is considered a circle.
[0034] Furthermore, according to the interior point ratio and interior point connected domain of the fitted primitive, the method steps for selecting the circular contour and the combined contour are as follows:
[0035] S201, analyzing the proportion of inliers of the fitted primitives and determining an inlier threshold T d :
[0036] T d =max{min{W,H}*0.5%,2}
[0037] Wherein, W represents the width of the image to be measured; H represents the height of the image to be measured;
[0038] According to the inlier threshold T d , determine the number of internal points N of the fitting primitive i ; According to the number of interior points and contour points of the fitting primitive, the proportion of interior points of the fitting primitive f is obtained n :
[0039]
[0040] Where N represents the number of contour points of the fitted primitive;
[0041] Determine the tolerance T f , T f With f n For comparison; when f n <T f When f n ≥T f When , execute step S202;
[0042] S202, fitting the internal point connected domain d of the primitive g For analysis, according to the calculation formula:
[0043]
[0044] Among them, D z represents the maximum distance between two consecutive inner points; r represents the fitting radius of the circle;
[0045] Determine the minimum circular angle coefficient entered by the user; when d g When the angle is not less than the minimum circular angle coefficient input by the user, the contour is judged to be a circular contour; when d g When it is smaller than the minimum circular angle coefficient input by the user, the contour is judged as a combined contour.
[0046] It should be noted that T d The value of determines the quality of the interior point, so T d The selection of T is very important; combined with relevant papers and engineering experience, the above formula is proposed d Calculate; take the industrial camera resolution of 2448*2048 commonly used in part measuring instruments as an example, 0.5% of 2048 is about 10 pixels; under a general optical system, the transition zone of the image edge is 3 to 4 pixels, that is, the edge point may shift by 3 to 4 pixels, and the threshold of 10 pixels can cover this shift; 2 is the minimum value limit to prevent the threshold from being too small, resulting in the phenomenon that the points adjacent to the fitting circle are misjudged as external points; get T d Then, f is calculated according to the formula n , when f n Value less than T f When f n The value should reach 1, but due to the processing error, the edge contour is not a perfect circle, so an appropriate tolerance T is required. f To accommodate more measurement scenarios; after experimental analysis, in this implementation, T f Set the value to 0.9.
[0047] S30, initializing the truncation point, dividing the combined contour into a straight line and an arc, and performing straight line fitting and arc fitting on the straight line and the arc respectively.
[0048] Specifically, according to the curvature initialization cutoff point, the least squares method is used to perform straight line fitting and arc fitting on the contour segment formed between the initialization cutoff points, respectively, to obtain the fitting primitives corresponding to the contour segment fitting straight line and the fitting arc, respectively, and according to the inner point ratio of the fitting primitive, the primitive attributes corresponding to the contour segment formed between the initialization cutoff points are judged; if the contour segment formed between the initialization cutoff points is a straight line or an arc, execute step S40; if the contour segment formed between the initialization cutoff points is a combination of a straight line and an arc, execute step S50; the primitive attributes include a straight line, an arc, and a combination of a straight line and an arc.
[0049] It should be noted that the combined contour may be a combination of straight lines and straight lines, a combination of arcs and arcs, or a combination of straight lines and arcs; steps S30-S40 need to split the combined contour into straight line segments and arc segments.
[0050] Furthermore, according to the curvature initialization cutoff point, the least square method is used to perform straight line fitting and arc fitting on the contour segment formed between the initialization cutoff points, respectively, to obtain the fitting primitives corresponding to the contour segment fitting straight line and the fitting arc, respectively, and according to the interior point ratio of the fitting primitive, the method steps for judging the primitive attributes corresponding to the contour segment formed between the initialization cutoff points are as follows:
[0051] S301, calculate the curvature of the contour point according to the calculation formula:
[0052]
[0053] Among them, R i1 =P i -P i-1 ; R i2 =P i+1 -P i ;P i =[X i ,Y i ] T ;k i represents the curvature of the i-th contour point; P i P represents the column vector of the i-th contour point; i-1 and P i+1 P i Column vector of adjacent contour points; T represents the transposed sign; R i1 Indicates P i-1 To P i The vector of i Indicates P i To P i+1A vector of; N represents the number of contour points of the fitted primitive; i represents the index of the point in the contour; i = 1, 2, ..., N;
[0054] Determine the curvature initialization screening threshold T k , T k With k i For comparison; when k i >T k When k i ≤T k When , the contour point is not the initialization truncation point;
[0055] It should be noted that when a contour is composed of multiple contour segments, there must be an intersection point between each contour segment, which we record as a truncation point; a truncation point refers to the intersection point between contour segments, which may exist between two straight lines, between a straight line and an arc, or between arcs; the truncation point divides the contour into individual contour segments, and the truncation point must appear at a contour point with a larger curvature.
[0056] It should be noted that the curvature of all contour points is calculated, when k i >T k When , the contour point is considered to be a truncation point, and the truncation point is added to the set of candidate points as the initial truncation point; since this step is mainly used to filter out points with larger curvatures and reduce the amount of calculation for subsequent steps, T here is k The value setting requirements are not strict. This method is based on the engineering verification results and sets T k =22.5, this value can filter out the points in the smooth straight line to a large extent, and the noise points that cannot be filtered out will be processed by subsequent steps.
[0057] S302, using the least squares method to perform straight line fitting and arc fitting on the contour segments formed between the initialization truncation points, respectively, to obtain fitting primitives corresponding to the contour segment fitting straight line and fitting arc, respectively, and to determine the proportion of inner points of the contour segment fitting primitives in the straight line fitting. The ratio of inner points of contour segment fitting primitives in arc fitting
[0058] S303, With T f to compare; when When , the contour segment formed between the initialization truncation points is judged to be a combination of straight lines and arcs; when there is or When , determine whether the contour segment formed between the initialization truncation points is a straight line or an arc.
[0059] Furthermore, the straight line fitting method is:
[0060] Establish a coordinate system about the X-axis and Y-axis, and let the expression of the fitting line be:
[0061] Y=uX+v
[0062] Construct the error function:
[0063]
[0064] Then order:
[0065]
[0066] The calculation results are:
[0067]
[0068] Where u is the slope of the fitted line; v is the intercept of the fitted line; f (x) represents the error value; N represents the number of contour points of the fitted primitive; X i and Y i They represent the coordinates of the i-th contour point respectively; i represents the index of the midpoint of the contour; i=1, 2, ..., N; M, I, J, K are the intermediate variables of the straight line fitting process respectively.
[0069] It should be noted that the arc fitting method is the same as the circle fitting method; the inner point ratio of the contour segment fitting primitive in the straight line fitting is The ratio of inner points of contour segment fitting primitives in arc fitting The confirmation method is the same as that in step S201. n The confirmation method is the same.
[0070] S40, updating the initialization truncation points in the combined contour to obtain the long contour segments of the straight line and the arc.
[0071] Specifically, according to the straight line fitting error and the arc fitting error, determine whether the contour segment formed between the initialization truncation points belongs to a straight line or an arc; wherein, the initialization truncation points are updated, the contour segments formed between the initialization truncation points under the same straight line or arc are combined, and the contour segment combination with the longest distance that satisfies the straight line or arc is determined to obtain a long contour segment; when the contour segments are combined into a long contour segment, the initialization truncation points at both ends of the long contour segment are retained as new truncation points, and all the initialization truncation points inside the long contour segment are deleted.
[0072] Furthermore, according to the straight line fitting error and the arc fitting error, the method steps for determining whether the contour segment formed between the initialization truncation points belongs to a straight line or an arc are as follows:
[0073] S401, calculating the straight line fitting error E corresponding to the contour segment formed between the initialization cutoff pointsL :
[0074]
[0075] Where u represents the slope of the fitted line; v represents the intercept of the fitted line; N represents the number of contour points of the fitted primitive; X i and Y i Respectively represent the coordinates of the i-th contour point; i represents the index of the contour midpoint; i = 1, 2, ..., N;
[0076] S402, calculating the arc fitting error E corresponding to the contour segment formed between the initialization truncation points a :
[0077]
[0078] Where a and b represent the coordinates of the center of the fitted circle; r represents the fitted radius of the circle;
[0079] S403, E L With E a For comparison; when E L >E a When E L ≤E a , the contour segment is a straight line.
[0080] It should be noted that the commonly used methods for line and arc detection in the industry include Hough transform method, random sampling consistency method, fitting method, etc.; this method determines the line and arc based on the fitting method, and its basic principle is: after obtaining the contour segment formed between the initialization truncation points, perform straight line fitting and arc fitting on it respectively. When the contour is an arc, the arc fitting error must be smaller than the straight line fitting error. When the contour is a straight line, the straight line fitting error must be smaller than the arc fitting error.
[0081] like Figure 2 As shown, Figure 1 In this implementation, since there are a lot of noise points in the initialization cutoff point, the noise points must be removed to obtain the true cutoff point of each primitive. Figure 21-7 are the initial truncation points. Starting from the starting point 1, each time a minimum straight line length is added, a straight line and arc fitting is performed to find the longest truncation point that meets the circle or straight line. Taking 1 as the starting point, line segments 1-2, 1-3, 1-4, 1-5, 1-6, and 1-7 are fitted into straight lines and arcs respectively. According to the above judgment criteria for straight lines and arcs, 1-2 and 1-3 meet the primitive attributes of straight lines, and 1-4, 1-5, 1-6, and 1-7 do not meet the attributes of straight lines or arcs. Since the distance of 1-3 is greater than 1-2, point 2 is discarded, and 3 is used as the starting point to continue fitting. 3-4, 3-5, 3-6, and 3-7 all meet the primitive attributes of arcs, that is, f n Greater than 0.9; since the distance 3-7 is the longest, points 5, 6, and 7 are discarded, and the final initialization cutoff points are updated to 1, 3, and 7, and the arc is divided into the long contour segment of the 1-3 straight line and the long contour segment of the 3-7 arc.
[0082] S50, outputting the circle fitting result of the circle contour and the straight line and arc fitting results corresponding to the long contour segment in the combined contour; wherein the circle fitting result is a fitted circle; and the straight line and arc fitting results are a fitted straight line and a fitted arc.
[0083] It should be noted that the output fitting results are circles, arcs and straight lines formed by the fitting circle, arc and straight line expressions corresponding to the contour.
[0084] It should be noted that, in the combined contour, when the contour segment is a straight line or an arc, the output fitting result is a long contour segment obtained by combining the contour segments formed between the initialization truncation points.
[0085] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for automatically identifying graphic elements, characterized in that: The method comprises the following steps: S10, obtaining an image to be measured, filtering the image, performing adaptive threshold segmentation, and extracting contours; S20, performing circle fitting on the extracted contour, and dividing it into a circle contour and a combined contour; if the extracted contour is a circle contour, directly executing step S50; if the extracted contour is a combined contour, executing step S30; S30, initializing the cutoff point, dividing the combined contour into a straight line and an arc, and performing straight line fitting and arc fitting on the straight line and the arc respectively; S40, updating the initialization truncation point in the combined contour to obtain the long contour segment of the straight line and the arc; S50, outputting the circle fitting result of the circle contour and the straight line and arc fitting results corresponding to the long contour segment in the combined contour; wherein the circle fitting result is a fitted circle; and the straight line and arc fitting results are a fitted straight line and a fitted arc.
2. The method for automatically identifying graphic elements according to claim 1, characterized in that: In the step S10, the user inputs image segmentation parameters, obtains the image to be measured, filters the obtained image to be measured, performs adaptive threshold segmentation, and extracts contours; wherein the image segmentation parameters include a minimum straight line length and a minimum round angle coefficient.
3. The method for automatically identifying graphic elements according to claim 2, characterized in that: In the step S20, the contour is divided into a circular contour and a combined contour, and a circle fitting is performed on the extracted contour according to the least squares method to obtain a fitted primitive of the extracted contour; the circular contour and the combined contour are screened out according to the inlier ratio and the inlier connected domain of the fitted primitive; if the screened contour is a combined contour, step S30 is executed; if the screened contour is a circular contour, step S50 is executed; wherein, the inlier represents a contour point whose distance to the fitted primitive is within the inlier threshold range; the inlier ratio represents the ratio of the number of inliers of the fitted primitive to the number of contour points of the fitted primitive; the inlier connected domain represents the ratio of the distance between two consecutive inliers on the fitted primitive to the circumference of the fitted primitive.
4. The method for automatically identifying graphic elements according to claim 3, characterized in that: In the step S30, according to the curvature initialization cutoff point, the contour segment formed between the initialization cutoff points is respectively fitted with a straight line and an arc using the least squares method, and the fitting primitives corresponding to the contour segment fitting straight line and the fitting arc are respectively obtained. According to the inner point ratio of the fitting primitive, the primitive attribute corresponding to the contour segment formed between the initialization cutoff points is judged; if the contour segment formed between the initialization cutoff points is a straight line or an arc, step S40 is executed; if the contour segment formed between the initialization cutoff points is a combination of a straight line and an arc, step S50 is executed; the primitive attributes include a straight line, an arc, and a combination of a straight line and an arc.
5. The method for automatically identifying graphic elements according to claim 4, characterized in that: In the step S40, it is determined whether the contour segment formed between the initialization truncation points belongs to a straight line or an arc according to the straight line fitting error and the arc fitting error; wherein, the initialization truncation points are updated, the contour segments formed between the initialization truncation points under the same straight line or arc are combined, and the contour segment combination with the longest distance that satisfies the straight line or arc is determined to obtain a long contour segment; when the contour segments are combined into a long contour segment, the initialization truncation points at both ends of the long contour segment are retained as new truncation points, and all the initialization truncation points inside the long contour segment are deleted.
6. The method for automatically identifying graphic elements according to claim 5, characterized in that: According to the interior point ratio and interior point connected domain of the fitted primitive, the method steps for screening out the circular contour and the combined contour are as follows: S201, analyzing the proportion of inliers of the fitted primitives and determining an inlier threshold T d : T d =max{min{W,H}*0.5%,2} Wherein, W represents the width of the image to be measured; H represents the height of the image to be measured; According to the inlier threshold T d , determine the number of internal points N of the fitting primitive i ; According to the number of interior points and contour points of the fitting primitive, the proportion of interior points of the fitting primitive f is obtained n : Where N represents the number of contour points of the fitted primitive; Determine the tolerance T f , T f With f n For comparison; when f n <T f When f n ≥T f When , execute step S202; S202, the internal point connected domain d of the fitting primitive g For analysis, according to the calculation formula: Among them, D z represents the maximum distance between two consecutive inner points; r represents the fitting radius of the circle; Determine the minimum circular angle coefficient entered by the user; when d g When the angle is not less than the minimum circular angle coefficient input by the user, the contour is judged to be a circular contour; when d g When it is smaller than the minimum circular angle coefficient input by the user, the contour is judged as a combined contour.
7. The method for automatically identifying graphic elements according to claim 6, characterized in that: According to the curvature initialization cutoff point, the contour segments formed between the initialization cutoff points are respectively fitted with straight lines and arcs using the least squares method, and the fitting primitives corresponding to the contour segment fitting straight lines and fitting arcs are respectively obtained. According to the proportion of the inner points of the fitting primitives, the method steps for judging the primitive attributes corresponding to the contour segments formed between the initialization cutoff points are as follows: S301, calculate the curvature of the contour point according to the calculation formula: Among them, R i1 =P i -P i-1 ; R i2 =P i+1 -P i ;P i =[X i ,Y i ] T ;k i represents the curvature of the i-th contour point; P i P represents the column vector of the i-th contour point; i-1 and P i+1 P i Column vector of adjacent contour points; T represents the transposed sign; R i1 Indicates P i-1 To P i The vector of i Indicates P i To P i+1 A vector of; N represents the number of contour points of the fitted primitive; i represents the index of the point in the contour; i = 1, 2, ..., N; Determine the curvature initialization screening threshold T k , T k With k i For comparison; when k i >T k When k i ≤T k When , the contour point is not the initialization truncation point; S302, using the least squares method to perform straight line fitting and arc fitting on the contour segments formed between the initialization truncation points, respectively, to obtain fitting primitives corresponding to the contour segment fitting straight line and fitting arc, respectively, and to determine the proportion of inner points of the contour segment fitting primitives in the straight line fitting. The ratio of inner points of contour segment fitting primitives in arc fitting S303, With T f to compare; when When , the contour segment formed between the initialization truncation points is judged to be a combination of straight lines and arcs; when there is or When , determine whether the contour segment formed between the initialization truncation points is a straight line or an arc.
8. The method for automatically identifying graphic elements according to claim 7, characterized in that: According to the straight line fitting error and the arc fitting error, the method steps for determining whether the contour segment formed between the initialization truncation points belongs to a straight line or an arc are as follows: S401, calculating the straight line fitting error E corresponding to the contour segment formed between the initialization cutoff points L : Where u represents the slope of the fitted line; v represents the intercept of the fitted line; N represents the number of contour points of the fitted primitive; X i and Y i Respectively represent the coordinates of the i-th contour point; i represents the index of the contour midpoint; i = 1, 2, ..., N; S402, calculating the arc fitting error E corresponding to the contour segment formed between the initialization truncation points a : Where a and b represent the coordinates of the center of the fitted circle; r represents the fitted radius of the circle; S403, E L With E a For comparison; when E L >E a When E L ≤E a , the contour segment is a straight line.
9. The method for automatically identifying graphic elements according to claim 1, characterized in that: The circle fitting method is: Establish a coordinate system about the X-axis and the Y-axis, and let the expression of the fitting circle be: (X-a) 2 +(Y-b) 2 =r 2 Then order: The calculation results are: Where a and b represent the coordinates of the center of the fitted circle; r represents the fitted radius of the circle; N represents the number of contour points of the fitted primitive; X i and Y i They respectively represent the coordinates of the i-th contour point; i represents the index of the midpoint of the contour; i=1, 2, ..., N; C, D, E, G, and H are the intermediate variables of the circle fitting process respectively.
10. The method for automatically identifying graphic elements according to claim 1, characterized in that: The straight line fitting method is: Establish a coordinate system about the X-axis and Y-axis, and let the expression of the fitting line be: Y=uX+v Construct the error function: Then order: The calculation results are: Where u is the slope of the fitted line; v is the intercept of the fitted line; f (x) represents the error value; N represents the number of contour points of the fitted primitive; X i and Y i They represent the coordinates of the i-th contour point respectively; i represents the index of the midpoint of the contour; i=1, 2, ..., N; M, I, J, K are the intermediate variables of the straight line fitting process respectively.
Citation Information
Patent Citations
Industrial part contour line multi-feature extracting method with additional constraint conditions
CN104655041A
Cited By
Method and system for quickly acquiring component characteristic parameters, storage medium and equipment
CN120374735A
DCS monitoring system primitive caching and dynamic loading method based on CIM / G specification
CN120780461A