Industrial heterogeneous visual recognition system and method
By constructing a training set and iterative training algorithm, the problem of image deviation caused by occlusion in industrial visual inspection is solved, efficient image repair and feature extraction are achieved, and the detection error rate and processing time are reduced.
Patent Information
- Application Number
- CN202410532029.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-29
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-04-29
AI Technical Summary
In industrial visual inspection, the object to be tested may be blocked at a certain angle or under a light source, causing deviations in the image fitting process. It is necessary to repair the missing image data in key areas to improve the efficiency and quality of image feature extraction.
An industrial heterogeneous visual recognition method is used to construct a training set by collecting multi-angle images, detect whether there is occlusion in the image, calculate the proportion of the occlusion area, and use the clustering algorithm and fitting algorithm for iterative training to extract and repair the image. feature distribution to generate the final repaired image.
Through preliminary screening of occlusion situations, the detection error rate is reduced, the number of iterations is reduced, the image processing efficiency is improved, and the best repaired image is generated.
Smart Images

Figure CN118351284B
Abstract
Description
Technical Field
[0001] The invention belongs to the field of data processing, and in particular relates to an industrial heterogeneous visual recognition system and method. Background Art
[0002] In industrial visual inspection, in order to improve the efficiency and quality of image feature extraction, heterogeneous images taken by different sensors, at different angles or at different times are often used for registration and fitting to obtain the final image of the object to be tested. However, in actual operation, the object to be tested is often partially blocked at a certain angle or under a certain light source, resulting in deviations in the final fitting process. Therefore, repairing the missing image data in key areas has become an essential part of the processing process. Summary of the invention
[0003] To this end, the present invention provides an industrial heterogeneous visual recognition method and system for repairing key areas of images with occlusion.
[0004] A first aspect of the present invention provides an industrial heterogeneous visual recognition method, comprising the steps of: S1: collecting multiple groups of multi-angle images of the product, and constructing an original image I0 training set;
[0005] S11: setting the image center definition point, scaling it along a preset distance, obtaining multiple edge definition points about the image middle definition point, thereby extracting multiple features T1 between the image middle definition point and the edge definition point;
[0006] S12: extracting a plurality of features T2 between the plurality of edge definition points;
[0007] S13: Combine T1 and T2 to obtain the feature distribution T3 of the original image I0 to form a training set;
[0008] S2: During the detection process, a heterogeneous image of the object to be detected is collected, and the heterogeneous image is preprocessed to obtain an image I1;
[0009] S3: Determine whether I1 is occluded and calculate the proportion of the occluded area; divide I1 into multiple local areas, calculate the pixel value and the number of pixels in the local area, compare the pixel value and the number of pixels with a preset occlusion threshold, if it is lower than the occlusion threshold, determine that the image is occluded, calculate the proportion of the number of pixels in the occluded area, and compare the proportion with a preset limit proportion, if it is higher than the limit proportion, input the training set, if it is lower than the limit proportion, it is judged as unqualified and an unavailable alarm is issued; if it is higher than the occlusion threshold, determine that the image is not occluded and input the training set; the occlusion threshold is obtained by clustering the pixel value and the number of pixels in I0 using a clustering algorithm;
[0010] S4: inputting I1 into the training set to obtain the characteristic distribution of I1, and using the fitting algorithm to determine the characteristic distribution to obtain the closest characteristic distribution of I1 in the training set; repeatedly determining multiple groups of data, and continuously performing iterative training in the training set to obtain the final characteristic distribution T3;
[0011] S5: The feature distribution T3 is output as a final image I through a decoder F .
[0012] Furthermore, after collecting multiple groups of multi-angle images of the product, the step S1 also pre-processes the images.
[0013] Furthermore, the T1 and T2 include texture features of the image, and the extraction step includes extracting the image texture features of the grayscale image using a grayscale co-occurrence matrix method to obtain a grayscale co-occurrence matrix; and determining the grayscale co-occurrence matrix as the texture feature.
[0014] Furthermore, T1 and T2 include calculating the directional characteristics of image edge definition points using Hough transform.
[0015] Furthermore, in step S4, T3 of the closest I1 feature distribution in the training set is obtained by judging the degree of fitting, and the steps include S51: calculating the inference extension line of the edge definition point by Hough transform; S52: connecting the intersection points of the inference extension lines as the fitting boundary.
[0016] Further, the iterative training includes: the fitting boundary is decayed at a preset learning rate to obtain a second fitting boundary, and the preset learning rate is a pixel interval between the fitting boundary and the second fitting boundary;
[0017] Back up the fitting image within the fitting boundary and determine the characteristic distribution T3 of the fitting image;
[0018] Determine a fitting threshold corresponding to a fitting boundary;
[0019] Iterate training to a preset number of times, or
[0020] The preset learning rate decays to a preset value, or
[0021] The average clustered pixel feature of the fitted image is smaller than the feature distribution T3 corresponding to the training set in any iteration;
[0022] The fitting threshold corresponding to the current number of iterations is taken as the minimum fitting threshold.
[0023] Furthermore, after determining the minimum fitting threshold, the corresponding fitting boundary and the fitting image within the boundary are determined according to the minimum fitting threshold, and the final feature distribution T3 is determined.
[0024] A second aspect of the present invention provides an industrial heterogeneous visual recognition system, which is used to execute the above-mentioned industrial heterogeneous visual recognition method.
[0025] Compared with the prior art, the present invention has the following advantages: the image is preliminarily screened by occlusion and occlusion area ratio, and images with serious occlusion are excluded, which reduces the detection error rate on the one hand, and reduces the number of iterations in the training set in the later stage on the other hand, speeding up the image processing efficiency. Continuous iterative training is performed in the training set, and the pixel interval between the fitting boundary and the second fitting boundary is continuously reduced by a preset learning rate to obtain the minimum fitting threshold, thereby obtaining the best repaired image. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a flow chart of the method provided by the embodiment of the present invention. DETAILED DESCRIPTION
[0027] In order to be able to understand the features and technical contents of the embodiments of the present disclosure in more detail, the implementation of the embodiments of the present disclosure is described in detail below in conjunction with the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present disclosure. In the following technical description, for the convenience of explanation, a full understanding of the disclosed embodiments is provided through multiple details. However, one or more embodiments can still be implemented without these details. In other cases, to simplify the drawings, well-known structures and devices can be simplified for display.
[0028] Embodiment 1
[0029] This embodiment provides an industrial heterogeneous visual recognition method, such as Figure 1 As shown, cameras at different angles are used to take images of the product, and the images are preprocessed. The steps include: 1. graying the image. In this embodiment, the imread function of the OpenCV library is used to read the image, and the cvtColor function is used to convert it into a grayscale image. 2. The grayscale image is divided into multiple local areas, using a fixed-size block / elliptical window; 3. Histogram equalization is performed on each local area to obtain a locally enhanced image. This step includes
[0030] 3.1: Calculate the histogram using the following formula,
[0031] h(i)=n(i) / N
[0032] Where h(i) is the frequency of gray level i, n(i) is the number of pixels with gray level i in the image, and N is the total number of pixels in the image.
[0033] 3.2: Calculate the cumulative distribution function (CDF) using the following formula
[0034] cdf(i)=∑_{j=0}^{i}h(j)
[0035] Wherein, cdf(i) is the cumulative distribution function value of gray level i, and Σ represents the summation symbol.
[0036] 3.3: Use the following formula to map each gray level of the input image to a new gray level using CDF
[0037]
[0038] Among them, output_pixel is the pixel value of the output image, input_pixel is the pixel value of the input image, cdf_min and cdf_max are the minimum and maximum values of CDF respectively, max_output_level and min_output_level are the maximum and minimum grayscale levels of the output image respectively.
[0039] 3.4: Apply the mapping to each pixel of the input image to generate a histogram-equalized image. Input the image into the training set.
[0040] In the training set, the image is set with an image center definition point, which is scaled along a preset distance to obtain multiple edge definition points relative to the image middle definition point, thereby extracting multiple features T1 between the image middle definition point and the edge definition point, and extracting multiple features T2 between the multiple edge definition points, wherein T1 and T2 include texture features and directional features. In terms of texture feature extraction, the grayscale co-occurrence matrix method is used to extract image texture features from the grayscale image to obtain a grayscale co-occurrence matrix; the grayscale co-occurrence matrix is determined as the texture feature. Taking the image middle definition point and the edge definition point as an example, the steps include: assuming that the pixel value of the image middle definition point is (x, y) and the edge definition point is (x+a, y+b), the grayscale value between the two points is (g1, g2). Let the pixel point (x, y) move on the entire template image to obtain different grayscale values (g1, g2). Count the number of times each (g1, g2) value appears in all traversals, and normalize them to P(g1, g2) with the total number of (g1, g2) occurrences. The calculation formula is as follows:
[0041] P(g1,g2)=P(g1,g2) / R
[0042]
[0043] The angle between the line connecting the points and the 0 degree direction, N is the pixel point of the image, R is the total number of times g1, g2) appear, and a 3×3 sliding window is used to traverse all the pixel points of the template image. A 3×3 sliding window corresponds to 9 pixel points, corresponding to a P(g1, g2), and finally multiple P(g1, g2) are obtained to form the gray level co-occurrence matrix of the template image. The gray level co-occurrence matrix is the texture feature of the template image. Similarly, the texture features between multiple edge points can be obtained. In terms of directional feature extraction, the image is input into the Hough transform to obtain the directional relationship between the middle definition point and the edge definition point of the image. After extracting T1 and T2 from the image, that is, the feature relationship between the middle definition point and the edge definition point of the image, and the feature relationship between multiple edge definition points, the T1 and T2 features are combined to form a feature distribution T3, and multiple T3 features are used to form a training set. At the same time, the image with feature distribution T3 is set as the original image I0.
[0044] During the detection process, multiple heterogeneous images of the objects to be tested are collected and preprocessed. The preprocessing steps here are the same as step S1, that is, the images are grayed and enhanced to obtain image I1. The next step is to determine whether the image I1 is blocked and calculate and judge the proportion of the blocked area. First, a clustering algorithm is used to cluster the pixel values and the number of pixels in I0 to obtain the occlusion threshold. In this embodiment, we select the more common K-means clustering algorithm, randomly select multiple pixel values and the number of pixels as the initial clustering center, and assign each pixel to the nearest clustering center according to its pixel value and the number of pixels. The average pixel value or the average value of the number of pixels assigned to the cluster center is calculated as the new clustering center. When the cluster center no longer changes, the characteristic relationship between the corresponding average pixel value and the average number of pixels is the occlusion threshold.
[0045] I1 is divided into multiple local areas, and the average pixel value and the average number of pixels of each local area are calculated. The pixel value and the number of pixels are compared with the preset occlusion threshold. If it is lower than the occlusion threshold, it is determined that the image is occluded. The proportion of the number of pixels in the occluded area relative to the entire image is calculated, and the proportion is compared with the preset limit proportion. If it is higher than the limit proportion, it is input into the training set. If it is less than the limit proportion, it is judged to be unqualified and an unavailable alarm is issued. If it is higher than the occlusion threshold, it is judged that the image is not occluded and the training set is input. It is worth noting that the limit proportion here is artificially set and can be adjusted according to the inspection requirements of the product. In addition, when the image is judged to be unqualified and an unavailable alarm is issued, it is necessary to remove the product for manual secondary inspection. The purpose of this operation is to screen the products, remove the images with more serious occlusion, and reduce the amount of calculation when fitting the image later.
[0046] After the qualified I1 enters the training set, its fitting boundary needs to be calculated. The steps include: 1. Map the image edge definition points to the parameter space of the Hough transform, determine the corresponding straight line, and calculate its extension line through the following formula:
[0047] Assume that the endpoints of the line are P(x1, y1) and Q(x2, y2), then the length L of the extended line is:
[0048] (L=\sqrt{(x2-x1)^{2}+(y2-y1)^{2}})
[0049] The direction vector PQ of the extension line is (x1-x2), (y1-y2).
[0050] The inference extension lines thus obtained connect the intersection points of each inference extension line to form a fitting boundary.
[0051] The fitting image within the back-up fitting boundary is determined, the characteristic distribution T3 of the fitting image is determined, and the fitting threshold is determined. In this embodiment, the fitting threshold is the degree of fitting of the image calculated using the structural similarity algorithm. Structural similarity (SSIM) is an indicator to measure the similarity of two images, and its value range is [0, 1]. The closer the SSIM value is to 1, the more similar the two images are, and the higher the degree of fitting is. Its calculation formula is:
[0052] L(X, Y) = (2μ x μ y +C1) / (μ x 2 +μ y 2 +C1)
[0053] C(X, Y) = (2σ x σ y +C2) / (σ x 2 +σ y 2 +C2)
[0054] S(X, Y) = (σ xy +C3) / (σ x σ y +C3)
[0055]
[0056]
[0057]
[0058] SSIM(X,Y)=1(X,Y) * C(X, Y)* S(X, Y)
[0059] where μ x and μ y Respectively represent the mean of image X(I1) and Y(fitting image), σ x 2 and σ y 2 Represents the variance of images X and Y, σ XY Represents the covariance of images X and Y. C1, C2, and C3 are constants. In order to avoid the situation where the score is 0, C1 = (K1*L)2, C2 = (K2*L)2, and C3 = C2 / 2 are usually taken.
[0060] At the same time, the fitting boundary is iterated, that is, a preset learning rate is set, and the fitting boundary is decayed at the preset learning rate to obtain a second fitting boundary, the preset learning rate is the pixel interval between the fitting boundary and the second fitting boundary, and the second fitting boundary is decayed to the Nth fitting boundary at the preset learning rate. When the iterative training reaches a preset number of times or the preset learning rate decays to a preset value or the average clustered pixel feature of the fitting image is less than the feature distribution T3 corresponding to the training set in any iteration, the fitting threshold corresponding to the current number of iterations is taken as the minimum fitting threshold, and the Nth fitting boundary corresponding to the minimum fitting threshold is obtained, and the fitting image within the Nth fitting boundary, that is, the feature distribution T3 corresponding to the fitting image, is determined. Finally, the Nth fitting boundary and the feature distribution T3 are combined, and the final image I is output through the decoder. F .
[0061] At the same time, an industrial heterogeneous visual recognition system is provided, which is used to execute the method described above.
[0062] Embodiment 2
[0063] The difference between the second embodiment and the first embodiment is that when determining the fitting threshold, a root mean square error algorithm is used, and the steps are: the image X (I1) and Y (fitting image) are converted into the same size M*N by scaling and other processing, and the formula is:
[0064]
[0065] M is the image length, N is the image width, X is I1, Y is the noise image, where i, j are the horizontal and vertical coordinates of the M*N image.
[0066] The above description and accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent possible changes only. Unless explicitly required, separate components and functions are optional, and the order of operation may vary. The parts and features of some embodiments may be included in or replace the parts and features of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and claims, unless the context clearly indicates, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of listings containing one or more associated ones. In addition, when used in the present application, the term "comprise" and its variants "comprises" and / or comprising refer to the presence of stated features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the presence of other identical elements in the process, method or device comprising the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the various embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.
Claims
1. Industrial heterogeneous visual recognition methods, It is characterized in that Includes steps: S1: Collect multiple sets of product images from multiple angles and construct the original image I 0 Training set; S11: Set the middle definition point of the image, scale it along a preset distance, obtain multiple edge definition points about the middle definition point of the image, and extract multiple features T between the middle definition point and the edge definition point of the image 1 ; S12: Extracting multiple features T between the multiple edge definition points 2 ; S13: Combined with T 1 and T 2 Get the original image I 0 The characteristic distribution T 3 Composition of training set; S2: During the detection process, a heterogeneous image of the object to be detected is collected and preprocessed to obtain an image I 1 ; S3: Determine the I 1 Whether there is occlusion and calculate the proportion of the occlusion area; 1 Divide into multiple local areas, calculate the pixel value and the number of pixels in the local area, compare the pixel value and the number of pixels with a preset occlusion threshold, if it is lower than the occlusion threshold, determine that the image is occluded, calculate the proportion of the number of pixels in the occluded area, and compare the proportion with a preset limit proportion, if it is higher than the limit proportion, input the training set, if it is less than the limit proportion, determine it as unqualified, and issue an unavailable alarm; If it is higher than the occlusion threshold, the image is judged as unoccluded and input into the training set; The occlusion threshold is a clustering algorithm for 0 The pixel values and pixel numbers in are clustered and calculated; S4: I 1 Input the training set to get I 1 The characteristic distribution of the feature is judged by the fitting algorithm to get the closest I in the training set. 1 Feature distribution; Repeatedly judge multiple sets of data, continuously perform iterative training in the training set, and obtain the final feature distribution T 3 ; The fitting algorithm steps include S51: calculating the inference extension line of the edge definition point through Hough transform; S52: connecting the intersection of the inference extension lines as a fitting boundary; the iterative training includes: the fitting boundary is decayed at a preset learning rate to obtain a second fitting boundary, and the preset learning rate is the pixel interval between the fitting boundary and the second fitting boundary; Back up the fitting image within the fitting boundary and determine the characteristic distribution T of the fitting image 3 ; Determine a fitting threshold corresponding to the fitting boundary; Iterate training to a preset number of times, or The preset learning rate decays to a preset value, or The average clustered pixel feature of the fitted image is less than the feature distribution T corresponding to the training set in any iteration 3 ; Take the fitting threshold corresponding to the current number of iterations as the minimum fitting threshold; After determining the minimum fitting threshold, the corresponding fitting boundary and the fitting image within the boundary are determined according to the minimum fitting threshold to determine the final feature distribution T 3 ; S5: Distribute the features T 3 The decoder outputs the final image I F .
2. According to the industrial heterogeneous visual recognition method described in claim 1, It is characterized in that After collecting multiple groups of multi-angle images of the product, step S1 also pre-processes the images.
3. According to the industrial heterogeneous visual recognition method described in claim 1, It is characterized in that The T 1 and T 2 The invention comprises texture features of an image, and the extraction step comprises graying the multi-angle image into a gray image, extracting image texture features from the gray image using a gray co-occurrence matrix method to obtain a gray co-occurrence matrix; and determining the gray co-occurrence matrix as the texture feature.
4. According to the industrial heterogeneous visual recognition method described in claim 1, It is characterized in that The T 1 and T 2 This includes using Hough transform to calculate the directional characteristics of image edge definition points.
5. Industrial heterogeneous visual recognition system, It is characterized in that The system is used to perform the method according to any one of claims 1 to 4.
