A multi-view visual inspection method for mechanical defects

Through the multi-view mechanical defect visual detection method, combined with denoising filtering and Gaussian filtering processing, and using reverse learning and genetic optimization strategies, the problem of difficulty in efficiently and accurately detecting the surface defects of precision instruments in the existing technology is solved, and the comprehensive and accurate detection of the surface of precision instruments is achieved.

CN115937182BActive Publication Date: 2025-04-11WUXI EMWAY IND CONTROL EQUIP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211696524.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-28
Publication Date
2025-04-11
Estimated Expiration
2042-12-28

AI Technical Summary

Technical Problem

In the production process of high-precision industrial equipment, existing manual visual inspections are difficult to efficiently and accurately detect multiple small-scale defects on the surface of precision instruments, and a single-view vision camera cannot fully obtain workpiece surface data, resulting in defects that may be missed.

Method used

The multi-view mechanical defect visual detection method is adopted, and the information intensity and edge clarity of the image defect area are enhanced through the denoising filter function and the convolution difference processing of the multi-scale Gaussian filter template. At the same time, reverse learning strategies and adaptive genetic optimization strategies are used to extract and screen individuals with better performance, enrich population diversity, and improve the accuracy and efficiency of defect extraction.

Benefits of technology

It realizes all-round accurate detection of the surface of precision instruments, improves the efficiency and accuracy of detection, and reduces the possibility of defect missed detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115937182B_ABST
    Figure CN115937182B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of mechanical defect detection, and discloses a multi-view visual detection method for mechanical defects, the method comprising: rotating the shooting angle to obtain a multi-view instrument surface image of an instrument to be detected; preprocessing the obtained multi-view instrument surface image for image denoising and enhancement; extracting defective parts from the preprocessed multi-view instrument surface image based on a defect extraction objective function; extracting index features from sub-images containing defective parts at different viewing angles based on an instrument surface defect feature detection index system, detecting whether there are defects on the surface of the instrument to be detected at different viewing angles, and comprehensively judging whether there are defects on the instrument surface. The present invention weakens image noise based on multiple filtering and enhances the information intensity and edge clarity of the image defect area, and uses an adaptive genetic optimization strategy to quickly solve the defect extraction objective function, thereby realizing defective part extraction and defect detection of instrument surface images at different viewing angles.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of defect detection, and in particular to a multi-viewing angle mechanical defect visual detection method. Background Art

[0002] During the production process of high-precision industrial equipment, surface defects are generated due to the influence of various process factors, which affect the factory quality and normal use. In particular, the surface defects of precision instruments are diverse, small in scale, and unclear in features. Existing manual visual inspections are difficult to achieve efficient and accurate detection requirements. At the same time, due to objective physical conditions, the visual camera used to obtain industrial equipment information cannot obtain the overall surface data of the workpiece with only a single viewing angle. For example, surface defects of the instrument may be missed due to viewing angle light and other reasons. In order to detect defects that may exist in all areas of the workpiece surface, the present invention proposes a multi-view mechanical defect visual detection method to achieve all-round and accurate detection of precision equipment. Summary of the invention

[0003] In view of this, the present invention provides a multi-view visual inspection method for mechanical defects, the purpose of which is to: 1) use a denoising filter function to sequentially perform row filtering and column filtering on the grayscale matrix of the surface image of the inspection instrument to smooth the noise information of the surface image, and realize the weakening of image noise generated by the viewing angle light, etc. in the image, but while weakening the noise, the information intensity of the defective part is also weakened. Therefore, a multi-scale Gaussian filter template convolution difference processing is adopted to perform pixel grayscale fusion based on different scale differential representations and gradient weights on Gaussian filter processed pixels at different scales, so as to enhance the information intensity and edge clarity of the image defect area; 2) in the defective part In the defect extraction process, the reverse learning strategy is used to obtain the reverse individual of the current iterative individual. By comparing the current iterative individual with the reverse individual, the individual with better performance is screened out as the next iterative individual, enriching the diversity of the population. In the defect extraction objective function process, each individual adopts an adaptive iterative strategy to iterate the algorithm. The individuals with better performance use themselves as the base encoding representation to enhance local searchability. The individuals with poor performance use random iterations, so that the individuals can fully search the encoding representation space to speed up exploration. It can not only better balance the diversity of the population to improve the accuracy of the solution, but also speed up convergence to save the search overhead of the algorithm.

[0004] To achieve the above object, the present invention provides a multi-view visual inspection method for mechanical defects, comprising the following steps:

[0005] S1: Rotate the shooting angle to obtain multi-view instrument surface images of the instrument to be tested;

[0006] S2: performing image denoising and enhancement preprocessing on the acquired multi-view instrument surface image to obtain a preprocessed multi-view instrument surface image, wherein intrinsic scale decomposition and fusion is the main implementation method of the image denoising and enhancement processing;

[0007] S3: extracting defective parts from the preprocessed multi-view instrument surface image based on the defect extraction objective function to obtain sub-images containing defective parts at different viewing angles, wherein the adaptive genetic optimization strategy is the main implementation strategy for the defect extraction of the instrument surface image;

[0008] S4: constructing an instrument surface defect feature detection index system, wherein the index system includes shape features and texture features;

[0009] S5: Based on the instrument surface defect feature detection index system, the index features of the sub-images containing defective parts at different viewing angles are extracted to detect whether there are defects on the surface of the instrument to be inspected at different viewing angles, and based on the defect detection results at different viewing angles, a comprehensive judgment is made as to whether there are defects on the surface of the instrument.

[0010] As a further improvement method of the present invention:

[0011] Optionally, the step S1 of acquiring a multi-view instrument surface image of the instrument to be detected includes:

[0012] Use a camera to capture the surface image of the instrument to be inspected for defects. After each capture, rotate the camera clockwise to obtain the surface image of the instrument to be inspected at different viewing angles. in Indicates rotating the camera device clockwise After the degree, we get The instrument surface image of the instrument to be detected under different viewing angles is taken as the multi-viewing angle instrument surface image of the instrument to be detected.

[0013] Optionally, the preprocessing of image denoising and enhancement on the acquired multi-view instrument surface image in step S2 includes:

[0014] According to the acquired multi-view instrument surface images, the intrinsic scale decomposition and fusion method is used to pre-process the instrument surface images of the instrument to be detected at different viewpoints by decomposing and fusion of image features at different scales, and the denoised and enhanced instrument surface images are obtained. The process of the intrinsic scale decomposition and fusion method is as follows:

[0015] S21: For any The instrument surface image of the instrument to be detected under the viewing angle is subjected to image grayscale processing to obtain a grayscale matrix Q of the instrument surface image. The size of the grayscale matrix is ​​M×N, where M represents the number of row pixels in the instrument surface image, and N represents the number of column pixels in the instrument surface image. The element coordinates in the grayscale matrix are the pixel coordinates of the corresponding pixels in the instrument surface image, and the element value is the grayscale value of the corresponding pixel. In the embodiment of the present invention, the grayscale value of a pixel is the maximum value of the pixel in the RGB color component.

[0016] S22: Use the denoising filter function to perform row filtering and column filtering on the grayscale matrix Q in sequence to obtain the grayscale filtering result of any element in the grayscale matrix:

[0017] Q′(x,y)=q(x,y)[1-α 2 / (Q(x,y)) 2 ],x∈[1,M],y∈[1,N]

[0018]

[0019]

[0020]

[0021]

[0022] in:

[0023] e represents a natural constant;

[0024] ω(·) represents the denoising filter function;

[0025] Q(x,y) represents the element value of the element in the xth row and yth column of the gray matrix Q, q(x,y) represents the filter coefficient of the element in the xth row and yth column of the gray matrix Q, and Q′(x,y) represents the gray filtering result of the element in the xth row and yth column of the gray matrix Q, where the filtering result is the processing result after the noise is weakened;

[0026] a represents the filtering scale, max a∈[1,5] {q a (x,y)} represents the maximum value of the grayscale filtering result of the element in the xth row and yth column of the grayscale matrix Q at the scale a∈[1,5];

[0027] σ σ Represents the standard deviation of the element values ​​in the gray matrix Q;

[0028] α represents the preset filtering threshold;

[0029] And the grayscale filtering results of all elements are constructed as a grayscale filtering matrix Q′;

[0030] S23: construct Gaussian filter templates of different scales σ1, σ2, σ3, where the Gaussian filter template is in the form of a 3×3 matrix, σ1=1, σ2=2, σ3=3;

[0031] In the embodiment of the present invention, the construction process of the Gaussian filter template is as follows:

[0032] Set the initial Gaussian filter template:

[0033]

[0034] in:

[0035] The scale is σ i The element value of the element in the x′th row and y′th column in the initial Gaussian filter template;

[0036] Normalize the element values ​​of each element in the initial Gaussian filter template so that the sum of all elements is 1, and the scale is σ i Gaussian filter template

[0037] S24: Convolve the Gaussian filter templates of different scales with any element of the grayscale filter matrix Q′:

[0038]

[0039] in:

[0040] The scale is σ i Gaussian filter template, Represents the Gaussian filtered template After filtering, the element value of the element in the xth row and yth column;

[0041] The Gaussian filtering of all elements results in the formation of a matrix Q″(σ i );

[0042] S25: Calculate the grayscale filter matrix Q′ and the matrix Q″ (σ i ), where the difference of any element (x,y) in the matrix is ​​expressed as:

[0043]

[0044] in:

[0045] Represents the x-th row and y-th column element and the scale σ i The difference representation of

[0046] S26: Based on the differential representation of different scales, the elements in the grayscale matrix are reconstructed, and the reconstructed matrix is ​​used as the pixel matrix of the instrument surface image after preprocessing to realize the pixel grayscale fusion based on the differential representation of different scales and gradient weights, and enhance the information intensity and edge clarity of the image defect area. The reconstructed element value of any element (x, y) is:

[0047]

[0048]

[0049] in:

[0050] Q″′(x,y) represents the reconstructed element value of element (x,y);

[0051] w i,(x,y) Represents the element (x, y) at scale σ i The gradient weight of .

[0052] Optionally, determining the defect extraction objective function in step S3 includes:

[0053] For any Defect extraction objective function determined by instrument surface image under viewing angle

[0054]

[0055] in:

[0056] express The defect grayscale threshold of the instrument surface image under the viewing angle is used to mark the elements in the pixel matrix of the instrument surface image whose element values ​​are higher than the defect grayscale threshold as defective elements, and the remaining elements as non-defective elements;

[0057] Indicates any The average gray value in the pixel matrix of the instrument surface image under the viewing angle;

[0058] Indicates the average element value of the marked defective elements, Indicates the average element value of the marked non-defective elements;

[0059] It represents the ratio of the number of marked defective elements to the total number of matrix elements. Indicates the ratio of the number of non-marked defect elements to the total number of matrix elements;

[0060] In the embodiment of the present invention, the pixel region corresponding to the defective element region in the pixel matrix of the instrument surface image is the defective pixel region.

[0061] Optionally, in step S3, extracting defective parts from the preprocessed multi-view instrument surface image based on the defect extraction objective function includes:

[0062] Adaptive genetic optimization strategy is used to optimize the Objective function for defect extraction of instrument surface images under viewing angle Solve it and get Defect grayscale threshold of instrument surface image under viewing angle The element value in the pixel matrix of the instrument surface image is higher than the defect grayscale threshold The elements are marked as defective elements, and the remaining elements are marked as non-defective elements. The instrument surface image pixel matrix with marked defective areas under different viewing angles is obtained. The area containing 80% defective elements in the preprocessed instrument surface image pixel matrix is ​​taken as the sub-image containing the defective part, where

[0063] The solution process of the defect extraction objective function is:

[0064] S31: Input the pixel matrix of the instrument surface image at all viewing angles after preprocessing and the corresponding defect extraction objective function, and convert any The defect extraction objective function of the perspective is reconstructed, and the reconstructed objective function F is:

[0065]

[0066] The reconstructed objective function divides the defect extraction objective functions under different viewing angles into four groups, each group includes the defect extraction objective functions under adjacent viewing angles, and the weight of each group is the absolute value of the difference between the defect grayscale thresholds under adjacent viewing angles;

[0067] S32: Generate U individuals to form a population, and randomly initialize the encoding representation of each individual. The encoding representation of each individual is the defect grayscale threshold of 8 different perspectives, where the initial encoding representation of the uth individual in the population is r u (0) = [r u,1 (0),r u,2 (0),...,r u,8 (0)], where r u,8 (0) indicates the initial encoding. u The defect grayscale threshold of the 8th viewing angle in (0) is in the range of 0-255. The sequential values ​​of k represent 8 viewing angles in turn;

[0068] S33: Generate a reverse population containing U reverse individuals based on the population, where the initial code of the u-th individual in the reverse population is expressed as

[0069] S34: Set the current iteration number of the adaptive genetic optimization strategy to t and the maximum iteration number to Max, where the initial value of t is 0, and initialize the adaptive threshold ε = 0; then the coding representation of the u-th individual in the population at the t-th iteration is r u (t), and the coding representation of the corresponding reverse individual is

[0070] S35: Substitute the coding representations of the individuals in the population and the reverse population into the reconstructed objective function F to obtain the objective function values corresponding to the coding representations, where the objective function value of the u-th individual in the population at the t-th iteration is F(r u (t)), and the objective function value of the corresponding reverse individual is

[0071] S36: Compare the objective function values of any individual in the population with the corresponding reverse individual. If the objective function value of the reverse individual is smaller, then replace the coding representation of the individual in the population with the coding representation of the corresponding reverse individual;

[0072] S37: Sort the individuals in the population in descending order according to the objective function values, and adopt the following coding representation update strategy for the coding representations of the top ε individuals after the descending order sorting:

[0073]

[0074] Where:

[0075] represents the coding representation of a random individual in the population, β represents the proportionality factor, and it is set to 0.6;

[0076] r ε (t) represents the coding representation of the top ε individuals after the t-th iteration;

[0077] Adopt the following coding representation update strategy for the remaining individuals:

[0078]

[0079] Where:

[0080] represents the coding representation of a random individual in the population, r 1-ε (t + 1) represents the update result of the coding representation of the remaining individuals;

[0081] S38: If t + 1 < Max, sequentially set t = t + 1, Return to step S33; otherwise, calculate the objective function values ​​of all individuals in the current population, use the encoded representation corresponding to the minimum objective function value as the defect grayscale threshold at different viewing angles obtained by solving, and mark the defect elements in the pixel matrix of the instrument surface image at different viewing angles based on the defect grayscale threshold at different viewing angles.

[0082] Optionally, in step S4, constructing an instrument surface defect feature detection index system includes:

[0083] An instrument surface feature detection index system is constructed, which includes shape features and texture features of the defective part. The shape features of the defective part represent the area of ​​the defective part, and the texture features represent the change in the grayscale value of the pixels in the defective area.

[0084] Optionally, in step S5, based on the instrument surface defect feature detection index system, index feature extraction is performed on sub-images containing defective parts at different viewing angles, including:

[0085] Based on the instrument surface defect feature detection index system, different The sub-image containing the defective part under the viewing angle is used to extract the index features, and the index feature extraction process is as follows:

[0086] Calculate the number of sub-images containing defective parts of the instrument to be inspected at different viewing angles and the area of ​​different sub-images as the shape features of the defective parts in Indicated in The number of sub-images containing defects under the viewing angle, Indicated in The area of ​​different sub-images under different viewing angles, Indicates that the The area of ​​a sub-image. In the embodiment of the present invention, the area containing 80% of defective elements in the pixel matrix of the instrument surface image is used as the sub-image containing the defective part;

[0087] Calculate the instrument to be tested The gray level co-occurrence matrix of the sub-image containing the defective part under the viewing angle is The texture features of the defective part of the viewing angle, where the gray level co-occurrence matrix is ​​in the form of:

[0088]

[0089] in:

[0090] count(0,255) means after preprocessing In the sub-image containing the defective part under the viewing angle, the number of element pairs whose element values ​​of adjacent elements in the horizontal direction are 0 and 255 respectively.

[0091] Optionally, in step S5, detecting whether there are defects on the surface of the instrument to be inspected at different viewing angles according to the extracted index features includes:

[0092] Preset a shape index threshold and a texture feature threshold, wherein the shape index threshold is in the form of a feature vector, including the number of sub-images containing defective parts and the areas of different sub-images, and the texture feature threshold is the gray level co-occurrence matrix of the image containing obvious defects;

[0093] According to the extracted index features, detect whether there are defects on the surface of the instrument to be tested at different viewing angles, and the detection process is as follows:

[0094] S51: Calculate any The number of sub-images containing defective parts under the viewing angle and the area of ​​different sub-images are used as Shape index features under viewing angle, and calculate The correlation between the shape index feature and the shape index threshold under the perspective is used as the calculation result. The probability of shape defects on the surface of the instrument to be inspected under the viewing angle

[0095] S52: Calculate any The gray level co-occurrence matrix of the sub-image containing the defective part under the viewing angle is related to the texture feature threshold, and the calculation result is used as The probability of texture defects on the surface of the instrument to be tested under the viewing angle

[0096] S53: As any The probability of defects on the surface of the instrument to be tested under the viewing angle

[0097] Optionally, in step S5, comprehensively judging whether there is a defect on the surface of the instrument based on the defect detection results at different viewing angles includes:

[0098] Based on the defect detection results at different viewing angles, it is comprehensively judged whether there are defects on the surface of the instrument, and the defect comprehensive detection judgment formula is:

[0099]

[0100] in:

[0101] p represents the defect detection result. If p is greater than the preset detection probability threshold, it means that there is a defect on the instrument surface.

[0102] In order to solve the above problem, the present invention provides an electronic device, the electronic device comprising:

[0103] A memory storing at least one instruction;

[0104] Communication interface, enabling electronic equipment to communicate; and

[0105] The processor executes the instructions stored in the memory to implement the multi-view visual inspection method for mechanical defects described above.

[0106] In order to solve the above problems, the present invention also provides a computer-readable storage medium, in which at least one instruction is stored. The at least one instruction is executed by a processor in an electronic device to implement the above-mentioned multi-view mechanical defect visual detection method.

[0107] Compared with the prior art, the present invention proposes a multi-view visual inspection method for mechanical defects, which has the following advantages:

[0108] First, this scheme proposes an image denoising and enhancement method. According to the acquired multi-view instrument surface images, the intrinsic scale decomposition and fusion method is used to pre-process the instrument surface images of the instrument to be detected at different viewpoints by decomposing and fusion image features at different scales, and the denoised and enhanced instrument surface images are obtained. The intrinsic scale decomposition and fusion method process is as follows: for any The instrument surface image of the instrument to be detected under the viewing angle is grayed to obtain the gray matrix Q of the instrument surface image. The size of the gray matrix is ​​M×N, where M represents the number of row pixels in the instrument surface image, and N represents the number of column pixels in the instrument surface image. The element coordinates in the gray matrix are the pixel coordinates of the corresponding pixels in the instrument surface image, and the element value is the gray value of the corresponding pixel. The gray matrix Q is subjected to row filtering and column filtering in turn using the denoising filter function to obtain the gray filtering result of any element in the gray matrix:

[0109] Q′(x,y)=q(x,y)[1-α 2 / (Q(x,y)) 2 ],x∈[1,M],y∈[1,N]

[0110]

[0111]

[0112]

[0113]

[0114] Where: e represents a natural constant; ω(·) represents a denoising filter function; Q(x,y) represents the element value of the element in the xth row and yth column of the gray matrix Q; q(x,y) represents the filter coefficient of the element in the xth row and yth column of the gray matrix Q; Q′(x,y) represents the gray filtering result of the element in the xth row and yth column of the gray matrix Q; a represents the filter scale, max a∈[1,5] {q a (x,y)} represents the maximum value of the grayscale filtering result of the element in the xth row and yth column of the grayscale matrix Q at the scale a∈[1,5]; σ Q Represents the standard deviation of the element values ​​in the grayscale matrix Q; α represents the preset filtering threshold; and the grayscale filtering results of all elements are constructed as the grayscale filtering matrix Q′; Gaussian filter templates of different scales σ1, σ2, σ3 are constructed, where the Gaussian filter template is in the form of a 3×3 matrix, σ1=1, σ2=2, σ3=3; Convolve the Gaussian filter templates of different scales with any element of the grayscale filtering matrix Q′:

[0115]

[0116] in: The scale is σ i Gaussian filter template, Represents the Gaussian filtered template After filtering, the element value of the element in the xth row and the yth column; after Gaussian filtering of all elements, the result forms the matrix Q″(σ i );Calculate the grayscale filter matrix Q′ and the matrix Q″(σ i ), where the difference of any element (x,y) in the matrix is ​​expressed as:

[0117]

[0118] in: Represents the x-th row and y-th column element and the scale σ i Based on the differential representation of different scales, the elements in the grayscale matrix are reconstructed, and the reconstructed matrix is ​​used as the pixel matrix of the instrument surface image after preprocessing, where the reconstructed element value of any element (x, y) is:

[0119]

[0120]

[0121] Where: Q″′(x,y) represents the reconstructed element value of element (x,y); w i,(x,y) Represents the element (x, y) at scale σ iGradient weight. This scheme uses a denoising filter function to perform row filtering and column filtering on the grayscale matrix of the surface image of the inspection instrument in turn, smoothing the noise information of the surface image and achieving the weakening of the image noise caused by the viewing angle light, etc., but while weakening the noise, it also weakens the information intensity of the defective part. Therefore, a multi-scale Gaussian filter template convolution difference processing is adopted to perform pixel grayscale fusion based on different scale differential representations and gradient weights on Gaussian filter processed pixels at different scales, thereby enhancing the information intensity and edge clarity of the image defect area.

[0122] At the same time, this scheme proposes a defect extraction process, which constructs the defect extraction objective function of the instrument surface image at different viewing angles, inputs the pixel matrix of the instrument surface image at all viewing angles after preprocessing and the corresponding defect extraction objective function, and converts any The defect extraction objective function of the perspective is reconstructed, and the reconstructed objective function F is:

[0123]

[0124] The reconstructed objective function divides the defect extraction objective functions under different perspectives into four groups, each of which includes the defect extraction objective functions under adjacent perspectives. The weight of each group is the absolute value of the difference between the defect grayscale thresholds under adjacent perspectives. U individuals are generated to form a population, and the encoding representation of each individual is randomly initialized. The encoding representation of each individual is the defect grayscale threshold of 8 different perspectives, where the initial encoding representation of the u-th individual in the population is

[0125] r u (0) = [r u,1 (0),r u,2 (0),...,r u,8 (0)], where r u,8 (0) indicates the initial encoding. u The defect grayscale threshold of the 8th viewing angle in (0) is in the range of 0-255. The sequential values ​​of k represent 8 perspectives in turn; a reverse population containing U reverse individuals is generated based on the population, where the initial code of the u-th individual in the reverse population is expressed as Set the current iteration number of the adaptive genetic optimization strategy to t, the maximum iteration number to Max, where the initial value of t is 0, and the adaptive threshold ε is initialized to 0; then the encoding of the uth individual in the population at the tth iteration is represented by r u (t), the corresponding reverse individual encoding is expressed as Substitute the encoded representation of individuals in the population and the reverse population into the reconstructed objective function F to obtain the objective function value of the corresponding encoded representation, where the objective function value of the u-th individual in the population at the t-th iteration is F(ru (t)), the objective function value of the corresponding reverse individual is Compare the objective function values of any individual in the population with those of the corresponding reverse individuals. If the objective function value of the reverse individual is smaller, replace the coding representation of the individual in the population with that of the corresponding reverse individual; sort the individuals in the population in descending order of the objective function value, and adopt the following coding representation update strategy for the coding representations of the first ε individuals after the descending order sorting:

[0126]

[0127] Where: represents the coding representation of a random individual in the population, β represents the proportionality factor, and it is set to 0.6;

[0128] r ε (t) represents the coding representation of the first ε individuals after the t-th iteration; adopt the following coding representation update strategy for the remaining individuals:

[0129]

[0130] Where: represents the coding representation of a random individual in the population, r 1-ε (t + 1) represents the update result of the coding representation of the remaining individuals; if t + 1 < Max, successively set t = t + 1, regenerate the reverse individuals for algorithm iteration; otherwise, calculate the objective function values of all individuals in the current population, and use the coding representation corresponding to the minimum objective function value as the defect gray threshold under different perspectives. Based on the defect gray thresholds under different perspectives, mark the defect elements in the pixel matrix of the instrument surface image under different perspectives. In the process of defect part extraction, this scheme adopts the reverse learning strategy to obtain the reverse individuals of the current iterative individuals. By comparing the current iterative individuals and the reverse individuals, the relatively better individuals are selected as the next iterative individuals, enriching the diversity of the population. In the process of the defect extraction objective function, each individual adopts an adaptive iterative strategy for algorithm iteration. The individuals with better performance use their own coding representations as the base, enhancing the local searchability. The individuals with relatively poor performance adopt the random iteration method, enabling the individuals to fully search the coding representation space to accelerate the exploration. This can not only better balance the diversity of the population to improve the solution accuracy, but also accelerate the convergence to save the search cost of the algorithm, quickly realize the defect part extraction, and according to the defect part extraction result, extract the index features of the sub-images containing the defect parts under different perspectives, detect whether there are defects on the surface of the instrument to be detected under different perspectives, and comprehensively judge whether there are defects on the surface of this instrument based on the defect detection results under different perspectives. Description of the Drawings

[0131] Figure 1A schematic diagram of a flow chart of a multi-viewing mechanical defect visual inspection method provided by an embodiment of the present invention;

[0132] Figure 2 A schematic diagram of the structure of an electronic device for implementing a multi-viewing angle mechanical defect visual inspection method provided by an embodiment of the present invention.

[0133] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0134] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0135] The embodiment of the present application provides a multi-view visual detection method for mechanical defects. The execution subject of the multi-view visual detection method for mechanical defects includes but is not limited to at least one of the electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiment of the present application. In other words, the multi-view visual detection method for mechanical defects can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc.

[0136] Embodiment 1:

[0137] S1: Rotate the shooting angle to obtain multi-view instrument surface images of the instrument to be inspected.

[0138] The step S1 of obtaining a multi-view instrument surface image of the instrument to be detected includes:

[0139] Use a camera to capture the surface image of the instrument to be inspected for defects. After each capture, rotate the camera clockwise to obtain the surface image of the instrument to be inspected at different viewing angles. in Indicates rotating the camera device clockwise After the degree, we get The instrument surface image of the instrument to be detected under different viewing angles is taken as the multi-viewing angle instrument surface image of the instrument to be detected.

[0140] S2: performing image denoising and enhancement preprocessing on the acquired multi-view instrument surface image to obtain a preprocessed multi-view instrument surface image, wherein intrinsic scale decomposition and fusion is the main implementation method of the image denoising and enhancement processing.

[0141] The step S2 performs image denoising and enhancement preprocessing on the acquired multi-view instrument surface image, including:

[0142] According to the acquired multi-view instrument surface images, the intrinsic scale decomposition and fusion method is used to pre-process the instrument surface images of the instrument to be detected at different viewpoints by decomposing and fusion of image features at different scales, and the denoised and enhanced instrument surface images are obtained. The process of the intrinsic scale decomposition and fusion method is as follows:

[0143] S21: For any The instrument surface image of the instrument to be detected under the viewing angle is subjected to image grayscale processing to obtain a grayscale matrix Q of the instrument surface image. The size of the grayscale matrix is ​​M×N, where M represents the number of row pixels in the instrument surface image, and N represents the number of column pixels in the instrument surface image. The element coordinates in the grayscale matrix are the pixel coordinates of the corresponding pixels in the instrument surface image, and the element value is the grayscale value of the corresponding pixel. In the embodiment of the present invention, the grayscale value of a pixel is the maximum value of the pixel in the RGB color component.

[0144] S22: Use the denoising filter function to perform row filtering and column filtering on the grayscale matrix Q in sequence to obtain the grayscale filtering result of any element in the grayscale matrix:

[0145] Q′(x,y)=q(x,y)[1-α 2 / (Q(x,y)) 2 ],x∈[1,M],y∈[1,N]

[0146]

[0147]

[0148]

[0149]

[0150] in:

[0151] e represents a natural constant;

[0152] ω(·) represents the denoising filter function;

[0153] Q(x,y) represents the element value of the element in the xth row and yth column of the gray matrix Q, q(x,y) represents the filter coefficient of the element in the xth row and yth column of the gray matrix Q, and Q′(x,y) represents the gray filtering result of the element in the xth row and yth column of the gray matrix Q, where the filtering result is the processing result after the noise is weakened;

[0154] a represents the filtering scale, max a∈[1,5] {q a (x,y)} represents the maximum value of the grayscale filtering result of the element in the xth row and yth column of the grayscale matrix Q at the scale a∈[1,5];

[0155] σ Q Represents the standard deviation of the element values ​​in the gray matrix Q;

[0156] α represents the preset filtering threshold;

[0157] And the grayscale filtering results of all elements are constructed as a grayscale filtering matrix Q′;

[0158] S23: construct Gaussian filter templates of different scales σ1, σ2, σ3, where the Gaussian filter template is in the form of a 3×3 matrix, σ1=1, σ2=2, σ3=3;

[0159] In the embodiment of the present invention, the construction process of the Gaussian filter template is as follows:

[0160] Set the initial Gaussian filter template:

[0161]

[0162] in:

[0163] G σi (x′,y′) represents the scale σ i The element value of the element in the x′th row and y′th column in the initial Gaussian filter template;

[0164] Normalize the element values ​​of each element in the initial Gaussian filter template so that the sum of all elements is 1, and the scale is σ i Gaussian filter template

[0165] S24: Convolve the Gaussian filter templates of different scales with any element of the grayscale filter matrix Q′:

[0166]

[0167] in:

[0168] The scale is σ i Gaussian filter template, Represents the Gaussian filtered template After filtering, the element value of the element in the xth row and yth column;

[0169] The Gaussian filtering of all elements results in the formation of a matrix Q″(σ i );

[0170] S25: Calculate the grayscale filter matrix Q′ and the matrix Q″ (σ i ), where the difference of any element (x,y) in the matrix is ​​expressed as:

[0171]

[0172] in:

[0173] Represents the x-th row and y-th column element and the scale σ i The difference representation of

[0174] S26: Based on the differential representation of different scales, the elements in the grayscale matrix are reconstructed, and the reconstructed matrix is ​​used as the pixel matrix of the instrument surface image after preprocessing to realize the pixel grayscale fusion based on the differential representation of different scales and gradient weights, and enhance the information intensity and edge clarity of the image defect area. The reconstructed element value of any element (x, y) is:

[0175]

[0176]

[0177] in:

[0178] Q″′(x,y) represents the reconstructed element value of element (x,y);

[0179] w i,(x,y) Represents the element (x, y) at scale σ i The gradient weight of .

[0180] S3: Extract defective parts from the preprocessed multi-view instrument surface image based on the defect extraction objective function to obtain sub-images containing defective parts at different viewing angles, wherein the adaptive genetic optimization strategy is the main implementation strategy for defect extraction from the instrument surface image.

[0181] Determining the defect extraction objective function in step S3 includes:

[0182] For any Defect extraction objective function determined by instrument surface image under viewing angle

[0183]

[0184] in:

[0185] express The defect grayscale threshold of the instrument surface image under the viewing angle is used to mark the elements in the pixel matrix of the instrument surface image whose element values ​​are higher than the defect grayscale threshold as defective elements, and the remaining elements as non-defective elements;

[0186] Indicates any The average gray value in the pixel matrix of the instrument surface image under the viewing angle;

[0187] Indicates the average element value of the marked defective elements, Indicates the average element value of the marked non-defective elements; It represents the ratio of the number of marked defective elements to the total number of matrix elements. Indicates the ratio of the number of non-marked defect elements to the total number of matrix elements;

[0188] In the embodiment of the present invention, the pixel region corresponding to the defective element region in the pixel matrix of the instrument surface image is the defective pixel region.

[0189] In the step S3, defect extraction is performed on the preprocessed multi-view instrument surface image based on the defect extraction objective function, including:

[0190] Adaptive genetic optimization strategy is used to optimize the Objective function for defect extraction of instrument surface images under viewing angle Solve it and get Defect grayscale threshold of instrument surface image under viewing angle The element value in the pixel matrix of the instrument surface image is higher than the defect grayscale threshold The elements are marked as defective elements, and the remaining elements are marked as non-defective elements. The instrument surface image pixel matrix with marked defective areas under different viewing angles is obtained. The area containing 80% defective elements in the preprocessed instrument surface image pixel matrix is ​​taken as the sub-image containing the defective part, where

[0191] The solution process of the defect extraction objective function is:

[0192] S31: Input the pixel matrix of the instrument surface image at all viewing angles after preprocessing and the corresponding defect extraction objective function, and convert any The defect extraction objective function of the perspective is reconstructed, and the reconstructed objective function F is:

[0193]

[0194] The reconstructed objective function divides the defect extraction objective functions under different viewing angles into four groups, each group includes the defect extraction objective functions under adjacent viewing angles, and the weight of each group is the absolute value of the difference between the defect grayscale thresholds under adjacent viewing angles;

[0195] S32: Generate U individuals to form a population, and randomly initialize the encoding representation of each individual. The encoding representation of each individual is the defect grayscale threshold of 8 different perspectives, where the initial encoding representation of the uth individual in the population is r u (0) = [r u,1 (0),ru,2 (0),...,r u,8 (0)], where r u,8 (0) indicates the initial encoding. u The defect grayscale threshold of the 8th viewing angle in (0) is in the range of 0-255. The sequential values ​​of k represent 8 viewing angles in turn;

[0196] S33: Generate a reverse population containing U reverse individuals based on the population, where the initial code of the u-th individual in the reverse population is expressed as

[0197] S34: Set the current iteration number of the adaptive genetic optimization strategy to t, the maximum iteration number to Max, where the initial value of t is 0, and the adaptive threshold ε is initialized to 0; then the encoding of the uth individual in the population at the tth iteration is represented by r u (t), the corresponding reverse individual encoding is expressed as

[0198] S35: Substitute the encoded representations of the individuals in the population and the reverse population into the reconstructed objective function F to obtain the objective function value of the corresponding encoded representation, where the objective function value of the u-th individual in the population at the t-th iteration is F(r u (t)), the corresponding objective function value of the reverse individual is

[0199] S36: Compare the objective function value of any individual in the population with the corresponding reverse individual. If the objective function value of the reverse individual is smaller, replace the encoding representation of the individual in the population with the encoding representation of the corresponding reverse individual.

[0200] S37: Sort the individuals in the population in descending order according to the objective function value, and adopt the following coding representation update strategy for the coding representation of the first ε individuals after descending sorting:

[0201]

[0202] in:

[0203] represents the encoding representation of a random individual in the population, β represents the scaling factor, which is set to 0.6;

[0204] r ε (t) represents the encoding representation of the first ε individuals after the tth iteration;

[0205] The following encoding is used to represent the update strategy for the remaining individuals:

[0206]

[0207] Wherein:

[0208] represents the coding representation of a random individual in the population, and r 1-ε (t + 1) represents the updated result of the coding representation of the remaining individuals;

[0209] S38: If t + 1 < Max, sequentially set t = t + 1, return to step S33; otherwise, calculate the objective function values of all individuals in the current population, and use the coding representation corresponding to the minimum objective function value as the defect gray threshold under different perspectives, and mark the defect elements in the pixel matrix of the instrument surface image under different perspectives based on the defect gray thresholds under different perspectives.

[0210] S4: Construct an instrument surface defect feature detection index system, and the index system includes shape features and texture features.

[0211] In the step S4 of constructing the instrument surface defect feature detection index system, it includes:

[0212] Construct an instrument surface feature detection index system, and the constructed instrument surface feature detection index system includes the shape features of the defective part and texture features. The shape features of the defective part represent the area of the defective part, and the texture features represent the change of the gray values of the pixels in the defective area.

[0213] S5: Based on the instrument surface defect feature detection index system, extract index features from the sub-images containing defective parts under different perspectives, detect whether there are defects on the surface of the instrument to be detected under different perspectives, and comprehensively judge whether there are defects on the surface of the instrument based on the defect detection results under different perspectives.

[0214] In the step S5 of extracting index features from the sub-images containing defective parts under different perspectives based on the instrument surface defect feature detection index system, it includes:

[0215] Based on the instrument surface defect feature detection index system, for different extract index features from the sub-images containing defective parts under perspectives, and the index feature extraction process is as follows:

[0216] Calculate the number of sub-images containing defective parts of the instrument to be detected under different perspectives and the areas of different sub-images as the shape features of the defective part Wherein represents the number of sub-images containing defective parts under the represents the areas of different sub-images under the represents the The area of ​​a sub-image. In the embodiment of the present invention, the area containing 80% of defective elements in the pixel matrix of the instrument surface image is used as the sub-image containing the defective part;

[0217] Calculate the instrument to be tested The gray level co-occurrence matrix of the sub-image containing the defective part under the viewing angle is The texture features of the defective part of the viewing angle, where the gray level co-occurrence matrix is ​​in the form of:

[0218]

[0219] in:

[0220] count(0,255) means after preprocessing In the sub-image containing the defective part under the viewing angle, the number of element pairs whose element values ​​of adjacent elements in the horizontal direction are 0 and 255 respectively.

[0221] In step S5, based on the extracted index features, detecting whether there are defects on the surface of the instrument to be inspected at different viewing angles includes:

[0222] Preset a shape index threshold and a texture feature threshold, wherein the shape index threshold is in the form of a feature vector, including the number of sub-images containing defective parts and the areas of different sub-images, and the texture feature threshold is the gray level co-occurrence matrix of the image containing obvious defects;

[0223] According to the extracted index features, detect whether there are defects on the surface of the instrument to be tested at different viewing angles, and the detection process is as follows:

[0224] S51: Calculate any The number of sub-images containing defective parts under the viewing angle and the area of ​​different sub-images are used as Shape index features under viewing angle, and calculate The correlation between the shape index feature and the shape index threshold under the perspective is used as the calculation result. The probability of shape defects on the surface of the instrument to be inspected under the viewing angle

[0225] S52: Calculate any The gray level co-occurrence matrix of the sub-image containing the defective part under the viewing angle is related to the texture feature threshold, and the calculation result is used as The probability of texture defects on the surface of the instrument to be tested under the viewing angle

[0226] S53: As any The probability of defects on the surface of the instrument to be tested under the viewing angle

[0227] In step S5, based on the defect detection results at different viewing angles, it is comprehensively judged whether there is a defect on the surface of the instrument, including:

[0228] Based on the defect detection results at different viewing angles, it is comprehensively judged whether there are defects on the surface of the instrument, and the defect comprehensive detection judgment formula is:

[0229]

[0230] in:

[0231] p represents the defect detection result. If p is greater than the preset detection probability threshold, it means that there is a defect on the instrument surface.

[0232] Embodiment 2:

[0233] like Figure 2 , is a schematic diagram of the structure of an electronic device for implementing a multi-viewing angle mechanical defect visual detection method provided by an embodiment of the present invention.

[0234] The electronic device 1 may include a processor 10 , a memory 11 , a communication interface 13 and a bus, and may also include a computer program stored in the memory 11 and executable on the processor 10 , such as a program 12 .

[0235] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. The memory 11 may be an internal storage unit of the electronic device 1 in some embodiments, such as a mobile hard disk of the electronic device 1. The memory 11 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 1. Further, the memory 11 may also include both an internal storage unit of the electronic device 1 and an external storage device. The memory 11 may be used not only to store application software and various types of data installed in the electronic device 1, such as the code of the program 12, etc., but also to temporarily store data that has been output or is to be output.

[0236] The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips, etc. The processor 10 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules stored in the memory 11 (such as the program 12 for realizing multi-view mechanical defect visual detection), and calls data stored in the memory 11 to execute various functions of the electronic device 1 and process data.

[0237] The communication interface 13 may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device 1 and other electronic devices, and to achieve connection and communication between internal components of the electronic device.

[0238] The bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.

[0239] Figure 2 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 2 The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.

[0240] For example, although not shown, the electronic device 1 may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, etc. The electronic device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.

[0241] Optionally, the electronic device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device 1 and to display a visual user interface.

[0242] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.

[0243] The program 12 stored in the memory 11 in the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can achieve:

[0244] Rotate the shooting angle to obtain multi-view instrument surface images of the instrument to be tested;

[0245] Performing image denoising and enhancement preprocessing on the acquired multi-view instrument surface image to obtain a preprocessed multi-view instrument surface image;

[0246] Based on the defect extraction objective function, the defect part is extracted from the preprocessed multi-view instrument surface image to obtain sub-images containing defect parts at different viewing angles;

[0247] Construct an instrument surface defect feature detection index system;

[0248] Based on the instrument surface defect feature detection index system, the index features of the sub-images containing defective parts at different viewing angles are extracted to detect whether there are defects on the surface of the instrument to be inspected at different viewing angles, and based on the defect detection results at different viewing angles, it is comprehensively judged whether there are defects on the instrument surface.

[0249] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to Figure 1 to Figure 2 The description of the relevant steps in the corresponding embodiments will not be repeated here.

[0250] It should be noted that the serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments. And the terms "including", "comprising" or any other variants thereof in this article are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "including a ..." does not exclude the presence of other identical elements in the process, device, article or method including the element.

[0251] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0252] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A multi-view visual inspection method for mechanical defects, characterized in that: The method comprises: S1: Rotate the shooting angle to obtain multi-view instrument surface images of the instrument to be tested; S2: performing image denoising and enhancement preprocessing on the acquired multi-view instrument surface image to obtain a preprocessed multi-view instrument surface image, wherein intrinsic scale decomposition and fusion is an implementation method of the image denoising and enhancement processing; S3: extracting defective parts from the preprocessed multi-view instrument surface image based on the defect extraction objective function to obtain sub-images containing defective parts at different viewing angles, wherein the adaptive genetic optimization strategy is the implementation strategy for defect extraction of the instrument surface image; S4: constructing an instrument surface defect feature detection index system, wherein the index system includes shape features and texture features; S5: Based on the instrument surface defect feature detection index system, extract index features from sub-images containing defective parts at different viewing angles, detect whether there are defects on the surface of the instrument to be inspected at different viewing angles, and comprehensively judge whether there are defects on the instrument surface based on the defect detection results at different viewing angles; According to the extracted index features, detect whether there are defects on the surface of the instrument to be tested at different viewing angles, including: Preset a shape index threshold and a texture feature threshold, wherein the shape index threshold is in the form of a feature vector, including the number of sub-images containing defective parts and the areas of different sub-images, and the texture feature threshold is the gray level co-occurrence matrix of the image containing obvious defects; According to the extracted index features, detect whether there are defects on the surface of the instrument to be tested at different viewing angles, and the detection process is as follows: S51: Calculate any The number of sub-images containing defective parts under the viewing angle and the area of ​​different sub-images are used as Shape index features under viewing angle, and calculate The correlation between the shape index feature and the shape index threshold under the perspective is used as the calculation result. The probability of shape defects on the surface of the instrument to be inspected under the viewing angle ; S52: Calculate any The gray level co-occurrence matrix of the sub-image containing the defective part under the viewing angle is related to the texture feature threshold, and the calculation result is used as The probability of texture defects on the surface of the instrument to be tested under the viewing angle ; S53: As any The probability p( ).

2. A multi-view visual inspection method for mechanical defects according to claim 1, characterized in that: The step S1 of obtaining a multi-view instrument surface image of the instrument to be detected includes: Use a camera to capture the surface image of the instrument to be inspected for defects. After each capture, rotate the camera clockwise to obtain the surface image of the instrument to be inspected at different viewing angles. ,in Indicates rotating the camera device clockwise After the degree, we get The instrument surface image of the instrument to be tested under the viewing angle, The instrument surface image of the instrument to be detected under the initial shooting angle of view is represented, and the instrument surface images of the instrument to be detected under different angles of view are used as the multi-angle instrument surface images of the instrument to be detected.

3. A multi-view visual inspection method for mechanical defects according to claim 2, characterized in that: The step S2 performs image denoising and enhancement preprocessing on the acquired multi-view instrument surface image, including: According to the acquired multi-view instrument surface images, the intrinsic scale decomposition and fusion method is used to pre-process the instrument surface images of the instrument to be detected at different viewpoints by decomposing and fusion of image features at different scales, and the denoised and enhanced instrument surface images are obtained. The process of the intrinsic scale decomposition and fusion method is as follows: S21: For any The instrument surface image of the instrument to be detected is grayed out under the viewing angle to obtain the gray matrix Q of the instrument surface image. The size of the gray matrix is , where M represents the number of row pixels in the instrument surface image, N represents the number of column pixels in the instrument surface image, the element coordinates in the grayscale matrix are the pixel coordinates of the corresponding pixels in the instrument surface image, and the element value is the grayscale value of the corresponding pixel; S22: Use the denoising filter function to perform row filtering and column filtering on the grayscale matrix Q in sequence to obtain the grayscale filtering result of any element in the grayscale matrix: in: e represents a natural constant; represents the denoising filter function; Represents the element value of the element in the xth row and yth column in the grayscale matrix Q, Represents the filter coefficient of the element in the xth row and yth column in the grayscale matrix Q, Represents the grayscale filtering result of the element in the xth row and yth column in the grayscale matrix Q; represents the filtering scale, Indicated in The maximum value of the grayscale filtering result of the element in the xth row and yth column of the grayscale matrix Q under the scale; Represents the standard deviation of the element values ​​in the gray matrix Q; Indicates the preset filtering threshold; And the grayscale filtering results of all elements are constructed as a grayscale filtering matrix ; S23: Constructing different scales Gaussian filter template, where the Gaussian filter template is In matrix form, , , ; S24: Gaussian filter templates of different scales and grayscale filter matrices Convolution operation is performed on any element of : in: The scale is Gaussian filter template, Represents the Gaussian filtered template After filtering, the element value of the element in the xth row and yth column; The result of Gaussian filtering of all elements forms a matrix ; S25: Calculate the grayscale filter matrix With matrices at different scales The difference matrix of The difference is expressed as: in: Represents the x-th row and y-th column element and scale The difference representation of S26: Based on the differential representation of different scales, the elements in the grayscale matrix are reconstructed, and the reconstructed matrix is ​​used as the pixel matrix of the instrument surface image after preprocessing, where any element The reconstructed element value is: in: Representation elements The reconstructed element value of ; Representation elements In scale The gradient weight of .

4. A multi-view visual inspection method for mechanical defects according to claim 1, characterized in that: Determining the defect extraction objective function in step S3 includes: For any Defect extraction objective function determined by instrument surface image under viewing angle : in: express The defect grayscale threshold of the instrument surface image under the viewing angle is used to mark the elements in the pixel matrix of the instrument surface image whose element values ​​are higher than the defect grayscale threshold as defective elements, and the remaining elements as non-defective elements; Indicates any The average gray value in the pixel matrix of the instrument surface image under the viewing angle; Indicates the average element value of the marked defective elements, Indicates the average element value of the marked non-defective elements; It represents the ratio of the number of marked defective elements to the total number of matrix elements. It indicates the ratio of the number of unmarked defect elements to the total number of matrix elements.

5. A multi-view visual inspection method for mechanical defects according to claim 4, characterized in that: In the step S3, defect extraction is performed on the preprocessed multi-view instrument surface image based on the defect extraction objective function, including: Adaptive genetic optimization strategy is used to optimize the Objective function for defect extraction of instrument surface images under viewing angle Solve it and get Defect grayscale threshold of instrument surface image under viewing angle , the element value in the pixel matrix of the instrument surface image is higher than the defect grayscale threshold The elements are marked as defective elements, and the remaining elements are marked as non-defective elements. The instrument surface image pixel matrix with marked defective areas under different viewing angles is obtained. The area containing 80% defective elements in the preprocessed instrument surface image pixel matrix is ​​taken as the sub-image containing the defective part, where ; The solution process of the defect extraction objective function is: S31: Input the pixel matrix of the instrument surface image at all viewing angles after preprocessing and the corresponding defect extraction objective function, and convert any The defect extraction objective function of the perspective is reconstructed, and the reconstructed objective function F is: The reconstructed objective function divides the defect extraction objective functions under different viewing angles into four groups, each group includes the defect extraction objective functions under adjacent viewing angles, and the weight of each group is the absolute value of the difference between the defect grayscale thresholds under adjacent viewing angles; S32: Generate U individuals to form a population, and randomly initialize the encoding representation of each individual. The encoding representation of each individual is the defect grayscale threshold of 8 different viewing angles, where the initial encoding representation of the u-th individual in the population is ,in Represents the initial encoding representation The defect grayscale threshold of the 8th viewing angle, the value range of each defect grayscale threshold is 0-255, , the sequential values ​​of k represent 8 perspectives in turn; S33: Generate a reverse population containing U reverse individuals based on the population, where the initial code of the u-th individual in the reverse population is expressed as ; S34: Set the current iteration number of the adaptive genetic optimization strategy to t, the maximum iteration number to Max, where the initial value of t is 0, and initialize the adaptive threshold ; Then the encoding of the u-th individual in the population at the t-th iteration is expressed as , the corresponding reverse individual encoding is expressed as ; S35: Substitute the encoded representation of individuals in the population and the reverse population into the reconstructed objective function F to obtain the objective function value of the corresponding encoded representation, where the objective function value of the u-th individual in the population at the t-th iteration is , the corresponding objective function value of the reverse individual is ; S36: Compare the objective function value of any individual in the population with the corresponding reverse individual. If the objective function value of the reverse individual is smaller, replace the encoding representation of the individual in the population with the encoding representation of the corresponding reverse individual. S37: Sort the individuals in the population in descending order according to the objective function value, and sort the individuals in descending order. The encoding representation of each individual adopts the following encoding representation update strategy: in: represents the encoding representation of a random individual in the population, Represents the scale factor, set it to 0.6; Indicates the number of iterations before The coded representation of each individual; The following encoding is used to represent the update strategy for the remaining individuals: in: represents the encoding representation of a random individual in the population, The codes representing the remaining individuals represent the update results; S38: If , and then , , return to step S33; otherwise, calculate the objective function values ​​of all individuals in the current population, use the encoded representation corresponding to the minimum objective function value as the defect grayscale threshold under different viewing angles obtained by solving, and mark the defect elements in the pixel matrix of the instrument surface image under different viewing angles based on the defect grayscale threshold under different viewing angles.

6. A multi-view visual inspection method for mechanical defects according to claim 1, characterized in that: The instrument surface defect feature detection index system is constructed in step S4, including: An instrument surface feature detection index system is constructed, which includes shape features and texture features of the defective part. The shape features of the defective part represent the area of ​​the defective part, and the texture features represent the change in the grayscale value of the pixels in the defective area.

7. A multi-view visual inspection method for mechanical defects according to claim 6, characterized in that: In the step S5, based on the instrument surface defect feature detection index system, the index feature extraction is performed on the sub-images containing defective parts at different viewing angles, including: Based on the instrument surface defect feature detection index system, different The sub-image containing the defective part under the viewing angle is used to extract the index features, and the index feature extraction process is as follows: Calculate the number of sub-images containing defective parts of the instrument to be inspected at different viewing angles and the area of ​​different sub-images as the shape features of the defective parts ,in Indicated in The number of sub-images containing defects under the viewing angle, Indicated in The area of ​​different sub-images under different viewing angles, Indicates that the The area of ​​the sub-images; Calculate the instrument to be tested The gray level co-occurrence matrix of the sub-image containing the defective part under the viewing angle is The texture features of the defective part of the viewing angle, where the gray level co-occurrence matrix is ​​in the form of: in: After preprocessing In the sub-image containing the defective part under the viewing angle, the element values ​​of adjacent elements in the horizontal direction are The number of pairs of elements.

8. The multi-view visual inspection method for mechanical defects according to claim 1, characterized in that: In step S5, based on the defect detection results at different viewing angles, it is comprehensively judged whether there is a defect on the surface of the instrument, including: Based on the defect detection results at different viewing angles, it is comprehensively judged whether there are defects on the surface of the instrument, and the defect comprehensive detection judgment formula is: in: Indicates the defect detection result. If p is greater than the preset detection probability threshold, it means that there is a defect on the instrument surface.

Citation Information

Patent Citations

  • Electronic die cutting material defect detecting implementation method based on machine vision

    CN106770332A

  • Die cutting material defect information generation method, defect calibration method and system

    CN114359263A