Workpiece profile measurement method, system, and storage medium
By using the Sobel or Canny algorithm to obtain the baseline profile in profile measurement, building a FLANN kd tree, and calculating the Euclidean distance and the dot product of the normal vector, the problems of high computational cost and low efficiency in profile measurement are solved, and efficient profile measurement is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-15
- Publication Date
- 2026-03-24
AI Technical Summary
Existing technologies involve large computational loads and are time-consuming in contour measurement, and the location and number of intersection points are difficult to determine, resulting in low measurement efficiency.
The Sobel or Canny algorithm is used to obtain the baseline contour, a kd tree is built based on FLANN, the image is segmented by rectangular blocks, and the contour value is calculated by Euclidean distance and dot product of normal vectors, which reduces the amount of computation and improves efficiency.
By reducing computational load and optimizing algorithm complexity, the efficiency of contour measurement is significantly improved, and the computational burden per run is reduced.
Smart Images

Figure CN116188426B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of contour measurement technology, and more specifically, to a workpiece contour measurement method, system, and storage medium. Background Technology
[0002] Currently, when measuring profile, the method used to calculate profile is to traverse the "reference profile" and calculate the intersection point of the straight line in the normal direction of the reference profile and the "profile to be measured". The Euclidean distance between this intersection point and the "reference profile" is taken as the profile of that point. If the intersection point is in the positive direction of the normal, it means that the point is convex; if the intersection point is in the opposite direction of the normal, it means that the point is concave.
[0003] The computational model described above is relatively simple to create, but each run is time-consuming, and the location and number of intersection points are not easy to determine. Summary of the Invention
[0004] The purpose of this application is to provide a workpiece contour measurement method, system, and storage medium, which can reduce the amount of calculation in the contour measurement process and improve the efficiency of contour measurement.
[0005] This application also provides a method for measuring the contour of a workpiece, including the following steps:
[0006] The reference contour is obtained from the reference image of the reference workpiece using the Sobel or Canny algorithm. Based on the reference contour, a tree is built using FLANN, that is, a kd tree is built according to the size of the x and y coordinates of the contour points. This tree is similar to a binary search tree. It can be understood as dividing an image into rectangular blocks using all contour points, with each rectangular block as a "hyperplane". When searching for nearby points, it is only necessary to know which "hyperplane" the test point falls in, and then it is considered that the test point is closest to the contour point corresponding to that "hyperplane".
[0007] Position correction is performed on the image to be tested, that is, the angle θ between the image to be tested and the reference image is obtained based on the similarity of contour points (or graphic similarity). Then the image to be tested is rotated in the opposite direction by θ so that the angular direction of the workpiece to be tested is consistent with the direction of the reference workpiece in the reference image.
[0008] The contour of the workpiece to be measured is extracted to obtain the contour points to be measured;
[0009] Traverse the contour points to be measured, select N points on the reference contour that are closest to the contour points to be measured, calculate the distance between the contour points to be measured and the selected N points respectively, and determine the contour value of the contour points to be measured based on the distances.
[0010] The profile angle is defined as the dot product of the normal vector at a point on the profile to be measured and the normal vector at a point on the reference profile whose distance meets the preset value.
[0011] Optionally, the reference profile is obtained using the Sobel algorithm or the Canny algorithm.
[0012] Optionally, the contour extraction of the workpiece to be measured is specifically performed by using the Sobel algorithm or the Canny algorithm to extract the contour of the workpiece to be measured.
[0013] Optionally, the step of building a tree based on the reference contour using FLANN specifically involves:
[0014] A kd-tree is built based on the magnitude of the horizontal and vertical coordinates of the reference contour points. That is, a map is divided into rectangular blocks called "hyperplanes" using all the reference contour points. When searching for nearby points, the contour point corresponding to the "hyperplane" on which the test point falls is determined to be the closest.
[0015] Optionally, the position correction of the image to be tested specifically includes:
[0016] The angle θ between the image to be tested and the reference image is obtained based on the similarity of contour points (or graphic similarity). Then, the image to be tested is rotated in the opposite direction by θ so that the angular direction of the workpiece to be tested is consistent with the direction of the reference workpiece in the reference image.
[0017] Optionally, the step of using the dot product of the normal vector at a point on the profile to be measured and the normal vector at a point on a reference profile whose distance meets a preset value as the profile angle specifically includes:
[0018] Traverse the contour points to be measured. Let P be the current contour point being traversed. Find the n points in the reference contour that are closest to P, and denote them as N0, N1, ..., N. n-1 Where n∈Z;
[0019] Calculate N0, N1, ..., N respectively. n-1 The Euclidean distance to point P is sorted. Sort is necessary because when finding the nearest n points, FLAUTION is used for quick lookup, which finds the n points closest in Manhattan distance. However, what is needed now is the point closest in Euclidean distance. The point with the smallest Euclidean distance is denoted as N. min And N min The Euclidean distance to point P is d min If d min If the value is not 0, record the reference profile at N. min The normal vector at point V is min Then the profile angle θ is V min and Given the angle between vectors, the sign of the cosine of that angle indicates whether the defect is concave or convex.
[0020]
[0021] Optionally, the contour points to be measured are traversed, N points closest to the contour points to be measured on the reference contour are selected, distances between the contour points to be measured and the selected N points are calculated respectively, and a profile value of the contour points to be measured is determined according to the distances; specifically comprising:
[0022] The contour points to be measured are traversed, and a non-zero value with the same sign of the continuous cosine value obtained in the traversal process is taken as a defect segment, and a maximum value of d min at each contour point in the defect segment is taken as a profile value of the defect segment.
[0023] Absolute values of the profile values of each defect segment in the workpiece to be measured are summed to obtain a profile value of the workpiece to be measured.
[0024] In a second aspect, the present application also provides a workpiece profile measurement system, which comprises a memory and a processor, the memory comprising a workpiece profile measurement method program, and the workpiece profile measurement method program is executed by the processor to realize the following steps:
[0025] A reference contour is obtained from a reference image of a reference workpiece, and a tree is built based on the reference contour based on FLANN;
[0026] A position correction is performed on a to-be-measured image, so that an angle direction of the workpiece to be measured is consistent with a direction of the reference workpiece in the reference image;
[0027] A contour extraction is performed on the workpiece to be measured to obtain contour points to be measured;
[0028] The contour points to be measured are traversed, N points closest to the contour points to be measured on the reference contour are selected, distances between the contour points to be measured and the selected N points are calculated respectively, and a profile value of the contour points to be measured is determined according to the distances;
[0029] A dot product of a normal vector at a point on the contour to be measured and a normal vector at a point on the reference contour with a distance complying with a preset value is taken as a profile angle.
[0030] Optionally, the dot product of the normal vector at the point on the contour to be measured and the normal vector at the point on the reference contour with the distance complying with the preset value is taken as the profile angle, and specifically comprising:
[0031] The contour points to be measured are traversed, and a current contour point to be measured is set as P, n points closest to the point P in the reference contour are found and are respectively denoted as N0, N1, …, N n-1 ; wherein n∈Z;
[0032] N0, N1, …, N n-1Euclidean distance to P point and sort, sort is because when looking for the nearest n points, FLAAN fast lookup is used, and the Manhattan distance nearest n points are found, and the current needs are the Euclidean distance nearest point, and the Euclidean distance minimum point is recorded as N min , and the Euclidean distance of N min to P point is d min , if d min is not 0, the normal vector of the reference contour at N min is recorded as V min , then the profile angle θ is the included angle between V min and vector, and then according to the positive and negative of the cosine value of the included angle, the defect is concave or convex:
[0033]
[0034] Optionally, the traversing the to-be-measured profile point, selecting N points closest to the to-be-measured profile point on the reference contour, respectively calculating the distance between the to-be-measured profile point and the selected N points, and determining the profile value of the to-be-measured profile point according to the distance; specifically comprising:
[0035] Traversing the to-be-measured profile point, taking the non-zero value of the continuous cosine value with the same sign in the traversing process as a defect segment, and taking the maximum value of d min at each profile point in the segment as the profile value of the defect segment;
[0036] Summing the absolute value of the profile value of each defect segment in the to-be-measured workpiece to obtain the profile value of the to-be-measured workpiece.
[0037] In a third aspect, the present application also provides a computer readable storage medium, wherein the computer readable storage medium comprises a workpiece profile measurement method program, and the workpiece profile measurement method program is executed by a processor to realize the steps of the workpiece profile measurement method.
[0038] As can be seen from the above, the present application provides a workpiece profile measurement method, system and medium. The present application first constructs (FLANN) all "reference contours", then traverses the "to-be-measured profile", selects N points (Manhattan distance) closest to the points on the "to-be-measured profile", selects the shortest Euclidean distance result from the N points as the profile value of the point, and the direction is determined by the dot product result of the normal vector at the point on the "to-be-measured profile" and the normal vector at the point on the "reference contour" with the shortest distance. The present application has small calculation amount, and part of the calculation can be calculated in the "model making" process, without the need for calculation every time. The efficiency of profile measurement can be effectively improved.
[0039] Other features and advantages of the present application will be set forth in the following description, and in part will be apparent from the description, or can be learned by practice of the application. The objects and other advantages of the present application will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings. BRIEF DESCRIPTION OF DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments of the present application. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.
[0041] Figure 1 A flow chart of a workpiece profile measurement method provided by the embodiments of the present application;
[0042] Figure 2 A workpiece profile measurement schematic diagram provided by the embodiments of the present application.
[0043] Figure 3 A structural schematic diagram of a workpiece profile measurement system provided by the embodiments of the present application. DETAILED DESCRIPTION
[0044] The technical solutions in the embodiments of the present application will be described clearly and completely in the following with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. The components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of the present application.
[0045] It should be noted that similar reference numbers and letters in the following drawings represent similar items, and therefore, once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. Meanwhile, in the description of the present application, the terms “first”, “second”, etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.
[0046] Reference will be made to Figure 1A flowchart of a workpiece profile measurement method in some embodiments of the present application. The blockchain-based bidding business quality map analysis method is used in terminal equipment such as computers, mobile phones, and the like. The workpiece profile measurement method comprises the following steps:
[0047] S101: Obtain a reference profile from a reference image of a reference workpiece, and perform tree building based on FLANN according to the reference profile;
[0048] S102: Correct the position of the to-be-measured image, so that the angle direction of the to-be-measured workpiece is consistent with the direction of the reference workpiece in the reference image;
[0049] S103: Extract the profile of the to-be-measured workpiece to obtain a to-be-measured profile point;
[0050] S104: Traverse the to-be-measured profile point, select the N closest points on the reference profile to the to-be-measured profile point, respectively calculate the distance between the to-be-measured profile point and the selected N points, and determine the profile value of the to-be-measured profile point according to the distance;
[0051] S105: Take the dot product of the normal vector at the point on the to-be-measured profile and the normal vector at the point on the reference profile with a distance that meets a preset value as the profile angle.
[0052] Please refer to Figure 2 As a specific embodiment, the present application first obtains a "reference profile" from a reference image, as shown in Figure 2 The dark points in Figure 2 are the "reference profile"; then tree building is performed based on the obtained reference profile points according to FLANN, which can greatly reduce the process of finding the N closest points thereafter. Then, each time the motion is performed, the to-be-measured image is first corrected in position, so that the angle direction of the to-be-measured workpiece is consistent with that of the workpiece in the reference image, and then profile extraction is performed to obtain a "to-be-measured profile", the to-be-measured profile point is as shown in Figure 2 The light-colored point 2 in Figure 2 is the to-be-measured profile point. Then, the to-be-measured profile point is traversed, the N closest points to the to-be-measured profile point are selected, the shortest Euclidean distance result is selected from the N points as the profile value of the point, and the dot product of the normal vector at the point on the to-be-measured profile and the normal vector at the point on the reference profile with the shortest distance is taken as the profile angle.
[0053] According to the embodiment of the present application, the reference profile is obtained by a Sobel algorithm or a Canny algorithm.
[0054] According to the embodiment of the present application, the profile extraction of the to-be-measured workpiece is specifically using a Sobel algorithm or a Canny algorithm to extract the profile of the to-be-measured workpiece.
[0055] According to an embodiment of the present invention, the step of constructing a tree based on the reference contour using FLANN specifically includes:
[0056] A kd-tree is built based on the magnitude of the horizontal and vertical coordinates of the reference contour points. That is, a map is divided into rectangular blocks using all the reference contour points. When searching for nearby points, the contour point corresponding to the rectangular block in which the test point falls is determined to be the closest.
[0057] It should be noted that after dividing an image into rectangular blocks using all reference contour points, these rectangular blocks are considered "hyperplanes". In geometry, a hyperplane is a one-dimensional subspace smaller than its surrounding space.
[0058] It should be noted that in computer science, a kd-tree (short for k-dimensional tree) is a data structure that organizes points in k-dimensional Euclidean space. kd-trees can be used in various applications, such as multidimensional key-value searches (e.g., range searches and nearest neighbor searches). A kd-tree is a special case of binary space partitioning.
[0059] According to an embodiment of the present invention, the position correction of the image to be tested specifically includes:
[0060] The angle θ between the image to be tested and the reference image is obtained based on the similarity of contour points (or graphic similarity). Then, the image to be tested is rotated in the opposite direction by θ so that the angular direction of the workpiece to be tested is consistent with the direction of the reference workpiece in the reference image.
[0061] According to an embodiment of the present invention, the step of using the dot product of the normal vector at a point on the profile to be measured and the normal vector at a point on a reference profile whose distance meets a preset value as the profile angle specifically includes:
[0062] Traverse the contour points to be measured. Let P be the current contour point being traversed. Find the n points in the reference contour that are closest to P, and denote them as N0, N1, ..., N. n-1 Where n∈Z;
[0063] Calculate N0, N1, ..., N respectively. n-1 The Euclidean distances to point P are calculated and sorted. Sort is necessary because when finding the nearest n points, FLAUTION is used for quick lookup, which finds the n points closest in Manhattan distance. The point with the smallest Euclidean distance is denoted as N. min And N min The Euclidean distance to point P is d min If d min If the value is not 0, record the reference profile at N. min The normal vector at point V is min Then the profile angle θ is Vmin With The angle between the vectors, according to the positive or negative of the cosine value of the angle, determines whether the defect is a depression or a protrusion:
[0064]
[0065] According to the embodiment of the present application, the profile points to be measured are traversed, N closest points on the reference profile to the profile points to be measured are selected, the distances between the profile points to be measured and the selected N points are calculated respectively, and the profile values of the profile points to be measured are determined according to the distances; specifically including:
[0066] The non-zero values of the continuous cosine values obtained in the traversal process and having the same sign are taken as a defect segment, and the maximum value of d at each profile point in the segment is taken as the profile value of the defect segment; min
[0067] The absolute values of the profile values of each defect segment in the workpiece to be measured are summed to obtain the profile value of the workpiece to be measured.
[0068] Compared with the traditional workpiece profile measurement method, the traditional method often traverses the "reference profile" and finds suitable "profile points to be measured" in the "reference profile"; and the workpiece profile measurement method described in the present application traverses the "profile to be measured" and finds suitable "reference profile points" in the "profile to be measured".
[0069] In addition, the FLANN algorithm is used in the present application to improve the efficiency of point finding. In general, assuming that the number of "reference profiles" is m and the number of "profiles to be measured" is n, then the time complexity of the algorithm of the prior art is O(m*n), and the time complexity of the method described in the present application is O(n*log(m)). The speed of the algorithm can be obviously optimized.
[0070] As Figure 3 shown, the present application also discloses a workpiece profile measurement system, which comprises a memory 31 and a processor 32, the memory comprising a workpiece profile measurement method program, and the workpiece profile measurement method program is executed by the processor to realize the following steps:
[0071] Obtaining a reference profile from a reference image of a reference workpiece, and building a tree based on the reference profile based on FLANN;
[0072] Position correction is performed on the test image, so that the angle direction of the workpiece to be measured is consistent with the direction of the reference workpiece in the reference image;
[0073] Profile extraction is performed on the workpiece to be measured to obtain profile points to be measured;
[0074] Traverse the profile points to be measured, select N points on the reference profile closest to the profile points to be measured, respectively calculate the distances between the profile points to be measured and the selected N points, and determine the profile degree value of the profile points to be measured according to the distances.
[0075] The dot product of the normal vector at the point on the profile to be measured and the normal vector at the point on the reference profile with a distance complying with a preset value is taken as the profile degree angle.
[0076] According to the embodiment of the present application, the reference profile is obtained by a Sobel algorithm or a Canny algorithm.
[0077] According to the embodiment of the present application, the reference profile is built based on the FLANN according to the reference profile, and specifically:
[0078] A k-d tree is established according to the sizes of the horizontal coordinates and the vertical coordinates of the reference profile coordinate points, that is, a picture is divided into a plurality of rectangular blocks "superplanes" by using all the reference profile points, and when searching for the nearest point, the profile point corresponding to the "superplane" on which the profile point to be measured falls is determined to be the nearest to the profile point to be measured.
[0079] According to the embodiment of the present application, the position of the image to be measured is corrected, and specifically:
[0080] According to the profile point similarity, the angle θ between the image to be measured and the reference image is obtained, and then the image to be measured is reversely rotated by θ, so that the angle direction of the workpiece to be measured is consistent with the direction of the reference workpiece in the reference image.
[0081] According to the embodiment of the present application, the dot product of the normal vector at the point on the profile to be measured and the normal vector at the point on the reference profile with a distance complying with a preset value is taken as the profile degree angle, and specifically includes:
[0082] Traverse the profile points to be measured, let the currently traversed profile point to be measured be P, find n points in the reference profile closest to the point P, and respectively mark them as N0, N1, …, Nn. n-1 ; wherein n is an integer;
[0083] Respectively calculate the Euclidean distances of N0, N1, …, Nn to the point P and sort them, because when finding the n nearest points, the FLAAN fast search is used, and the n points with the smallest Manhattan distances are found, the point with the smallest Euclidean distance is marked as N n-1 , the Euclidean distance of N min to the point P is d min , if d min is not 0, the normal vector of the reference profile at N min is marked as V min , and the profile degree angle θ is V min . min The angle between the vectors, according to the cosine value of the angle, determines whether the defect is a depression or a protrusion:
[0084]
[0085] According to the embodiment of the present application, the contour point to be measured is traversed, N points closest to the contour point to be measured are selected on the reference contour, the distance between the contour point to be measured and the selected N points is calculated respectively, and the profile value of the contour point to be measured is determined according to the distance; specifically comprising:
[0086] The non-zero value of the continuous cosine value obtained in the traversal process and having the same sign is taken as a defect segment, and the maximum value of d in each contour point in the segment is taken as the profile value of the defect segment. min
[0087] The absolute values of the profile values of each defect segment in the workpiece to be measured are summed to obtain the profile value of the workpiece to be measured.
[0088] The third aspect of the present application provides a computer readable storage medium, the computer readable storage medium comprises a workpiece profile measurement method program, when the workpiece profile measurement method program is executed by a processor, the steps of the workpiece profile measurement method according to any one of the above are realized.
[0089] The present application discloses a workpiece profile measurement method, system and medium. First, all the "reference contours" are built (FLANN), then the "contour to be measured" is traversed, N points closest to the points on the "contour to be measured" are selected (Manhattan distance), the shortest Euclidean distance result is selected from the N points as the profile value of the point, and the direction is determined by the dot product result of the normal vector at the point on the "contour to be measured" and the normal vector at the point on the "reference contour" with the shortest distance. The present application has small calculation amount, and part of the calculation can be calculated in the "model making" process, without the need for calculation every time. The efficiency of profile measurement can be effectively improved.
[0090] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed components can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or other forms.
[0091] The units described as separate components above can or can not be physically separate, and the components shown as units can or can not be physical units; they can be located in one place or distributed on multiple network units; and part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0092] In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
[0093] Those of ordinary skill in the art can understand that all or part of the steps of the above method embodiments can be completed by program instruction-related hardware, and the foregoing program can be stored in a readable storage medium, and when the program is executed, the steps of the method embodiments are executed; and the foregoing storage medium includes mobile storage devices, read-only memories (ROMs), random access memories (RAMs), magnetic discs or optical discs, and various media that can store program codes.
[0094] Alternatively, the integrated units of the present application, if implemented in the form of software functional modules and sold or used as independent products, can also be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present application can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the embodiments of the present application. The foregoing storage medium includes mobile storage devices, ROMs, RAMs, magnetic discs or optical discs, and various media that can store program codes.
Claims
1. A method for measuring the contour of a workpiece, characterized in that, The method includes the following steps: Obtain the datum profile from the datum image of the datum workpiece, and construct a tree based on the datum profile using FLANN; Position correction is performed on the image to be measured so that the angle and direction of the workpiece to be measured are consistent with the direction of the reference workpiece in the reference image; The contour of the workpiece to be measured is extracted to obtain the contour points to be measured; Traverse the contour points to be measured, select N points on the reference contour that are closest to the contour points to be measured, calculate the distance between the contour points to be measured and the selected N points respectively, and determine the contour value of the contour points to be measured based on the distances. The profile angle is defined as the dot product of the normal vector at a point on the profile to be measured and the normal vector at a point on the reference profile whose distance meets the preset value. The step of using the dot product of the normal vector at a point on the profile to be measured and the normal vector at a point on a reference profile at a distance that meets a preset value as the profile angle specifically includes: Traverse the contour points to be measured. Let P be the current contour point being traversed. Find the n points in the reference contour that are closest to P, and denote them as N0, N1, ..., N. n-1 Where n∈Z; Calculate N0, N1, ..., N respectively. n-1 The Euclidean distances to point P are calculated and sorted. Sort is used because when finding the nearest n points, a FLANN quick search is used, which finds the n points closest in Manhattan distance. The point with the smallest Euclidean distance is denoted as N. min And N min The Euclidean distance to point P is d min If d min If the value is not 0, record the reference profile at N. min The normal vector at point V is min Then the profile angle θ is V min and The angle between the vectors is used to determine whether the defect is concave or convex. The process involves traversing the contour points to be measured, selecting N points on the reference contour that are closest to the contour points to be measured, calculating the distance between the contour points to be measured and the selected N points, and determining the contour degree value of the contour points to be measured based on the distances; specifically, this includes: Traverse the contour points to be tested, and take consecutive non-zero cosine values with the same sign obtained during the traversal as a defect segment, and find the d value at each contour point within the segment. min The maximum value in the range is taken as the contour value of the defect segment; The absolute values of the profile of each defect segment in the workpiece under test are summed to obtain the profile value of the workpiece under test.
2. The workpiece contour measurement method according to claim 1, characterized in that, The baseline profile is obtained using the Sobel algorithm or the Canny algorithm.
3. The workpiece contour measurement method according to claim 2, characterized in that, The process of building a tree based on the baseline contour using FLANN specifically involves: A kd-tree is built based on the magnitude of the horizontal and vertical coordinates of the reference contour points. That is, a map is divided into rectangular blocks using all the reference contour points. When searching for nearby points, the contour point corresponding to the rectangular block in which the test point falls is determined to be the closest.
4. The workpiece contour measurement method according to claim 3, characterized in that, The position correction of the image to be tested is specifically as follows: The angle θ between the image to be tested and the reference image is obtained based on the similarity of the contour points. Then, the image to be tested is rotated in the opposite direction by θ so that the angular direction of the workpiece to be tested is consistent with the direction of the reference workpiece in the reference image.
5. A workpiece contour measurement system, characterized in that, The system includes a memory and a processor. The memory contains a program for a workpiece contour measurement method. When the program for the workpiece contour measurement method is executed by the processor, it performs the following steps: Obtain the datum profile from the datum image of the datum workpiece, and construct a tree based on the datum profile using FLANN; Position correction is performed on the image to be measured so that the angle and direction of the workpiece to be measured are consistent with the direction of the reference workpiece in the reference image; The contour of the workpiece to be measured is extracted to obtain the contour points to be measured; Traverse the contour points to be measured, select N points on the reference contour that are closest to the contour points to be measured, calculate the distance between the contour points to be measured and the selected N points respectively, and determine the contour value of the contour points to be measured based on the distances. The profile angle is defined as the dot product of the normal vector at a point on the profile to be measured and the normal vector at a point on the reference profile whose distance meets the preset value. The step of using the dot product of the normal vector at a point on the profile to be measured and the normal vector at a point on a reference profile at a distance that meets a preset value as the profile angle specifically includes: Traverse the contour points to be measured. Let P be the current contour point being traversed. Find the n points in the reference contour that are closest to P, and denote them as N0, N1, ..., N. n-1 Where n∈Z; Calculate N0, N1, ..., N respectively. n-1 The Euclidean distances to point P are calculated and sorted. Sort is used because when finding the nearest n points, a FLANN quick search is used, which finds the n points closest in Manhattan distance. The point with the smallest Euclidean distance is denoted as N. min And N min The Euclidean distance to point P is d min If d min If the value is not 0, record the reference profile at N. min The normal vector at point V is min Then the profile angle θ is V min and The angle between the vectors is used to determine whether the defect is concave or convex. The process involves traversing the contour points to be measured, selecting N points on the reference contour that are closest to the contour points to be measured, calculating the distance between the contour points to be measured and the selected N points, and determining the contour degree value of the contour points to be measured based on the distances; specifically, this includes: Traverse the contour points to be tested, and take consecutive non-zero cosine values with the same sign obtained during the traversal as a defect segment, and find the d value at each contour point within the segment. min The maximum value in the range is taken as the contour value of the defect segment; The absolute values of the profile of each defect segment in the workpiece under test are summed to obtain the profile value of the workpiece under test.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a workpiece contour measurement method program, which, when executed by a processor, implements the steps of the workpiece contour measurement method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Method and system for visual measurement of profile of machine part
CN105509653A
Point-cloud-model-based precise detection method and system for surface profile
CN106248035A