A visual inspection method for part contours based on local tracking path planning
By combining the A-GSAA algorithm with adaptive crossover probability and mutation probability for local tracking path planning, the efficiency and accuracy problems in the measurement of complex sheet-like parts are solved, and efficient and high-precision part contour measurement is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-08
- Publication Date
- 2026-04-03
AI Technical Summary
Traditional contact measurement methods have large errors and low efficiency when measuring complex sheet-like parts. Simple single-imaging methods and local tracking methods cannot balance measurement efficiency and accuracy. The path planning problem of local tracking methods has not been effectively solved.
A visual detection method based on local tracking path planning is adopted. The path planning is performed by the A-GSAA algorithm, combined with adaptive crossover probability and mutation probability. The global optimization performance of GA and the local optimization performance of SA are utilized, and image processing technology is combined to perform path planning and local image capture point adjustment.
It improves the accuracy and efficiency of measurement path planning, avoids missed or repeated measurements in local tracking measurements, simplifies the path planning process, and achieves efficient and high-precision part contour measurement.
Smart Images

Figure CN115170517B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of visual measurement of sheet-like parts, and specifically relates to a visual detection method for part contours based on local tracking path planning. Background Technology
[0002] Complex sheet-like parts have wide applications in precision instruments, mechanical watchmaking, and optoelectronic industries. However, because sheet-like parts are typically thin, they are prone to bending deformation under contact forces. Therefore, traditional contact measurement methods will produce large measurement errors and are inefficient.
[0003] Machine vision uses machines to replace human eyes for measurement and judgment. It combines image processing, pattern recognition, and artificial intelligence to acquire measurement information, significantly improving efficiency compared to manual measurement and judgment. Because it uses non-contact measurement, it avoids secondary damage to the object being measured. For measuring the contour parameters of complex sheet-like parts, the main visual measurement methods used include:
[0004] 1. Single-frame imaging method: This method uses a low-magnification, wide-field-of-view lens to completely image the object being measured within the camera's field of view, acquiring a single frame of image. The required measurement parameters are then obtained through image processing techniques. This method is highly efficient, but its accuracy is limited by the camera and lens parameters. For high-precision measurements, high-resolution cameras and wide-field-of-view lenses are often required, resulting in higher measurement costs.
[0005] 2. Local Tracking Method: This method uses a high-magnification, small-field-of-view lens to acquire images in real time and perform image analysis. Algorithms are used to determine the contour change trend to predict the next shooting point, until the entire image of the object under test is captured. This measurement method has high accuracy, but relying solely on algorithms to predict the measurement path makes it prone to local omissions or repeated measurements, resulting in low robustness of the measurement system.
[0006] As can be seen from the above methods, neither the single-imaging method nor the local tracking method can fully balance measurement efficiency and measurement accuracy, and the path planning problem of the local tracking method has not been adequately solved. Summary of the Invention
[0007] The purpose of this invention is to provide a visual inspection method for part contours based on local tracking path planning;
[0008] The specific steps of this part contour visual inspection method based on local tracking path planning are as follows:
[0009] Step 1: Establish the measurement coordinate system required for visual measurement.
[0010] Step 2: Obtain the coarse measurement profile. The probe device uses a lens capable of capturing a panoramic image of the part being measured; the obtained image is used for profile acquisition to obtain the coarse measurement panoramic profile. The bounding rectangle of the coarse measurement panoramic profile in the image is taken as the detection area.
[0011] Step 3: Preprocessing for intersection paths in the flat tiling method.
[0012] 3-1. Lay out n tiles in the detection area. w ·n h One nominal field of view; n w and n h These represent the number of columns and rows of the nominal field of view, respectively. The width and height of the nominal field of view are smaller than the width and height of the field of view when the probe device captures a partial image of the part being measured.
[0013] 3-2. Contour intersection: retain the nominal fields of view that intersect with the coarsely measured panoramic contour as intersecting fields of view, and delete the remaining nominal fields of view.
[0014] 3-3. Select the intersecting fields of view where the contour is at the edge as the adjusted fields of view. Based on the relative position of the adjusted fields of view and the contour, form a new intersecting field of view and then delete the adjusted fields of view.
[0015] 3-4. The position of the center of each intersecting field of view in the machine coordinate system is taken as the local image capture point P. i (x i ,y i ), i = 1, 2, 3, ..., n, where n is the number of local image capture points.
[0016] Step 4: Perform local measurement path planning using the A-GSAA algorithm.
[0017] 4-1. The fitness function maxF(D) is established as follows:
[0018]
[0019] In the formula, C is a preset constant; Let be the measured distance corresponding to the objective function of the j-th individual in the g-th generation.
[0020] 4-2. Initialize the number of iterations g = 1 and the population size N. pop Maximum number of iterations G.
[0021] 4-3. Randomly generate the first generation population
[0022] 4-4. Calculate population D based on the fitness function. g Inner individual fitness At each fitness The minimum value is taken as the optimal fitness of the population in the g-th generation. The individual corresponding to this fitness level is the optimal individual.
[0023] 4-5. If the fitness of the best individuals obtained after a preset number of iterations is equal, then a local optimum is considered to have occurred, and the SA algorithm is executed to obtain the measurement path D. SA If the measurement path D SA The total distance is less than the current optimal individual The corresponding total distance is then measured using path D. SA Replace the current best individual.
[0024] 4-6. Regarding population D g A selection operation is performed on all individuals, retaining a number of individuals with better fitness, thus creating a population.
[0025] 4-7. Generate random numbers RNG c =rand(0,1), if RNG c Less than or equal to the adaptive crossover probability P c Then for population O g A crossover operation is performed between two adjacent individuals to produce individuals.
[0026] 4-8. Generate random numbers RNG m =rand(0,1), if RNG m Less than or equal to the adaptive mutation probability P m Then for population O g Perform mutation operations on individuals to produce individuals
[0027] 4-9. Generate the next generation population D g+1 =M g The iteration number g is increased by 1; steps 4-4 to 4-8 are repeated until the iteration termination condition is met, and the path corresponding to the final optimal individual is taken as the optimal measurement path.
[0028] Step 5: The probe device performs local tracking measurement according to the optimal measurement path to obtain n local images; the n local images are stitched together using overlapping parts to extract the contour and obtain the fine measurement contour.
[0029] Preferably, in step 3-3, the process of forming a new intersecting field of view based on the relative position of the adjusted field of view and the contour is as follows:
[0030] S1. Define the outermost contour of the coarsely measured panoramic contour as the outer contour; define the contour contained within the outer contour as the inner contour. Determine the size of the intersection region between each intersecting field of view and the contour: For intersecting fields of view intersecting with the outer contour, use the number of pixels inside the outer contour to the total number of pixels in the intersecting field of view as the intersection ratio. For intersecting fields of view intersecting with the inner contour, use the number of pixels inside the inner contour to the total number of pixels in the intersecting field of view as the intersection ratio. Intersecting fields of view with an intersection ratio less than 1 / 4 or greater than 3 / 4 are considered to have an excessively small intersection region. Fields of view with excessively small intersection regions are designated as the fields of view to be adjusted.
[0031] S2. Determine the translation direction of each adjusted field of view and complete the translation operation:
[0032] If the adjusted field of view has a contour in the upper left 1 / 4 region, then the field of view obtained by translating the adjusted field of view in the u direction by -a / 4 and in the v direction by -b / 4 is taken as a new intersecting field of view. a is the width of the nominal field of view; b is the height of the nominal field of view.
[0033] If the adjusted field of view has an outline in the lower left 1 / 4 region, then the field of view obtained by translating the adjusted field of view in the u direction by -a / 4 and in the v direction by b / 4 is taken as a new intersecting field of view.
[0034] If the adjusted field of view has an outline in the upper right 1 / 4 region, then the field of view obtained by translating the adjusted field of view a / 4 in the u direction and -b / 4 in the v direction is taken as a new intersecting field of view.
[0035] If the adjusted field of view has an outline in the lower right 1 / 4 region, then the field of view obtained by translating the adjusted field of view a / 4 in the u direction and b / 4 in the v direction is taken as a new intersecting field of view.
[0036] Afterwards, each adjusted field of view will be deleted.
[0037] S3. Repeat steps S1 and S2 until the number of adjusted fields of view selected in step S1 is zero.
[0038] Preferably, step S1 determines the relative positions of pixels within the nominal field of view with respect to the outer and inner contours by marking gray values; the marking process is as follows: the regions outside the outer contour, the regions inside the outer contour and outside each inner contour, and the regions inside each inner contour are set to different gray values.
[0039] As a preferred embodiment, the SA algorithm described in steps 4-5 is as follows:
[0040] S1. Construct the objective function f(D) as follows:
[0041]
[0042] S2. Set the initial temperature T0 and the ending temperature T end Annealing coefficient δ and Markov chain length L.
[0043] S3. Randomly generate the initial solution D′0=(D1,D2,D3,…,D…) for the SA algorithm. n ).
[0044] S4. Randomly generate a new solution to the SA algorithm: N = (N1, N2, N3, ..., N n ).
[0045] S5. Calculate the initial objective function value f(D′0) and the new objective function value f(N).
[0046] S6. Determine the outcome using the Metropolis criterion, with probability P. k Accept the new solution with probability P k Specifically as follows:
[0047]
[0048] In the formula, T is the current temperature.
[0049] If f(D′0)-f(N)>0, then D′0=N; if f(D′0)-f(N)≤0, generate random numbers RNG=rand(0,1) with probability P. k =exp((f(D′0)-f(N)) / T) accepts a new solution.
[0050] S7. Cool the system down, multiply the current temperature T by the annealing coefficient δ to get the new current temperature T, and repeat steps S4, S5, S6, and S7 until T < T end The updated solution D′0 is used as the output path of the SA algorithm.
[0051] As a preferred option, in steps 4-7, the individual The expression is as follows:
[0052]
[0053] As a preferred option, in steps 4-8, the individual The expression is as follows:
[0054]
[0055] Preferably, the width and height of the nominal field of view are less than or equal to half of the width and height of the field of view when the probe device performs local image acquisition.
[0056] Preferably, the adaptive crossover probability P mentioned in steps 4-7 c The expression is as follows:
[0057] P c =exp(-(2 / G)×g)
[0058] Preferably, the adaptive mutation probability P mentioned in steps 4-8 m The expression is as follows:
[0059] P m = 1 / 10 × exp(-(2 / G) × g)
[0060] Preferably, the part being tested is in the form of a sheet.
[0061] The beneficial effects of this invention are:
[0062] 1. This invention employs A-GSAA to perform measurement path planning on local image capture points extracted through tiled intersection. It utilizes adaptive crossover and mutation probabilities, maintaining high crossover and mutation probabilities in the early iterations to promote the generation of new individuals, and reducing these probabilities in the later iterations to prevent the destruction of good individuals, thus improving the accuracy of path planning. Furthermore, this invention fully leverages the global optimization performance of GA and the local optimization performance of SA. When GA gets stuck in a local optimum, SA performs a local search to replace the best individual in GA, escaping the local optimum and enabling the algorithm to find the global optimum more quickly, thereby improving the algorithm's optimization performance.
[0063] 2. This invention utilizes image processing technology to extract local image capture points required for local tracking measurement from the coarse panoramic contour through a tiling intersection method. It also adjusts the positions of local image capture points located at the edge of the field of view, thereby providing path guidance for local tracking measurement, simplifying the path planning process, and making it simple to operate and easy to implement.
[0064] 3. This invention uses the coarse panoramic contour of the thin sheet part to be measured obtained by one imaging as the path guide for local tracking measurement, which solves the problem of tracking failure or partial contour omission in the existing local tracking measurement methods. Attached Figure Description
[0065] Figure 1 This is a flowchart of the present invention.
[0066] Figure 2 This is a schematic diagram of the tiling and unfolding process in the tiling intersection path preprocessing step of the present invention.
[0067] Figure 3 This is a schematic diagram of contour intersection in the preprocessing step of the tiling intersection path in this invention.
[0068] Figure 4This is the intention of adjusting the edge field of view in the preprocessing step of the tiling intersection path in this invention.
[0069] Figure 5 This is a schematic diagram of the edge field of view adjustment process in the preprocessing step of the tiling intersection path in this invention.
[0070] Figure 6 This is a flowchart of the A-GSAA algorithm provided in step five of this invention.
[0071] Figure 7 This is a high-magnification image acquisition path diagram for thin-plate gears according to the present invention.
[0072] Figure 8 This is a comparison of the convergence curves of the path planning optimization algorithm A-GSAA and the GA algorithm provided in step five of this invention. Detailed Implementation
[0073] The invention will be further described below with reference to the accompanying drawings, taking the measurement of thin-plate gears as an example.
[0074] A visual inspection method for part contours based on local tracking path planning is disclosed. The probe device used can automatically switch between lenses of different magnifications. In this embodiment, the probe device is the image measurement probe device disclosed in any claim of patent application No. 2022104583422, entitled "An Image Measurement Probe Device and Measurement Method Based on Multi-Lens Integration." When using a low-magnification lens, the probe device can acquire the complete contour of the part being measured; when using a high-magnification lens, it can accurately acquire the local contour of the part being measured. In this embodiment, the part being measured is a thin-plate gear.
[0075] like Figure 1 As shown, this visual detection method for part contours based on local tracking path planning specifically includes the following steps:
[0076] Step 1: Establish the measurement coordinate system required for visual measurement, including: machine coordinate system O M X M Y M Z M World coordinate system O w X w Y w Z w and camera coordinate system O c X c Y c Z c And complete the coordinate unification.
[0077] Step 2: Obtain the coarse measurement profile. Control the probe device to switch the working lens to a low-magnification lens, ensuring the measured thin gear is fully imaged within the camera's field of view. Acquire one frame of image and extract the coarse measurement panoramic profile using digital image processing technology. Establish the pixel coordinate system `ouv` with the top-left vertex of the coarse measurement panoramic profile image as the origin of the pixel coordinate system, the horizontal side of the image as the u-axis, and the vertical side as the v-axis. Through connected component analysis, extract the width (W) and height (H) of the minimum bounding rectangle of the measured thin gear profile, and the coordinates of the top-left vertex of the minimum bounding rectangle in the image pixel coordinate system as the part position coordinates (u, u). ltop ,v ltop ).
[0078] Step 3: Preprocessing for intersection paths in the flat tiling method.
[0079] 3-1. For example Figure 2 As shown, when the image is tiled, the nominal field of view n is tiled in both the horizontal and vertical directions. w n h The calculation formula is as follows:
[0080]
[0081] In the formula, W and H represent the width and height of the minimum bounding rectangle of the measured thin-plate gear profile, respectively; a and b represent the nominal field width and height, respectively; c1 = W mod a, c2 = H mod b. mod is the modulo operator.
[0082] The nominal field of view is tiled from left to right and from top to bottom on the contour image extracted by coarse measurement, and the extracted part position coordinates (u) are analyzed using connected component analysis. ltop ,v ltop The top-left vertex of the first tiling nominal field of view is used as the tiling area, with the region encompassed by the smallest bounding rectangle of the thin-plate gear profile as the tiling region. The tiling result is as follows: Figure 2 As shown, the width and height of the nominal field of view are smaller than those of the field of view when the probe is equipped with a high-powered lens.
[0083] 3-2. Nominal field of view numbering: The nominal field of view after being unfolded is numbered from left to right and from top to bottom, and is sequentially labeled as C. ij (i = 1, 2, 3, ..., n) h j = 1, 2, 3, ..., n w ), where i is the row index and j is the column index. h n is the nominal field of view row number within the tiling area. w This represents the nominal field of view column number within the tiling area.
[0084] 3-3. For example Figure 3As shown, the contours are intersected. If each of the tiled nominal fields of view intersects with the coarsely measured panoramic contour, then that nominal field of view is retained as the intersecting field of view. Figure 2 C in 12 C 13 C 14 ..., C 107 Etc.; conversely, the nominal field of view is removed, such as... Figure 2 C in 11 C 18 C 101 ..., C 108 The results of contour intersection are as follows: Figure 3 As shown.
[0085] 3-4. For example Figure 4 and 5 As shown, the adjustment of the intersecting fields of view involves adjusting the position of the intersecting fields of view in the direction of increasing the intersection area if the intersection area between each intersecting field of view after tiling and the profile of the thin gear being coarsely measured is too small. Figure 3 C in 12 C 17 C 21 The results of the nominal field-of-view translation at the edge are as follows: Figure 3 As shown.
[0086] 3-5. Mark the coordinates of the center point of the intersecting fields of view, such as... Figure 4 As shown, the coordinates of the center points of each intersecting field of view are sequentially labeled as P from left to right and from top to bottom. i (u i ,v i ), where i = 1, 2, 3, ..., n, P i This refers to the image capture point measured locally in the pixel coordinate system. n is the number of intersecting fields of view formed after adjustment.
[0087] Step 4: Transform the coordinate system, converting the nominal field of view center point P in the pixel coordinate system. i (u i ,v i Transform to the machine coordinate system to obtain the image capture point P of the local tracking measurement in the machine coordinate system. i (x i ,y i ), where i = 1, 2, 3, ..., n.
[0088] Step 5: As Figure 6 As shown, A-GSAA is used for local measurement path planning.
[0089] GA (Global Algorithm) is a swarm intelligence global optimization evolutionary algorithm. Starting with a randomly generated initial population, it simulates the biological evolutionary process through selection, crossover, and mutation operations to generate new populations, exhibiting strong robustness and good global search capabilities. However, GA is highly dependent on the selection of crossover and mutation probabilities and has poor local search capabilities, easily getting trapped in local optima. To improve its performance, this invention establishes a relationship between the current iteration number g and the maximum iteration number G, allowing the crossover and mutation probabilities of GA to adaptively change according to the iteration number. This maintains high crossover and mutation probabilities in the early stages of iteration, promoting the generation of new individuals, while reducing crossover and mutation probabilities in the later stages of iteration to prevent the destruction of good individuals, thus improving the accuracy of GA. Furthermore, it utilizes the local search capabilities of SA (Self-Optimizing Algorithm) to help GA escape local optima, improving the algorithm's optimization ability.
[0090] 5-1. The fitness function maxF(D) is established as shown in the following equation:
[0091]
[0092] In the formula, D is the objective function, and C is a preset constant. Let be the measurement distance represented by the objective function of the j-th individual in the g-th generation.
[0093] 5-2. Initialize relevant parameters: Population size is N pop =200, the maximum number of iterations is G=500.
[0094] 5-3. Randomly generate the initial population in, j = 1, 2, 3, ..., N pop .individual The elements D in ji Image capture point P corresponding to local tracking measurement in the machine coordinate system i (x i ,y i ).
[0095] 5-4. Calculate population D based on the fitness function. g Inner individual fitness At each fitness The minimum value is taken as the optimal fitness of the population in the g-th generation. The individual corresponding to this fitness level is the optimal individual.
[0096] 5-5. If the current iteration number g ≥ 10, determine whether the A-GA algorithm has fallen into a local optimum. A local optimum is defined as the fitness function values of the best individuals being equal for 10 consecutive generations. If a local optimum is found, execute the SA algorithm. If the measurement path D obtained by the SA algorithm... SA The total distance is less than the current iteration number of the optimal individual The corresponding total distance is then used to replace the optimal individual in the current iteration with the path obtained by the SA algorithm.
[0097] 5-6. Regarding population D g A selection operation is performed on all individuals, retaining those with better fitness, thus creating a population.
[0098] 5-7. Generate random numbers RNG c =rand(0,1), if RNG c Less than or equal to the adaptive crossover probability P c For population O g A crossover operation is performed between two adjacent individuals to produce individuals. As shown in equation (3).
[0099]
[0100] 5-8. Generate random numbers RNG m =rand(0,1), if RNG m Less than or equal to the adaptive mutation probability P m For population O g Perform mutation operations on individuals to produce individuals As shown in the formula.
[0101]
[0102] 5-9. Generate the next generation population D g+1 =M g Repeat steps 5-4 to 5-8 until the iteration termination condition is met. In this embodiment, the iteration termination condition is reaching the preset maximum number of iterations.
[0103] Step 6: The probe device performs local tracking measurement based on the optimal measurement path obtained from the path planning determined in Step 5, and obtains n local images; the n local images are stitched together using the overlapping parts to obtain the fine measurement profile.
[0104] As a preferred example, the width and height of the nominal field of view are respectively half of the width and height of the field of view after the probe device is switched to a high-magnification lens.
[0105] As a preferred example, the nominal field of view preservation and removal method described in step 3-3 is implemented using a grayscale-based discrimination method. Since the coarse-measured panoramic contour image is a binary image, the grayscale value in the image is represented by 0 or 255, and its mathematical expression is:
[0106]
[0107] As shown in equation (6), let C ij (i,j=1,2,3,…,n) is a nominal field of view region after tiling, and P is the coarse measurement panoramic contour region. Within the nominal field of view region, if there exists an image pixel gray value f(u,v)=0, then the nominal field of view and the coarse measurement panoramic contour are defined to have an intersection; if f(u,v)≡255, then the nominal field of view and the coarse measurement panoramic contour are defined to have no intersection.
[0108]
[0109] As a preferred example, the method for translating the intersection region described in steps 3-4 is as follows:
[0110] S1. Grayscale value labeling: The outermost contour of the coarsely measured panoramic contour is defined as the outer contour, and its internal contained area is denoted as A0. The contour contained within the outer contour is defined as the inner contour, and its internal contained area is denoted as A0. i (i = 1, 2, 3, ..., m). m is the number of inner contours. The pixel gray values of the regions contained within each contour are set to the same gray level, and the pixel gray values within different contours are different, as shown in equation (7).
[0111]
[0112] S2. Determine the size of the intersection region between each intersecting field of view and the contour: For intersecting fields of view intersecting with the outer contour, calculate the intersection ratio by dividing the number of pixels with a gray value not equal to 255 by the total number of pixels in the intersecting field of view. For intersecting fields of view intersecting with the inner contour, calculate the intersection ratio by dividing the number of pixels with a gray value not equal to 0 and not equal to 255 by the total number of pixels in the intersecting field of view. Intersecting fields of view with an intersection ratio less than 1 / 4 or greater than 3 / 4 are considered to have an excessively small intersection region. Fields of view with excessively small intersection regions are selected as the fields of view to be adjusted.
[0113] S3. Determine the translation direction of each adjusted field of view and complete the translation operation:
[0114] If the adjusted field of view has an outline in the upper left 1 / 4 region, then the field of view obtained by translating the adjusted field of view in the u direction by -a / 4 and in the v direction by -b / 4 is taken as a new intersecting field of view.
[0115] If the adjusted field of view has an outline in the lower left 1 / 4 region, then the field of view obtained by translating the adjusted field of view in the u direction by -a / 4 and in the v direction by b / 4 is taken as a new intersecting field of view.
[0116] If the adjusted field of view has an outline in the upper right 1 / 4 region, then the field of view obtained by translating the adjusted field of view a / 4 in the u direction and -b / 4 in the v direction is taken as a new intersecting field of view.
[0117] If the adjusted field of view has an outline in the lower right 1 / 4 region, then the field of view obtained by translating the adjusted field of view a / 4 in the u direction and b / 4 in the v direction is taken as a new intersecting field of view.
[0118] Next, each adjusted field of view is deleted. If multiple corners in an adjusted field of view have outlines, multiple intersecting fields of view will be created.
[0119] S4. Repeat steps S2 and S3 until the number of adjusted fields of view selected in step S2 is zero.
[0120] As a preferred example, the SA algorithm described in step 5-5 is as follows:
[0121] S1. Construct the objective function f(D), as shown in equation (8).
[0122]
[0123] S2. Initialize relevant parameters: initial temperature T0 = 2℃, final temperature T end =1℃, annealing coefficient δ =0.98, Markov chain length L =1000.
[0124] S3. Randomly generate the initial solution D′0=(D1,D2,D3,…,D…) for the SA algorithm. n ).
[0125] S4. Randomly generate a new solution to the SA algorithm: N = (N1, N2, N3, ..., N n ).
[0126] S5. Calculate the initial objective function value f(D′0) and the new objective function value f(N).
[0127] S6. Determine the outcome using the Metropolis criterion, with probability P. k Accept the new solution with probability P k Specifically as follows:
[0128]
[0129] In the formula, T is the current temperature, and its value is determined by the initial temperature, annealing coefficient, and the current number of annealing cycles.
[0130] From the formula, we know that if f(D′0)-f(N)>0, then D′0=N; if f(D′0)-f(N)≤0, generate random numbers RNG=rand(0,1) with probability P. k =exp((f(D′0)-f(N)) / T) accepts a new solution, as shown in equation (10).
[0131]
[0132] S7. Cool the system down, T = T × δ. Repeat steps S4, S5, S6, and S7 until T < T end The solution D′0 at this point is taken as the path output by the SA algorithm.
[0133] As a preferred example, the adaptive crossover probability P described in steps 5-7 c The calculation formula is as follows:
[0134] P c =exp(-(2 / G)×g) (11)
[0135] In the formula, G is the maximum number of iterations, and g is the current number of iterations.
[0136] As a preferred example, the adaptive mutation probability P described in steps 5-8 m The calculation formula is as follows:
[0137] P m =1 / 10×exp(-(2 / G)×g) (12)
[0138] In the formula, G is the maximum number of iterations, and g is the current number of iterations.
[0139] The high-magnification lens imaging path diagram obtained in this embodiment is as follows: Figure 7 As shown. To verify the optimization performance of the A-GSAA algorithm described in this invention, this invention uses the A-GSAA algorithm and the GA algorithm to perform path planning on the local contour shooting points extracted from the thin-plate gear in the embodiment. The comparison diagram of the two algorithms is shown in the figure. Figure 8 As shown in the figure, the A-GSAA algorithm provided by this invention has a significantly faster convergence speed than the GA algorithm and can quickly escape local optima, thus improving the optimization performance and convergence speed of the algorithm.
Claims
1. A visual inspection method for part contours based on local tracking path planning, characterized in that: Includes the following steps: Step 1: Establish the measurement coordinate system required for visual measurement; Step 2: Obtain the coarse measurement profile; the probe device uses a lens capable of capturing a panoramic image of the part being measured; the obtained image is used for profile acquisition to obtain the coarse measurement panoramic profile; the bounding rectangle of the coarse measurement panoramic profile in the image is taken as the detection area. Step 3: Preprocessing of intersection paths for tiling; 3-1. Lay out n tiles in the detection area. w ·n h One nominal field of view; n w and n h These are the number of columns and rows of the nominal field of view, respectively; the width and height of the nominal field of view are smaller than the width and height of the field of view when the probe device captures a partial image of the part being measured. 3-2. Contour intersection: retain the nominal fields of view that intersect with the coarsely measured panoramic contour as the intersecting fields of view, and delete the rest of the nominal fields of view; 3-3. Select the intersecting fields of view with the outline at the edge as the adjusted fields of view; based on the relative position of the adjusted fields of view and the outline, form a new intersecting field of view and then delete the adjusted fields of view; The process of forming a new intersecting field of view based on the relative position of the adjusted field of view and the contour is as follows: S1. Define the outermost contour of the coarsely measured panoramic contour as the outer contour; define the contour contained within the outer contour as the inner contour; determine the size of the intersection area between each intersecting field of view and the contour: for intersecting fields of view that intersect with the outer contour, use the number of pixels inside the outer contour to the total number of pixels in the intersecting field of view as the intersection ratio; for intersecting fields of view that intersect with the inner contour, use the number of pixels inside the inner contour to the total number of pixels in the intersecting field of view as the intersection ratio. Intersecting fields of view with an intersection ratio less than 1 / 4 or greater than 3 / 4 are judged as having an excessively small intersection region; intersecting fields of view with an excessively small intersection region are used as the fields of view to be adjusted. The relative positions of pixels within the nominal field of view to the outer and inner contours are determined by grayscale value marking. The marking process is as follows: different grayscale values are set for the regions outside the outer contour, the regions inside the outer contour and outside each inner contour, and the regions inside each inner contour. S2. Determine the translation direction of each adjusted field of view and complete the translation operation: If the adjusted field of view has an outline in the upper left 1 / 4 region, then the field of view obtained by translating the adjusted field of view in the u direction by -a / 4 and in the v direction by -b / 4 is taken as a new intersecting field of view; a is the width of the nominal field of view; b is the height of the nominal field of view. If the adjusted field of view has an outline in the lower left 1 / 4 region, then the field of view obtained by translating the adjusted field of view in the u direction by -a / 4 and in the v direction by b / 4 is taken as a new intersecting field of view; If the adjusted field of view has an outline in the upper right 1 / 4 region, then the field of view obtained by translating the adjusted field of view a / 4 in the u direction and -b / 4 in the v direction is taken as a new intersecting field of view; If the adjusted field of view has an outline in the lower right 1 / 4 region, then the field of view obtained by translating the adjusted field of view a / 4 in the u direction and b / 4 in the v direction is taken as a new intersecting field of view. Then, delete each adjusted field of view; S3. Repeat steps S1 and S2 until the number of adjusted fields of view selected in step S1 is zero; 3-4. The position of the center of each intersecting field of view in the machine coordinate system is taken as the local image capture point P. i (x i ,y i ), i = 1, 2, 3, ..., n, where n is the number of local image capture points; Step 4: Perform local measurement path planning using the A-GSAA algorithm; 4-1. The fitness function maxF(D) is established as follows: In the formula, C is a preset constant; Let be the measured distance corresponding to the objective function of the j-th individual in the g-th generation; 4-2. Initialize the number of iterations g = 1 and the population size N. pop Maximum number of iterations G; 4-3. Randomly generate the first generation population 4-4. Calculate population D based on the fitness function. g Inner individual fitness At each fitness The minimum value is taken as the optimal fitness of the population in the g-th generation. The individual corresponding to this fitness level is the optimal individual. 4-5. If the fitness of the best individuals obtained after a preset number of iterations is equal, then a local optimum is considered to have occurred, and the SA algorithm is executed to obtain the measurement path D. SA If the measurement path D SA The total distance is less than the current optimal individual The corresponding total distance is then measured using path D. SA Replace the current best individual; 4-6. Regarding population D g A selection operation is performed on all individuals, retaining a number of individuals with better fitness, thus creating a population. 4-7. Generate random numbers RNG c =rand(0,1), if RNG c Less than or equal to the adaptive crossover probability P c Then for population O g A crossover operation is performed between two adjacent individuals to produce individuals. The adaptive crossover probability P c The expression is as follows: P c =exp(-(2 / G)×g) 4-8. Generate random numbers RNG m =rand(0,1), if RNG m Less than or equal to the adaptive mutation probability P m Then for population O g Perform mutation operations on individuals to produce individuals The adaptive mutation probability P m The expression is as follows: P m =1 / 10×exp(-(2 / G)×g) 4-9. Generate the next generation population D g+1 =M g The iteration number g is increased by 1; steps 4-4 to 4-8 are repeated until the iteration termination condition is met, and the path corresponding to the final optimal individual is taken as the optimal measurement path. Step 5: The probe device performs local tracking measurement according to the optimal measurement path to obtain n local images; the n local images are stitched together using overlapping parts to extract the contour and obtain the precise measurement contour.
2. The method for visual inspection of part contours based on local tracking path planning according to claim 1, characterized in that: The SA algorithm described in steps 4-5 is as follows: S1. Construct the objective function f(D) as follows: S2. Initialize initial temperature T0, ending temperature T end Annealing coefficient δ, Markov chain length L; S3. Randomly generate the initial solution D0′=(D1,D2,D3,…,D n ); S4. Randomly generate a new solution N = (N1, N2, N3, ..., N) for the SA algorithm. n ); S5. Calculate the initial objective function value f(D0′) and the new objective function value f(N); S6. Discriminate using the Metropolis criterion, with probability P. k Accept the new solution with probability P k Specifically as follows: In the formula, T is the current temperature; If f(D0′)-f(N)>0, then D0′=N; if f(D0′)-f(N)≤0, generate random numbers RNG=rand(0,1) with probability P. k =exp((f(D0′)-f(N)) / T) accepts a new solution; S7. Cool the system down, multiply the current temperature T by the annealing coefficient δ to get the new current temperature T, and repeat steps S4, S5, S6, and S7 until T < T end The updated solution D0′ is used as the output path of the SA algorithm.
3. The method for visual inspection of part contours based on local tracking path planning according to claim 1, characterized in that: In steps 4-7, the individual The expression is as follows:
4. The method for visual inspection of part contours based on local tracking path planning according to claim 1, characterized in that: In steps 4-8, the individual The expression is as follows:
5. The method for visual inspection of part contours based on local tracking path planning according to claim 1, characterized in that: The width and height of the nominal field of view are less than or equal to half of the width and height of the field of view when the probe device performs local image acquisition.
6. The part contour visual inspection method based on local tracking path planning according to claim 1, characterized in that: The part being tested is in sheet form.
Citation Information
Patent Citations
Image overlaying-based thin sheet part contour automatic detection head and method
CN102661722A
Spot welding robot operation space smooth path planning method for curved surface workpiece
CN113325799A