Image defect target matching method and system based on geometric distance measurement
The geometric distance measurement method is used to determine the matching relationship of defects in power system inspection images, which solves the problem of repeated identification of the same defect in multiple images, improves the quality of inspection results and system efficiency, and reduces management costs.
Patent Information
- Application Number
- CN202410933584.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-07-12
AI Technical Summary
In power system inspections, repeated identification of the same defect in different inspection images leads to increased calculations and high management costs for the inspection system.
The image defect target matching method based on geometric distance measurement is used to construct the two-dimensional matrix of the defect target matching relationship and the distance measurement function matrix, which is converted into an optimal matching problem, and the optimal defect target matching relationship is solved to determine the repeated defects in the image. location.
It improves the quality and usability of image detection results, reduces system calculations and manual management costs, reduces misjudgments and missed detections, and improves detection accuracy and efficiency.
Smart Images

Figure CN118506030B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of target detection and discloses an image defect target matching method and system based on geometric distance measurement. Background Art
[0002] Electricity is one of the most important energy sources in the world today, and it is an important guarantee for maintaining the normal operation of people's various life and production activities. Therefore, the normal and stable operation of the power system is particularly critical. Power inspection is the core work to ensure the safe and reliable operation of the power system. By using drone systems to shoot power inspection equipment and using artificial intelligence algorithms to detect and locate equipment defects, faulty equipment in the power system can be discovered and handled in a timely manner, effectively preventing power failures and accidents, improving the reliability and stability of the power supply system, and thus ensuring the normal operation of people's production and life.
[0003] Although the automatic identification of defects in the line by artificial intelligence algorithms can significantly reduce the workload of manual verification of inspection images, the repeated detection of the same defect in different inspection images also further increases the cost of defect review and management. Specifically, in the process of line inspection, in order to fully discover the important defects in the towers, it is often necessary to take multiple shots of the same level of towers from multiple directions and angles, and then use artificial intelligence algorithms to analyze these inspection images to detect the defects in the images. However, in this process, it is inevitable that the same level of defects will be identified multiple times when photographed from multiple angles, and the same defect will be identified multiple times by the algorithm in multiple images, which is not only unnecessary, but also increases the computational workload of the detection system and the material and human costs of subsequent manual review and defect management. Summary of the invention
[0004] The purpose of the invention is to provide an image defect target matching method and system based on geometric distance measurement to solve the above-mentioned problems existing in the prior art.
[0005] The technical solution is an image defect target matching method based on geometric distance measurement, comprising the following steps:
[0006] S1, collect images of the same target from multiple angles and perform defect detection on each image;
[0007] S2. Based on the defect detection results, a two-dimensional matrix of defect-target matching relationship is constructed, and the two-dimensional matrix is transformed into an optimal matching problem through a distance metric function;
[0008] S3, obtaining the camera intrinsic parameter matrix and the position and posture relationship between cameras, and constructing a distance metric function matrix based on the defect detection results, the camera intrinsic parameter matrix and the position and posture relationship between cameras;
[0009] S4. Based on the distance metric function matrix, the optimal matching problem is solved to obtain the optimal defect-target matching relationship.
[0010] Image defect target matching system based on geometric distance measurement, including:
[0011] at least one processor; and,
[0012] a memory communicatively connected to at least one of the processors; wherein,
[0013] The memory stores instructions that can be executed by the processor, and the instructions are used to be executed by the processor to implement the image defect target matching method based on geometric distance measurement described in any of the above technical solutions.
[0014] Beneficial effect: The present invention finds repeated defects in the image by determining the matching relationship between defect targets, thereby improving the overall quality and availability of image detection results and effectively reducing the cost of system calculation, defect review and manual management. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a flow chart of the present invention.
[0016] Figure 2 This is a flow chart of step S1 of the present invention.
[0017] Figure 3 This is a flow chart of step S2 of the present invention.
[0018] Figure 4 This is a flow chart of step S3 of the present invention.
[0019] Figure 5 This is a flow chart of step S4 of the present invention. DETAILED DESCRIPTION
[0020] like Figure 1 As shown, the present application proposes an image defect target matching method based on geometric distance measurement, comprising the following steps:
[0021] S1, collect images of the same target from multiple angles and perform defect detection on each image;
[0022] S2. Based on the defect detection results, a two-dimensional matrix of defect-target matching relationship is constructed, and the two-dimensional matrix is transformed into an optimal matching problem through a distance metric function;
[0023] S3, obtaining the camera intrinsic parameter matrix and the position and posture relationship between cameras, and constructing a distance metric function matrix based on the defect detection results, the camera intrinsic parameter matrix and the position and posture relationship between cameras;
[0024] S4. Based on the distance metric function matrix, the optimal matching problem is solved to obtain the optimal defect-target matching relationship.
[0025] This embodiment can obtain a comprehensive view of the surface defects of the target by collecting target images from multiple angles and performing defect detection. This multi-angle method helps to reduce omissions and misjudgments that may be caused by a single perspective; by constructing a two-dimensional matrix of defect target matching relationships and using a distance metric function, the defect detection result is converted into an optimal matching problem, so that the actual defect features can be converted into a mathematical expression that can be processed by the algorithm. The distance metric function measures the distance between any two defect targets detected by the detection algorithm, accurately determines the matching relationship between the same defect targets in different images, and helps to improve the accuracy and reliability of defect detection, and reduce misjudgments and missed detections; obtain the camera intrinsic parameter matrix and the inter-camera posture relationship, where the intrinsic parameter matrix contains information such as the focal length and principal point coordinates of the camera, and the inter-camera posture relationship describes the spatial position and direction between cameras under different viewing angles. The accurate acquisition of this information enables images taken from different angles to be correctly corrected and fused; by solving the optimal matching problem through the distance metric function matrix, the best defect target matching relationship can be determined, and repeated defects in the image can be found, which improves the overall quality and availability of the image detection results and effectively reduces the cost of defect review and manual management.
[0026] This embodiment achieves comprehensive image acquisition through multi-angle acquisition, ensures matching accuracy through precise calculation of distance measurement function and camera parameters, automates the entire process to reduce manual intervention and improve efficiency, and solves the optimal matching problem to ensure the reliability of the results.
[0027] like Figure 2 As shown, according to one aspect of the present application, step S1 is further:
[0028] S11. Use a drone to shoot the same target from multiple angles along a predetermined path to obtain images from multiple angles;
[0029] S12, preprocessing images at multiple angles;
[0030] S13, using a defect detection algorithm to extract defect features in each preprocessed image to form a defect detection frame set;
[0031] S14: Determine the matching relationship of the defect targets in the defect detection frame set.
[0032] In a specific embodiment, a camera on a drone is used to shoot the same target from multiple angles to obtain images I1, I2, ...I N , where N is the total number of the same target image, Ii is the i-th image captured. In the application scenario of this application, the target specifically refers to the line tower. The image is preprocessed, including histogram equalization, segmentation of abnormal points and removal of noise. Based on the defect detection algorithm, the defects in each image are detected respectively, and the defect features are extracted to obtain the defect detection frame set {b 11 , b 12 , ..., b imi}. Among them, m i is the number of defects detected in the i-th image; b imi Denotes the detection box of each defect detected in the i-th image. Determine the correspondence between the defects detected in these different images, that is, find out which defects detected in different images are the same.
[0033] This embodiment uses a drone for multi-angle shooting, which can cover more surface areas of the target object, especially for large or irregularly shaped targets. The flexibility and maneuverability of the drone make it possible to acquire images from angles that are difficult to reach manually, which is crucial for comprehensive detection of surface defects of the target object. Image preprocessing is a key step in image analysis, which includes operations such as denoising, contrast enhancement, and edge detection. These operations help improve image quality, highlight defect features, and provide clearer and more accurate input data for subsequent defect detection algorithms. The defect features are extracted using a defect detection algorithm, and this step is the core of the entire process. Through algorithm analysis, the defect position and morphology in the image can be accurately identified to form a defect detection frame set. This not only improves the accuracy of detection, but also provides a reliable basis for subsequent matching and analysis. By comparing the defect features in different images, the corresponding relationship of the same defect under different viewing angles can be identified.
[0034] like Figure 3 As shown, according to one aspect of the present application, step S2 is further:
[0035] S21. Based on the defect detection results, a two-dimensional matrix of defect-target matching relationships is constructed, and constraints of the two-dimensional matrix are confirmed;
[0036] S22. The similarity of defect targets is quantified by a distance measurement function, and based on the similarity, the two-dimensional matrix is transformed into an optimal matching problem.
[0037] In this embodiment, a two-dimensional matrix is first constructed to represent the defect-target matching relationship. The shape of the two-dimensional matrix M is defined as m1×m2, and the matrix element M is set ij =1 means match, M ij =0 means no match, set the constraint condition as:
[0038] ∑ j=1m2 M ij ≤1
[0039] ∑ i=1 m1 M ij ≤1
[0040] Where m1 represents the number of defects detected in the first image, m2 represents the number of defects detected in the second image, and M ij Indicates whether the i-th defect in the first image matches the j-th defect in the second image.
[0041] Define the distance metric function and set the distance metric function to D(b i , b j ), the following conditions are met:
[0042] If b i With b j are the same target, then the distance metric function D(b i , b j ) is smaller; if b i With b j If they are not the same target, then the distance metric function D(b i , b j ) is larger; b i With b j The more similar, the distance metric function D(b i , b j ) is smaller.
[0043] Convert the defect target matching problem into an optimization problem:
[0044] min M ∑ i=1 m1 ∑ j=1 m2 D(b i , b j )M ij ;
[0045] st ∑ j=1 m2 M ij ≤1;
[0046] ∑ i=1 m1 M ij ≤1;
[0047] M ij ∈{0,1};
[0048] Among them, b i represents the detection box of each defect detected in the i-th image, bj represents the detection box of each detected defect in the jth image.
[0049] like Figure 4 As shown, according to one aspect of the present application, step S3 is further:
[0050] S31, based on the defect detection result, determining the center point coordinates of each defect detection frame;
[0051] S32, obtaining a camera intrinsic parameter matrix, and based on the camera intrinsic parameter matrix, converting the coordinates of each center point into a three-dimensional space straight line in a different coordinate system;
[0052] S33, obtaining the posture relationship between cameras, and based on the posture relationship between cameras, converting the three-dimensional space straight lines in different coordinate systems to the same coordinate system;
[0053] S34. Calculate the shortest distance of a straight line in three-dimensional space under the same coordinate system, and construct a distance measurement function matrix based on the shortest distance.
[0054] In a further embodiment, the camera intrinsic parameter matrix K and the inter-camera pose relationship R,t are first obtained; the coordinates of the center point of the defect detection frame are calculated as:
[0055] p1=(u1,v1)
[0056] p2=(u2,v2)
[0057] Where p1 represents the coordinates of the center point of a defect detection frame, (u1, v1) represents the coordinates of a defect detection frame on the image plane, p2 represents the coordinates of the center point of another defect detection frame, and (u2, v2) represents the coordinates of another defect detection frame on the image plane.
[0058] Convert the center point to a straight line in three-dimensional space. The straight line in the first camera coordinate system is:
[0059] l1={o1,d′1}
[0060] Where o1 represents the starting point of the straight line in the first three-dimensional space, and d'1 represents the direction vector of the straight line in the first three-dimensional space;
[0061] The straight line in the second camera coordinate system is:
[0062] l2={o2,d'2}
[0063] Where o2 represents the starting point of the straight line in the second three-dimensional space, and d'2 represents the direction vector of the straight line in the second three-dimensional space;
[0064] Convert l2 to the first camera coordinate system:
[0065] l2'={Ro2+t,Rd'2}
[0066] Where R represents the rotation matrix of the position relationship between cameras, and t represents the translation vector of the position relationship between cameras;
[0067] Calculate the shortest distance between two straight lines l1 and l2' as a metric function:
[0068] D(b i , b j )=min λ1,λ2 ∣(o1+λ1d'1)-(Ro2+t+λ2Rd'2)∣ 2
[0069] Where λ1 represents the scalar parameter along the line l1, and λ2 represents the scalar parameter along the line l2';
[0070] The metric function is converted into a metric matrix D[i, j], where D[i, j] = D(b i , b j ), D[i, j] represents the distance between the i-th defect in the first image and the j-th defect in the second image.
[0071] like Figure 5 As shown, according to one aspect of the present application, step S4 is further:
[0072] S41. Construct a bipartite graph based on the distance metric function matrix and the optimal matching problem;
[0073] S42, calculating the Laplacian matrix of the bipartite graph, and based on the Laplacian matrix, using the k-means clustering method to obtain a predetermined number of subgraphs;
[0074] S43, matching each subgraph, and merging the matching results of all subgraphs;
[0075] S44. Based on the matching results, a consistency graph is constructed, and the global consistency of the consistency graph is optimized using a simulated annealing algorithm to obtain an optimized result, which is the optimal defect-target matching relationship.
[0076] In a specific embodiment, a bipartite graph G = (U, V, E) is constructed, where U represents the defect set in the first image, V represents the defect set in the second image, and E represents the edge set. For each pair of defects (i, j), if the distance metric function matrix D [i, j] is less than the threshold τ, an edge e (i, j) is added, and the edge weight w (i, j) = 1 / (D [i, j] + ε), where ε is a small positive number to prevent division by zero. Spectral clustering is applied to the bipartite graph G, and the Laplacian matrix of the bipartite graph is calculated:
[0077] L'=DA
[0078] where D is a metric function matrix and A is an adjacency matrix;
[0079] Calculate the eigenvectors corresponding to the predetermined minimum eigenvalues of the Laplacian matrix L', and form a matrix X;
[0080] Perform k-means clustering on the rows of the matrix X to obtain K' subgraphs {G1, G2,..., G K '}; Perform matching on each subgraph, initialize the matching set M k ', and repeat until no new match can be found. Find the edge e(i, j) with the largest weight in the current subgraph, add the defect (i, j) to the matching set M k ', remove the vertex defects i and j and their associated edges from the subgraph, and update the weights of the remaining edges:
[0081] w'(p, q) = w(p, q) + λ·(w(p, i) + w(q, j))
[0082] where w(p, q) is the weight of the edge e(p, q), representing the relationship strength between the defects p and q in the image, w(p, i) represents the weight of the edge from the defect p to the defect i, w(q, j) represents the weight of the edge from the defect q to the defect j, and λ is a small positive number used to consider the proximity relationship; Combine the matching results of all subgraphs:
[0083] M* = ∪ k 'M k '
[0084] where ∪ k ' represents the union operation on the matching sets in all subgraphs;
[0085] Perform global consistency optimization to construct a consistency graph G c , with vertices being matching pairs and edges representing the consistency between matching pairs; Use the simulated annealing algorithm to optimize the global consistency, initialize the temperature T* = T0, and repeat until T* < T min , randomly select a matching pair, attempt to exchange it with other unmatched defects, calculate the consistency score ΔE before and after the exchange. If ΔE > 0 or random() < exp(ΔE / T*), accept the exchange; Decrease the temperature, T* = α·T*, where 0 < α < 1; Return the final matching result M". Here, random() represents a random number generation function used for the random selection process in the simulated annealing algorithm; exp() represents the exponential function used for calculating the probability part in the simulated annealing algorithm to determine whether to accept a new match; α represents the cooling coefficient in the simulated annealing algorithm used to gradually decrease the temperature T* to help the algorithm converge to the optimal solution.
[0086] This embodiment can directly utilize the powerful tools of graph theory by converting the metric matrix into a graph problem; spectral clustering helps to deal with large-scale matching problems and decompose them into more manageable sub-problems; the iterative optimization process takes into account local and global consistency, which helps to improve the matching quality; the introduction of the simulated annealing algorithm enables the algorithm to escape from the local optimum and find the global optimal solution.
[0087] According to one aspect of the present application, step S11 further includes optimizing the shooting angle of the drone using an adaptive sampling algorithm based on information entropy, specifically:
[0088] S11a, based on each shooting angle, construct an initial sampling point set, each sampling point represents a shooting angle;
[0089] S11b, calculating the information gain of each sampling point, and selecting the sampling point with the largest information gain;
[0090] S11c, based on the sampling point with the largest information gain, update the initial sampling point set;
[0091] S11d, repeating steps S11d to S11c until the information gain is lower than a preset threshold, and outputting an updated sampling point set.
[0092] In a further embodiment, the sampling point set S={s1, ..., s n}, each point represents a potential shooting position and angle; for each sampling point s i , calculate its information gain:
[0093] IG(s i ) = H(X)-H(X|s i )
[0094] Where H(X) represents the entropy of the current image set, H(X|s i ) indicates adding sampling point s i The conditional entropy after ; select the sampling point with the largest information gain:
[0095] s*=argmax i IG(s i )
[0096] Where argmax means finding the value of the variable that makes the given function reach the maximum value;
[0097] Update the sampling point set:
[0098] S=S∪s*
[0099] Where ∪ represents the union operation of sets;
[0100] The above steps are repeated until the predetermined number of samples is reached or the information gain is lower than the threshold.
[0101] Furthermore, reinforcement learning algorithms can be used to optimize drone shooting angles and paths to obtain optimal image coverage.
[0102] Define the state space S': including the position and orientation of the drone, the three-dimensional model of the power equipment, etc.
[0103] Define the action space A: including movement direction, camera angle adjustment, etc.
[0104] Define the reward function R:
[0105] R(s',a)=w1·coverage+w2·image quality-w3·energy consumption
[0106] Among them, s' represents the state of the state space S', a represents the action in the action space A, w1 represents the weight of the coverage, which is calculated by the ray tracing algorithm, w2 represents the weight of the image quality, which takes into account the clarity and lighting conditions, and w3 represents the weight of the energy consumption, which is estimated based on the flight distance.
[0107] Use the Proximal Policy Optimization (PPO) algorithm to train the policy network ξ(a|s'). The policy network is a conditional probability distribution, which is the probability of selecting action a given state s'.
[0108] The strategy network structure is: 3D convolutional neural network + long short-term memory network, which means that the 3D convolutional neural network processes spatial information and the long short-term memory network processes time series information;
[0109] The loss function is:
[0110] L(θ)=E"[min(r(θ)A",clip(r(θ),1-ε,1+ε)A")]-β·KL[ξ old ,ξ new ]
[0111] Where E″ represents the average of all possible states and actions, r(θ) represents the ratio of the probability of selecting action a under the new strategy to the probability of selecting action a under the old strategy, θ is the parameter of the policy network, A″ represents the advantage function estimation, which evaluates the advantage of selecting action a relative to the average action, clip(r(θ), 1-ε, 1+ε) represents the clipping operation of the probability ratio, which limits r(θ) to the range of [1-ε, 1+ε)] to avoid excessive policy updates, ε represents a small positive number, β represents the weight of the regularization term, KL represents the relative entropy, ξ old represents the old policy network, ξ newrepresents the new policy network;
[0112] r(θ)=ξ new (a|s') / ξ old (a|s')
[0113] In actual inspections, the drone path and shooting angle are dynamically adjusted according to the trained strategy network.
[0114] According to another aspect of the present application, step S12 is further:
[0115] S121, dividing the image at each angle into a predetermined number of rectangular blocks of equal size, calculating the histogram of each rectangular block, and determining the grayscale level of the histogram;
[0116] S122, based on a preset clipping threshold, clipping the histogram of each rectangular block to obtain a clipped histogram;
[0117] S123, calculating a cumulative distribution function based on the clipped histogram;
[0118] S124, calculating a mapping function based on the cumulative distribution function and the gray level number;
[0119] S125. Based on the mapping function, interpolate each pixel in the image to obtain an interpolated image, which is the preprocessed image.
[0120] In a further embodiment, a Contrast Limited Adaptive Histogram Equalization (CLAHE) algorithm is applied to perform adaptive histogram equalization. The input image I (x, y) is divided into rectangular blocks B of equal size. i , assuming that each block size is 8x8 pixels; for each block B i , calculate its grayscale histogram H i (g), where g∈[0, L-1] represents the grayscale level, L is the number of grayscale levels (usually 256); the histogram is cropped, and the cropping threshold is set to T (usually 1% of the total number of pixels). For each grayscale histogram H i (g)
[0121] If H i (g)>T: excess=H i (g)-TH i (g) = T
[0122] Where excess represents the histogram count exceeding the threshold T;
[0123] Distribute the excess equally to all gray levels:
[0124] For each gray level: H i (g)+=excess / L
[0125] Calculate the cumulative distribution function (CDF):
[0126] CDF i (g)=∑ k=0 g H i (k) / (total number of pixels in the block)
[0127] Where k represents the gray level variable;
[0128] Calculate the mapping function:
[0129] M i (g)=round((L-1)·CDF i (g))
[0130] Where round() represents the rounding function;
[0131] Interpolate each pixel. For each pixel (x, y) in the image, determine the four adjacent blocks B1, B2, B3, B4 to which it belongs; calculate the distance d1, d2, d3, d4 from the pixel to the center of each block; use bilinear interpolation to calculate the final mapping value:
[0132] I new (x,y)=∑ i=1 4 w i ·M i (I(x,y))
[0133] Among them, w i =(1-d i / (d1+d2+d3+d4)) represents the weight factor, and the output result image I new (x, y).
[0134] Furthermore, the Otsu threshold method can be used to segment outliers. First, the image histogram is calculated, and each pixel in the image I (x, y) is traversed to count the number of pixels n at each gray level g. g , calculate the probability:
[0135] p(g)=n g / (total number of pixels in the image), g∈[0,L-1]
[0136] Initialize variables, total mean μT=∑ g=0 L-1 g·p(g); between-class variance σ B 2=0; optimal threshold t*=0; traverse all possible thresholds t', t'∈[0, L-2], and calculate the probability and mean of the background class (pixels less than or equal to t'):
[0137] w0(t')=∑ g=0 t' p(g)
[0138] μ0(t')=∑ g=0 t' g·p(g) / w0(t')
[0139] Calculate the probability and mean of the foreground class (pixels greater than t'):
[0140] w1(t')=1-w0(t')
[0141] μ1(t')=(μT-w0(t')·μ0(t')) / w1(t')
[0142] Calculate the between-class variance:
[0143] σ B 2 (t')=w0(t')·w1(t')·(μ0(t')-μ1(t')) 2
[0144] Update the optimal threshold to:
[0145] If σ B 2 (t')>σ B 2 :σ B 2 =σ B 2 (t')t*=t'
[0146] Use the optimal threshold to binarize the image. For each pixel I(x, y) in the image: if I(x, y) <= t': I new (x, y) = 0 ∥ background; otherwise I new (x, y) = 1 ∥ foreground, output binary image I new (x, y).
[0147] Furthermore, the noise can be removed by statistical outlier removal (SOR). i , calculate point p i The average distance d to its k nearest neighbors i ; Calculate the mean μ' and standard deviation σ' of all average distances; For each point p i: If |d i -μ'∣>α*σ': point p i Marked as an outlier; where α* represents a multiplier, which is used to define the strictness of outlier judgment; otherwise, point p is retained i ; Remove all points marked as outliers.
[0148] According to another aspect of the present application, step S13 is further:
[0149] S131, performing edge detection on each preprocessed image, and based on the edge detection result, using a discrete Fourier transform method to calculate the amplitude of a discrete Fourier transform coefficient as a shape feature of the defect;
[0150] S132, based on each preprocessed image, using the gray level co-occurrence matrix to calculate the Haralic features of the gray level distribution, including angular second moment, contrast, correlation, entropy and inverse difference moment;
[0151] S133, based on each preprocessed image, calculating local binary pattern features of different scales;
[0152] S134, forming texture features of defects based on Harald features and local binary pattern features;
[0153] S135. Combine the shape features and texture features of the defect to form a defect detection frame set.
[0154] In a specific embodiment, shape features are first extracted, and the contour is represented by a Fourier descriptor. Edge detection (such as the Canny algorithm) is performed on the defect area image, and a contour tracking algorithm (such as Moore-Neighbor tracking) is used to extract the closed contour; the contour is sampled into N points (usually N=64 or 128) at equal intervals to obtain a sampling point sequence: (x[0], y[0]), (x[1], y[1]), ..., (x[N-1], y[N-1]); the sampling points are converted into complex form: z[n]=x[n]+j'·y[n], n=0, 1, ..., N-1, representing the index of the sampling point; the complex sequence is subjected to discrete Fourier transform (DFT):
[0155] F[k*]=(1 / N)·∑ n=0 N-1 z[n]·exp(-j′2πk*n / N), k*=0, 1,..., N-1
[0156] Where j' represents the imaginary unit, π represents the circumference of a circle, and k* represents the frequency index in the discrete Fourier transform;
[0157] Calculate the amplitude of the Fourier coefficient |F[k*]| and normalize the amplitude:
[0158] D[k*]=∣F[k*]∣ / ∣F[0]∣, k*=1, 2,...,N / 2
[0159] Where F[0] represents the center position of the contour;
[0160] Select the first M coefficients as Fourier descriptors (usually M = 10 or 20);
[0161] Ignore the contour center position F[0] and use the amplitude spectrum |F[k*]| as the feature to achieve rotation invariance.
[0162] Then, texture features are extracted, and Harald features and local binary patterns (LBP) are calculated. Gray-level co-occurrence matrix (GLCM) is calculated and the image is quantized into N g Grayscale (usually N g =8 or 16); define the distance d and direction θ* (usually d=1, θ*=0°, 45°, 90°, 135°); for each direction, calculate the gray level co-occurrence matrix P(i, j), where P(i, j) represents the number of times a pixel with gray level i has a pixel with gray level j at the distance d and direction θ*;
[0163] Normalize the gray-level co-occurrence matrix:
[0164] P norm (i, j) = P (i, j) / ∑ i,j P(i, j)
[0165] Calculate the Hararik characteristic, the angular second moment (ASM) as:
[0166] f1=∑ i,j P norm (i, j) 2
[0167] The contrast ratio is:
[0168] f2=∑ i,j (ij) 2 ·P norm (i, j)
[0169] The correlation is:
[0170] f3=∑ i,j (ij)·P norm (i, j)-(μ x ·μ y ) / (σ x ·σ y )
[0171] where μ x , μ y , σx , σ y are the mean and standard deviation of the marginal distribution, respectively;
[0172] Entropy is:
[0173] f4=-∑ i,j P norm (i, j)·log(P norm (i, j))
[0174] The inverse difference moment (IDM) is:
[0175] f5=∑ i,j P norm (i, j) / (1+(ij) 2 )
[0176] Take the average of the features calculated in different directions to obtain the rotation-invariant features;
[0177] Calculate the local binary pattern (LBP) feature. First, calculate the basic LBP feature. For each pixel in the image, consider its 3x3 neighborhood, use the central pixel value as the threshold, and binarize the neighborhood pixels. If the neighborhood pixel value is greater than or equal to the central pixel value, it is 1; otherwise, it is 0; the binarization result is serialized clockwise into an 8-bit binary number, and converted to a decimal number as the local binary pattern value of the pixel.
[0178] Calculate circular LBP extension features. Define the sampling radius and number of sampling points (common combinations such as (1, 8), (2, 16), (3, 24)); for sampling points that are not on the pixel grid, use bilinear interpolation to calculate the grayscale value;
[0179] Calculate the rotation-invariant LBP feature. For each LBP code, take the minimum value among all its cyclic shifts as the rotation-invariant LBP feature of the pixel.
[0180] Calculate the equivalent pattern LBP features. Define "equivalent pattern" as a pattern with no more than 2 0 / 1 transitions in a cyclic binary sequence; classify all non-equivalent patterns into one category, and get the number of sampling points + 2 patterns.
[0181] Calculate the LBP histogram. Calculate the LBP values of all pixels in the image; calculate the histogram of the LBP values, and normalize the histogram to obtain the texture feature vector.
[0182] The basic LBP features, circular LBP extension features, rotation-invariant LBP features, equivalent pattern LBP features, and LBP histogram are connected to form the final texture descriptor.
[0183] Furthermore, the statistical moments (mean, variance, skewness, kurtosis) of the pixel intensity in the region are calculated as statistical features to construct the defect feature vector: F i =[F shape , F texture , F stat ], where F shape represents the shape feature vector, F texture represents the texture feature vector, F stat Represents a statistical feature vector; principal component analysis (PCA) is used to reduce the dimension of the defect feature vector, retaining 95% of the variance information. PCA is a statistical method that transforms possibly correlated variables into a set of linearly uncorrelated variables, called principal components, through orthogonal transformation. In this process, retaining 95% of the variance information means retaining only those principal components that contribute the most, which can reduce the dimension of the data while retaining the most important information, thereby simplifying the model and improving computational efficiency.
[0184] According to another aspect of the present application, step S34 also includes optimizing the distance metric function matrix, specifically:
[0185] S34a, based on the defect detection results, the camera internal parameter matrix and the position and posture relationship between cameras, estimate the three-dimensional position coordinates of the defect target in the same coordinate system, and calculate the covariance matrix of the three-dimensional position coordinates;
[0186] S34b, based on the defect detection results, construct a defect appearance feature extraction model, and calculate the appearance similarity of the defect target;
[0187] S34c, based on the defect detection result, construct a local image block around the defect target, and extract context features of the local image block;
[0188] S34d, weighting and fusing the covariance matrix, appearance similarity and context features to form a distance metric function matrix.
[0189] In a specific embodiment, a geometric distance measurement of fusion uncertainty estimation is performed. The improved bundle adjustment algorithm is used to optimize the camera parameters and the 3D point positions, and for each defect target, the covariance matrix of its 3D position is estimated:
[0190] ∑ i D geo (b i , b j )=(p' i -p' j ) T (∑ i +∑ j ) -1 (p'i -p' j )
[0191] Where D geo Represents geometric distance; define Mahalanobis distance as a geometric distance metric, where p' i and p' j is the estimated 3D position of the defect target, T Represents matrix transpose.
[0192] Construct and use the simple twin (SimSiam) self-supervised learning method to train the defect appearance feature extraction model:
[0193] D app =1-cosine similarity (f(b i ), f(b j ))
[0194] Where D app Indicates the appearance similarity between defect targets; cosine similarity Represents cosine similarity, which is used to measure the similarity between two vectors. i ) and f(b j ) represent defect targets b i and b j The eigenvector of
[0195] Construct local image patches around the defect and use NetVLAD to extract context features:
[0196] D ontext =L2 distance (NetVLAD(context(b i )), NetVLAD(context(b j )))
[0197] Where D context represents the contextual consistency between defect targets, NetVLAD represents the neural network architecture for extracting image context features, L2 distance Represents the Euclidean distance, which is used to calculate the distance between two feature vectors. context(b i ) and context(b j ) represent defect targets b i and b j The surrounding local image patches;
[0198] Combining geometric distance, appearance similarity and contextual consistency:
[0199] D'(b i , b j) = w '1 · D geo +w'2 · D app +w'3 · D context
[0200] Among them, D'(b i , b j ) represents the total distance metric that integrates geometric distance, appearance similarity and contextual consistency. w'1, w'2 and w'3 represent the weights of geometric distance, appearance similarity and contextual consistency respectively. The weights w'1, w'2, w'3 are trained by Batch Hard Triplet Loss.
[0201] This application analyzes multiple images based on a defect deduplication algorithm, successfully identifies repeated defect problems in the images, and effectively reduces defect review and manual management costs.
[0202] In another embodiment, an image defect target matching method based on geometric distance measurement includes the following steps:
[0203] S1. Describe the correspondence between target defects detected by multiple images taken from multiple angles of the same target based on a mathematical model;
[0204] S2, before considering more complex multiple images, use a two-dimensional matrix to model the target defect matching problem between image pairs; further, given images I1, I2 and detected target b 1,1 , b 1,2 , …b 1,n1 , b 2,1 , b 2,2 , …b 2,n2 , the defect target matching problem between image pairs is transformed into a standard two-dimensional matrix matching problem; based on the geometric defect target distance measurement method, the repeated defect matching problem between image pairs is solved;
[0205] S3. For defect matching between any number of images, the defect targets detected between all images can be paired with each other to obtain the matching relationship between the defect targets.
[0206] In a further embodiment, a specific description is given based on the problem of image defect deduplication. Multiple images of the same target taken from multiple angles are used to detect the target using a defect detection algorithm, and the corresponding relationship between the same defects in different images of the same target is determined, specifically:
[0207] S11. Assume that the camera takes photos of the same target from multiple angles and obtains images I1, I2…I N , where N is the total number of the same target image, I iis the i-th image captured. In the application scenario of the present invention, the target specifically refers to the line tower;
[0208] S12, based on the defect detection algorithm, the defects in the N images are detected respectively to obtain the defect detection frame { b 1,1 , b 1,2 , …, b 1,n1 , b 2,1 , b 2,2 , …b 2,n2 …b N,nN}. In the i-th image, the defect detection algorithm detected a total of n i different defects, record n detected in the i-th image i The defects are b i,1 , b i,2 , …b i,ni ;
[0209] S13. The solution to image defect deduplication is to determine the correspondence between the defects detected in different images, that is, to find out which defects detected in different images are the same.
[0210] Before solving the defect matching problem between complete and complex images, the defect target matching problem between two images is solved based on the repeated defect matching algorithm, specifically:
[0211] S21, in order to find the matching relationship between the defects of the two sets of images, suppose the defect targets detected in the two images I1 and I2 are b 1,1 , b 1,2 , …, b 1,n1 , b 2,1 , b 2,2 , …b 2,n2 . Define a two-dimensional matrix M with a shape of n1×n2 1,2 To represent the matching relationship between the defect targets detected by images I1 and I2:
[0212] M 1,2 (m, n) = 1, if b 1,m and b 2,n match
[0213] M 1,2 (m, n) = 0, others
[0214] where b 1,m represents the m defect targets detected in the first image, b 2,n represents the n defect targets detected in the second image;
[0215] Obviously, a certain target detected in image I1 cannot be associated with multiple targets detected in image I2 at the same time, and vice versa. Therefore, the matrix M 1,2 The following two conditions must be met:
[0216] ∑ m=1 n1 M 1,2 (m, n)≤1, ∧n=n1, n2,…n n2
[0217] ∑ n=1 n2 M 1,2 (m, n)≤1, ∧m=n1, n2,…n n1
[0218] Where ∧ represents all.
[0219] S22, quantify the similarity of defect targets in a given pair of images through a distance metric function, thereby determining a binary two-dimensional matrix. Specifically, assume that there is a distance metric D, for any two images I1 and I2, and two groups of defect targets b detected in the two images, respectively 1,m and b 2,n , can quantify the similarity D(I1, I2, b 1,m , b 2,n ), and satisfy:
[0220] 1. If defect target b 1,m With defect target b 2,n is the same goal, then the metric D(I1, I2, b 1,m , b 2,n ) is smaller;
[0221] 2. If defect target b 1,m With defect target b 2,n are not the same target, then the metric D(I1, I2, b 1,m , b 2,n ) is larger;
[0222] 3. If defect target b 1,m With defect target b 2,n The more similar, the metric value D(I1, I2, b 1,m , b 2,n ) is smaller;
[0223] Defined by mathematical relations:
[0224] D 1,2 (m,n) = D(I1,I2,b 1,m , b 2,n), ∧m=1,2,…,n n1 , ∧n=n1,n2,…,n n2
[0225] The defect target matching problem between image pairs is further transformed into an optimization problem. By determining an optimization target, the binary two-dimensional matrix M is determined. 1,2 :
[0226] min M1,2 ∑ m=1 nn1 ∑ n=1 nn2 D 1,2 (m, n) M 1,2 (m, n)
[0227] M 1,2 (m, n) ∈ {0, 1}, ∧m=1, 2,…, n n1 , ∧n=n1,n2,…,n n2
[0228] ∑ m=1 n1 M 1,2 (m, n)≤1, ∧n=n1, n2,…n n2
[0229] ∑ n=1 n2 M 1,2 (m, n)≤1, ∧m=n1, n2,…n n1
[0230] S23, the defect target matching problem between image pairs is solved by using the classic Jonker-Volgenant algorithm to solve a standard bipartite graph matching problem. Specifically, determining the metric function D is the key to transforming the defect target matching problem between image pairs into an optimization standard problem. The present invention proposes a geometry-based distance metric method to measure the distance between any two detected defect targets. Assume that the internal parameters of the camera taking the two images I1 and I2 are:
[0231]
[0232] Among them, f x , f y It represents the focal length of the camera, with the number of horizontal and vertical pixels of the camera as the unit respectively; u and v represent the position of the optical center of the camera, with pixels as the unit.
[0233] Assume that the shooting posture relationship between the two cameras is R 1,2 , t 1,2 , where R1,2 The rotation matrix representing the pose transformation between the two cameras, t 1,2 The translation vector representing the position transformation between the two cameras. The above information can be read and calculated from the Exif information in the file;
[0234] For the defect detection frame b 1,m and defect detection box b 2,n , respectively record b 1,m and b 2,n The center coordinates of the two defect target detection frames are (x 1,m ,y 1,m ) and (x 2,n ,y 2,n ). Any pixel in an image can correspond to a straight line in the three-dimensional world, so the center point (x 1,m ,y 1,m ) and (x 2,n ,y 2,n ) can induce two straight lines in the three-dimensional world, and the shortest distance between these two straight lines is used to represent the distance metric between the two target detection frames. Specifically, the detection frame b 1,m The center point (x 1,m ,y 1,m ) is expressed in the first camera coordinate system as:
[0235] o1=(0,0,0) T , r1=K -1 [x 1,m ,y 1,m , 1]
[0236] Where o1 represents the origin of the line, and r1 represents the direction of the line.
[0237] Similarly, the detection box b in the second image 2,n The center point (x 2,n ,y 2,n ) is expressed in the second camera coordinate system as:
[0238] o2=(0,0,0) T , r2=K -1 [x 2,n ,y 2,n , 1]
[0239] Where o2 represents the origin of the line, and r2 represents the direction of the line.
[0240] However, the two straight lines calculated above are in the coordinate system of their respective cameras. In order to calculate the distance between the two straight lines, the two straight lines need to be converted to the same coordinate system for representation. 2,n The induced straight line is transformed into the coordinate system of the first camera:
[0241] o'2=t 1,2 , r'2=R 1,2 r2
[0242] Where o'2 and r'2 represent the origin and direction of the line in the first camera coordinate system respectively;
[0243] Then, the metric function is defined as:
[0244] D(I1,I2,b 1,m , b 2,n )=min λ3,λ4 ∣∣(o1+λ3 r1)- (o'2+λ4 r'2) ∣∣ 2
[0245] Among them, ∣∣ ∣∣ 2 represents the square of the vector 2 norm, λ3 represents the scalar parameter along the line r1, and λ4 represents the scalar parameter along the line r'2;
[0246] Furthermore, the metric function is expressed in matrix form as:
[0247] D(I1,I2,b 1,m , b 2,n )=min λ3,λ4 ∣∣(o1- o'2)+ [ r1- r'2] [λ3, λ4]∣∣ 2
[0248] Let O = (o1 - o'2), R = [r1 - r'2], ∏ = [λ3, λ4], and find the optimal solution of ∏;
[0249] ψ D(I1,I2,b 1,m , b 2,n ) / ψ∏=R T (R∏+O)=0
[0250] Where ψ represents the partial derivative;
[0251] The solution is:
[0252] ∏=-(R T R) -1 R T O
[0253] Substituting the ∏ expression into the matrix form of the metric function, we get:
[0254] D(I1,I2,b 1,m , b 2,n ) = ∣∣(IR (R T R) -1 R T ) O∣∣ 2
[0255] S24. According to the optimization objective and metric function determined above, determine the algorithm flow of repeated defect matching between image pairs:
[0256] Traverse each pair of defects b detected in images I1 and I2 1,m and b 2,n , where m traverses from 1 to n1, and n traverses from 1 to n2; the defect target detection frame b is calculated based on the metric function formula obtained in step S23 1,m and b 2,n The distance metric D(I1, I2, b 1,m , b 2,n ); After traversing step S21 and step S22, a metric matrix D of the defect target detection frame between the two images with a shape of n1×n2 is obtained. 1,2 ; Based on the classic Jonker-Volgenant algorithm, the optimization problem of step S22 transformation is solved to obtain the matching relationship between the defect target detection frames of the two images.
[0257] Determine the defect matching relationship between any multiple images according to the defect matching method between the two acquired images, specifically:
[0258] S31, the defect matching problem between multiple images is decomposed into the defect matching problem between multiple image pairs, and the defect targets detected between all images are paired with each other using the method in step S2, and the matching results of all image pairs are combined to obtain the defect target matching relationship between multiple images.
[0259] This embodiment expands the defect matching method between two images to multiple images, and realizes defect target matching between multiple images by pairing them one by one.
[0260] Furthermore, the defect matching relationship between multiple images can be gradually constructed through hierarchical clustering methods, and the overall rationality of defect matching between multiple images can be ensured through global consistency constraints.
[0261] In a specific embodiment, initialization is first performed to treat each defect as an independent cluster. i and C j , calculate the similarity between clusters:
[0262] sim(C i , C j ) = max bp∈Ci,bq∈Cj exp(-D(b p , b q ) / γ)
[0263] Among them, p and q represent the indexes of the clusters to which two different defect detection boxes belong, respectively, and b p and b q is the specific defect detection frame, D(b p , b q ) is the defect detection frame b p and b q The distance metric between them, γ is used to adjust the influence of the distance metric in the similarity calculation;
[0264] Adaptive density clustering is performed using the HDBSCAN algorithm. HDBSCAN is a density-based clustering algorithm that defines the distance between clusters as:
[0265] D(C i , C j ) = -log(sim(C i , C j ))
[0266] Merge the most similar clusters until a preset threshold or number of clusters is reached; for each cluster C, minimize the following energy function:
[0267] E(C) =∑ bi,bj∈C D(b i , b j ) +φ·∑ bi∈C (1 - max bj∈Cbi sim(b i , b j ))
[0268] Where φ represents the trade-off factor, which is used to adjust the influence of distance metric and similarity in the energy function;
[0269] The consistency of clusters is iteratively optimized using the Louvain algorithm;
[0270] Construct the global defect relationship graph G a =(V a , E a ), where V a represents the defects in all images, E a Indicates that based on the matching results, a global consistency energy function is defined:
[0271] E global =∑ (i,j)∈Ea w* ij·D(b i , b j )+α'∑ k (∣C k ∣-η) 2 +β'·∑ Cp,Cq overlap(C p , C q )
[0272] Among them, E global represents the global consistency energy function, w* ij is the matching weight, |C k ∣ is the cluster size, η is the expected cluster size, overlap(C p , C q ) represents the degree of overlap between clusters, α' and β' represent the trade-off factors;
[0273] The problem is decomposed into sub-problems using the Alternating Direction Method of Multipliers (ADMM) algorithm: matching update, cluster size adjustment, overlap elimination, and iterative solution until convergence or the maximum number of iterations is reached.
[0274] In another specific embodiment, a graph-based clustering algorithm is used to group images. Construct an image similarity graph G img = (V img , E img ); calculate the similarity between images, taking into account shooting angle, timestamp and image content; apply the improved Louvain algorithm for community detection and obtain the image group {G a1 , G a2 , ..., G am}; Apply the matching algorithm to the images within each image group.
[0275] A bottom-up hierarchical matching method is adopted. At the bottom layer, a matching algorithm is applied to each pair of adjacent images; at the middle layer, adjacent matching results are merged: a matching graph G is constructed. match = (V match , E match ); apply the maximum weight clique algorithm to find consistent matching subsets; at the top level, solve the global consistency problem: build a global matching constraint graph; use an iterative algorithm based on Lagrangian relaxation to solve the global optimal matching.
[0276] An image defect target matching system based on geometric distance measurement includes: at least one processor; and a memory communicatively connected to at least one of the processors; wherein the memory stores instructions executable by the processor, and the instructions are used to be executed by the processor to implement the image defect target matching method based on geometric distance measurement described in any of the above technical solutions.
[0277] The metric function proposed in this embodiment measures the distance between any two defect targets detected by the detection algorithms, accurately determines the matching relationship between the same defect targets in different images, and helps to improve the accuracy and reliability of defect detection and reduce misjudgments and missed detections; through analysis between multiple images, the matching relationship between defect targets is determined, and repeated defects in the images are found, which improves the overall quality and availability of image detection results and effectively reduces the cost of defect review and manual management; this technology has high scalability and can process different types of images and defect targets. Whether in the industrial field, medical imaging, or other fields, this technology can be applied for defect matching to improve image analysis quality and image processing efficiency.
[0278] The preferred embodiments of the present invention are described in detail above; however, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, various equivalent transformations can be made to the technical solutions of the present invention, and these equivalent transformations all belong to the protection scope of the present invention.
Claims
1. An image defect target matching method based on geometric distance measurement, characterized in that: The steps include: S1, collect images of the same target from multiple angles and perform defect detection on each image; S2. Based on the defect detection results, a two-dimensional matrix of defect-target matching relationship is constructed, and the two-dimensional matrix is transformed into an optimal matching problem through a distance metric function; S3, obtaining the camera intrinsic parameter matrix and the position and posture relationship between cameras, and constructing a distance metric function matrix based on the defect detection results, the camera intrinsic parameter matrix and the position and posture relationship between cameras; S4. Solve the optimal matching problem based on the distance metric function matrix to obtain the optimal defect-target matching relationship; Step S2 is further as follows: S21. Based on the defect detection results, a two-dimensional matrix of defect-target matching relationships is constructed, and constraints of the two-dimensional matrix are confirmed; S22, quantifying the similarity of defect targets through a distance measurement function, and based on the similarity, transforming the two-dimensional matrix into an optimal matching problem; Construct a two-dimensional matrix to represent the defect-target matching relationship, define the shape of the two-dimensional matrix M as m1×m2, and set the matrix element M ij =1 means match, M ij =0 means no match, set the constraint condition as: ∑ j=1 m2 M ij ≤1; ∑ i=1 m1 M ij ≤1; Where m1 represents the number of defects detected in the first image, m2 represents the number of defects detected in the second image, and M ij Indicates whether the i-th defect in the first image matches the j-th defect in the second image; Define the distance metric function and set the distance metric function to D(b i , b j ), the following conditions are met: If b i With b j are the same target, then the distance metric function D(b i , b j ) is smaller; if b i With b j If they are not the same target, then the distance metric function D(b i , b j ) is larger; b i With b j The more similar, the distance metric function D(b i , b j ) is smaller; Convert the defect target matching problem into an optimization problem: min M ∑ i=1 m1 ∑ j=1 m2 D(b i ,b j )M ij ; s.t. ∑ j=1 m2 M ij ≤1; ∑ i=1 m1 M ij ≤1; M ij ∈{0,1}; Among them, b i represents the detection box of each defect detected in the i-th image, b j represents the detection box of each defect detected in the jth image; Step S3 is further as follows: S31, based on the defect detection result, determining the center point coordinates of each defect detection frame; S32, obtaining a camera intrinsic parameter matrix, and based on the camera intrinsic parameter matrix, converting the coordinates of each center point into a three-dimensional space straight line in a different coordinate system; S33, obtaining the posture relationship between cameras, and based on the posture relationship between cameras, converting the three-dimensional space straight lines in different coordinate systems to the same coordinate system; S34, calculating the shortest distance of a straight line in the three-dimensional space under the same coordinate system, and constructing a distance measurement function matrix based on the shortest distance; Step S4 is further as follows: S41. Construct a bipartite graph based on the distance metric function matrix and the optimal matching problem; S42, calculating the Laplace matrix of the bipartite graph, and based on the Laplace matrix, using the k-means clustering method to obtain a predetermined number of subgraphs; S43, matching each subgraph, and merging the matching results of all subgraphs; S44. Based on the matching results, a consistency graph is constructed, and the global consistency of the consistency graph is optimized using a simulated annealing algorithm to obtain an optimized result, which is the optimal defect-target matching relationship.
2. The image defect target matching method based on geometric distance measurement according to claim 1 is characterized in that: Step S1 is further as follows: S11. Use a drone to shoot the same target from multiple angles along a predetermined path to obtain images from multiple angles; S12, preprocessing images at multiple angles; S13, using a defect detection algorithm to extract defect features in each preprocessed image to form a defect detection frame set; S14: Determine the matching relationship of the defect targets in the defect detection frame set.
3. The image defect target matching method based on geometric distance measurement according to claim 2 is characterized in that: Step S11 also includes optimizing the shooting angle of the drone using an adaptive sampling algorithm based on information entropy, specifically: S11a, based on each shooting angle, construct an initial sampling point set, each sampling point represents a shooting angle; S11b, calculating the information gain of each sampling point, and selecting the sampling point with the largest information gain; S11c, based on the sampling point with the largest information gain, update the initial sampling point set; S11d, repeating steps S11b to S11c until the information gain is lower than a preset threshold, and outputting an updated sampling point set.
4. The image defect target matching method based on geometric distance measurement according to claim 2 is characterized in that: Step S12 is further as follows: S121, dividing the image at each angle into a predetermined number of rectangular blocks of equal size, calculating the histogram of each rectangular block, and determining the grayscale level of the histogram; S122, based on a preset clipping threshold, clipping the histogram of each rectangular block to obtain a clipped histogram; S123, calculating a cumulative distribution function based on the clipped histogram; S124, calculating a mapping function based on the cumulative distribution function and the gray level number; S125. Based on the mapping function, interpolate each pixel in the image to obtain an interpolated image, which is the preprocessed image.
5. The image defect target matching method based on geometric distance measurement according to claim 2 is characterized in that: Step S13 is further as follows: S131, performing edge detection on each preprocessed image, and based on the edge detection result, using a discrete Fourier transform method to calculate the amplitude of a discrete Fourier transform coefficient as a shape feature of the defect; S132, based on each preprocessed image, using the gray level co-occurrence matrix to calculate the Haralic features of the gray level distribution, including angular second moment, contrast, correlation, entropy and inverse difference moment; S133, based on each preprocessed image, calculating local binary pattern features of different scales; S134, forming texture features of defects based on Harald features and local binary pattern features; S135. Combine the shape features and texture features of the defect to form a defect detection frame set.
6. The image defect target matching method based on geometric distance measurement according to claim 2 is characterized in that: Step S34 also includes optimizing the distance metric function matrix, specifically: S34a, based on the defect detection results, the camera internal parameter matrix and the position and posture relationship between cameras, estimate the three-dimensional position coordinates of the defect target in the same coordinate system, and calculate the covariance matrix of the three-dimensional position coordinates; S34b, based on the defect detection results, construct a defect appearance feature extraction model, and calculate the appearance similarity of the defect target; S34c, based on the defect detection result, construct a local image block around the defect target, and extract context features of the local image block; S34d, weighting and fusing the covariance matrix, the appearance similarity and the context features to form a distance metric function matrix; D'(b i ,b j )=w'1·D geo +w'2 · D app +w'3 · D context ; Among them, D'(b i , b j ) represents the total distance metric that integrates geometric distance, appearance similarity and contextual consistency. w'1, w'2 and w'3 represent the weights of geometric distance, appearance similarity and contextual consistency, respectively. The weights w'1, w'2, w'3 are obtained by batch triplet loss training. geo is the covariance matrix, representing the geometric distance; D app Indicates appearance similarity; D context It is a context feature, indicating context consistency.
7. Image defect target matching system based on geometric distance measurement, characterized in that: include: at least one processor; as well as, a memory communicatively connected to at least one of the processors; wherein, The memory stores instructions that can be executed by the processor, and the instructions are used to be executed by the processor to implement the image defect target matching method based on geometric distance measurement as described in any one of claims 1 to 6.
