Verification method and device of industrial appearance detection equipment, equipment and storage medium
By performing image preprocessing and spectral analysis on the appearance inspection equipment of the tobacco packaging production line, and combining the SVDD model and the isolated forest algorithm, automated equipment fault detection and verification were achieved, solving the consistency problem of manual verification and improving the digitalization and accuracy of quality control.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-09
- Publication Date
- 2026-07-10
Smart Images

Figure CN122367922A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of tobacco technology, and in particular to a verification method, apparatus, equipment and storage medium for industrial appearance inspection equipment. Background Technology
[0002] In tobacco packaging production sites, online inspection devices for the appearance of cigarette packs are key equipment to ensure product quality, and regular verification of their effectiveness is crucial.
[0003] Currently, the industry generally uses a manual verification method, in which operators create physical cigarette packs with specific defects (such as damaged trademarks or crooked seals) as samples. During the short time between equipment shifts, these samples are passed through the testing device one by one to observe whether they can be correctly rejected, thereby determining whether the device is working properly.
[0004] Manual verification methods require multiple people working intensively; poor consistency of manual samples leads to inaccurate verification results; it is impossible to accurately pinpoint whether the fault originates from the vision system or the rejection mechanism; physical samples are easily damaged and mixed, making management difficult; and the lack of digital traceability capabilities severely restricts the effectiveness of quality control. Summary of the Invention
[0005] The main objective of this application is to provide a verification method, apparatus, equipment, and storage medium for industrial appearance inspection equipment, in order to solve the problem that the consistency of manual samples in existing manual verification methods is poor, resulting in inaccurate verification results and inability to accurately locate faults.
[0006] To achieve the above objectives, this application provides the following technical solution: A verification method for industrial appearance inspection equipment, the verification method comprising: Step S1: Collect multiple frames of images of the standard verification board of the industrial appearance inspection equipment to be verified under different light intensities and shooting angles, and perform data preprocessing on the multiple frames of images to obtain a preprocessed image set. Step S2: Extract the amplitude spectrum and phase spectrum of each image in the preprocessed image set through Fourier spectrum analysis, and then flatten and connect them to obtain the first frequency domain feature matrix. Step S3: Input the first frequency domain feature matrix into the SVDD model to perform single-class boundary modeling. By minimizing the hypersphere radius, the output data distribution of the normal detection device is mapped to the hypersphere in the high-dimensional feature space to obtain the hypersphere center vector and the hypersphere radius threshold. Step S4: Input the second frequency domain feature matrix obtained after processing the pre-acquired verification test image in the same way as in steps S1 to S2 into the SVDD model, calculate the Euclidean distance between the vector in the second frequency domain feature matrix and the center vector of the hypersphere, and obtain the deviation distance value sequence. Step S5: The anomaly score of each deviation distance value in the deviation distance value sequence is obtained by using the isolated forest algorithm to obtain the anomaly score sequence corresponding to each frame; Step S6: Compare the abnormal score sequence with the hypersphere radius threshold one by one, mark the frames with abnormal scores exceeding the hypersphere radius threshold as unqualified frames, and calculate the proportion of unqualified frames to the total number of frames to obtain the verification failure rate of the industrial appearance inspection equipment to be verified.
[0007] Beneficial effects of steps S1 to S6: This method replaces the traditional manual verification process, reducing on-site workload, eliminating verification deviations caused by insufficient consistency of manual samples, and avoiding the challenges of fragile physical samples, mixing, and management. The method relies entirely on data processing for verification, enabling digital retention and traceability of the verification process. It also provides data support for subsequent equipment fault location, improving the stability and standardization of quality control in tobacco packaging production.
[0008] Step S1 eliminates irrelevant interference factors in the original image, providing a unified data foundation for subsequent feature extraction; Step S2 mines the intrinsic features of the image from the frequency domain dimension, improving the ability to perceive subtle appearance differences; Step S3 establishes a single-class boundary model based on normal equipment output data, forming an objective and unified verification benchmark; Step S4 quantifies the deviation of the test data from the benchmark boundary, realizing the numerical representation of the verification results; Step S5 identifies abnormal fluctuations in the data sequence, enhancing the ability to detect intermittent equipment failures; Step S6 outputs the final verification conclusion through quantitative statistics, ensuring the objectivity and comparability of the verification results.
[0009] As a further improvement to this application, step S1 involves acquiring multiple frames of images of the standard verification board under different light intensities and shooting angles from the industrial appearance inspection equipment to be verified, and performing data preprocessing on the multiple frames of images to obtain a preprocessed image set, including: Step S1.1: Place the standard verification board on the inspection station of the industrial appearance inspection equipment to be verified, and trigger the image acquisition function of the inspection equipment in sequence according to the preset combination of light intensity gradient and shooting angle to obtain the original multi-frame image sequence. Step S1.2: Read the RGB channel data of each frame in the original multi-frame image sequence, and combine the three-channel pixel values into a single-channel grayscale value by weighted averaging to obtain a grayscale image sequence; Step S1.3: Map the grayscale values of each frame in the grayscale image sequence to the range of 0 to 255 by Min-Max linear scaling to obtain a grayscale normalized image sequence; Step S1.4: The intrinsic parameter matrix and distortion coefficients of the industrial appearance inspection equipment to be verified are calibrated using the Zhang Zhengyou calibration method to obtain the camera intrinsic parameter matrix and distortion coefficient vector; Step S1.5: Substitute the camera intrinsic parameter matrix and the distortion coefficient vector into the distortion correction mapping function to perform pixel remapping on each frame of the grayscale normalized image sequence to obtain the distortion corrected image sequence. Step S1.6: Sort the distortion-corrected image sequence according to the acquisition timestamp and summarize it to obtain a preprocessed image set.
[0010] Beneficial effects of steps S1.1 to S1.6: This series of steps completes the standardized acquisition and preprocessing of the original images required for verification, eliminating various systematic errors and random interferences during the acquisition process, and ensuring the consistency and comparability of the input data. It provides a reliable data foundation for subsequent feature extraction and model building, avoids biases introduced by manual samples, and supports the objective conduct of the verification process.
[0011] The steps are as follows: Step S1.1 covers the output status of the device under different operating conditions to ensure the comprehensiveness of the collected data; Step S1.2 simplifies the data dimensions while retaining the core appearance information to reduce the complexity of subsequent calculations; Step S1.3 unifies the image brightness range to eliminate numerical differences caused by illumination fluctuations; Step S1.4 obtains the device's own optical parameters to provide the necessary basis for image correction; Step S1.5 corrects the image distortion caused by the optical system to restore the true appearance of the target; Step S1.6 forms a structured dataset to facilitate batch processing and retrieval in subsequent processes.
[0012] As a further improvement to this application, step S2 involves extracting the amplitude and phase spectra of each image in the preprocessed image set through Fourier spectrum analysis, and then flattening and joining them to obtain a first frequency domain feature matrix, including: Step S2.1: Read each distortion correction image sequentially from the preprocessed image set, and perform a two-dimensional discrete Fourier transform on the gray-level pixel matrix of each frame image to obtain the corresponding two-dimensional complex frequency domain matrix. Step S2.2: Calculate the magnitude of each complex element in the two-dimensional complex frequency domain matrix, and rearrange the magnitudes of all complex elements according to the same matrix dimension to obtain the amplitude spectrum matrix of each frame image; Step S2.3: Calculate the argument of each complex element in the two-dimensional complex frequency domain matrix, and rearrange the arguments of all complex elements according to the same matrix dimension to obtain the phase spectrum matrix of each frame image; Step S2.4: The amplitude spectrum matrix and phase spectrum matrix of each frame image are concatenated according to the channel dimension to obtain the dual-channel spectrum matrix of each frame image; Step S2.5: Flatten the dual-channel spectral matrix of each frame image and arrange all elements of the matrix into a one-dimensional vector according to row priority to obtain the one-dimensional spectral vector of each frame image. Step S2.6: The one-dimensional spectrum vector of each frame image is appended sequentially according to the order in which the original image appears in the preprocessed image set, forming a first frequency domain feature matrix in the form of a multi-row, single-column data table.
[0013] Beneficial effects of steps S2.1 to S2.6: This series of steps converts spatial domain images to the frequency domain, extracts the inherent texture and structural features of the image, avoids the limitations of traditional spatial domain pixel comparison, provides more discriminative feature inputs for subsequent modeling, and improves the stability and robustness of feature representation.
[0014] The process includes: step S2.1 performing frequency domain transformation on the image to separate different frequency components of the signal; step S2.2 extracting the amplitude information of the image to reflect the energy distribution of different frequency components; step S2.3 extracting the phase information of the image to preserve the spatial relationship of the structure; step S2.4 fusing the amplitude and phase information to preserve the complete frequency domain features of the image; step S2.5 converting the two-dimensional matrix into a one-dimensional vector to adapt to the input format of the subsequent model; and step S2.6 integrating the feature vectors of all images to form a unified structured feature matrix.
[0015] As a further improvement of this application, step S3 involves inputting the first frequency domain feature matrix into the SVDD model for single-class boundary modeling. By minimizing the hypersphere radius, the output data distribution of the normal detection device is mapped to the hypersphere in the high-dimensional feature space, resulting in the hypersphere center vector and the hypersphere radius threshold. This includes: Step S3.1: Initialize the SVDD model and input the first frequency domain feature matrix into the SVDD model. Map each feature vector in the first frequency domain feature matrix to a high-dimensional regenerating kernel Hilbert space through a kernel function to obtain a high-dimensional feature mapping matrix containing several support vectors. Step S3.2: Define a minimum hypersphere containing all support vectors in the high-dimensional feature mapping matrix, and solve the problem of minimizing the volume of the hypersphere using the Lagrange multiplier method to obtain the hypersphere optimization objective function; Step S3.3: Solve the hypersphere optimization objective function iteratively using the sequential minimum optimization algorithm. In each iteration, select any pair of Lagrange multipliers for updating until convergence is obtained to obtain the optimal Lagrange multiplier vector. Step S3.4: Calculate the weighted combination of support vectors based on the optimal Lagrange multiplier vectors, and sum the feature vectors corresponding to all non-zero Lagrange multipliers according to their weights to obtain the hypersphere center vector; Step S3.5: Select any support vector from the high-dimensional feature mapping matrix and calculate the Euclidean distance from the selected support vector to the center vector of the hypersphere to obtain the hypersphere radius threshold. Step S3.6: Store the hypersphere center vector and the hypersphere radius threshold as SVDD model parameters to obtain the single-class boundary modeling of the SVDD model.
[0016] Beneficial effects of steps S3.1 to S3.6: This series of steps completes single-class boundary modeling based on normal equipment output data, eliminating the need for abnormal samples in training and solving the problem of scarce defect samples in industrial scenarios. It establishes an objective and unified benchmark for normal equipment operation, freeing it from reliance on manual experience, providing quantifiable evidence for subsequent anomaly detection, and improving the standardization and consistency of the verification process.
[0017] The process includes: Step S3.1, implementing high-dimensional mapping of the original features to enhance the ability to distinguish between different samples; Step S3.2, constructing a hypersphere optimization objective to clarify the boundary range of normal data; Step S3.3, efficiently solving the optimization problem to ensure the convergence and stability of model training; Step S3.4, calculating the center position of the hypersphere to determine the core region of normal data distribution; Step S3.5, determining the hypersphere radius threshold to define the boundary between normal and abnormal data; and Step S3.6, storing key model parameters to provide a reusable benchmark model for subsequent verification processes.
[0018] As a further improvement to this application, in step S4, the second frequency domain feature matrix obtained after processing the pre-acquired verification test image in the same way as in steps S1 to S2 is input into the SVDD model. The Euclidean distance between the vector in the second frequency domain feature matrix and the center vector of the hypersphere is calculated to obtain a sequence of deviation distance values, including: Step S4.1: Collect verification test images of the industrial appearance inspection equipment to be verified, and perform data preprocessing on the verification test images to obtain a set of preprocessed verification test images; Step S4.2: Extract the amplitude spectrum and phase spectrum of each image in the verification test preprocessed image set through Fourier spectrum analysis, and then flatten and connect them to obtain the second frequency domain feature matrix. Step S4.3: Read the hypersphere center vector from the SVDD model parameters, and divide the second frequency domain feature matrix by rows to obtain the second frequency domain feature vector corresponding to each frame image; Step S4.4: Calculate the Euclidean distance between the second frequency domain feature vector corresponding to each frame image and the center vector of the hypersphere to obtain the initial value of the deviation distance for each frame image; Step S4.5: Sort the initial values of the deviation distance of all frame images according to the timestamp of the verification test image acquisition to form a numerical sequence that increases in time, and obtain the deviation distance value sequence of each frame image.
[0019] Beneficial effects of steps S4.1 to S4.5: This series of steps standardizes and quantifies test data, ensuring consistency between the testing and modeling processes and eliminating systemic biases caused by different data processing methods. It correlates test data with established benchmarks, outputting quantifiable deviation indicators to provide direct data support for subsequent anomaly identification.
[0020] The process includes: Step S4.1 preprocessing the test images to ensure that the processing standards of the test data and the modeling data are consistent; Step S4.2 extracting the frequency domain features of the test data to form a feature matrix of the same dimension as the modeling features; Step S4.3 calling the stored model parameters and splitting the feature matrix to prepare for frame-by-frame deviation calculation; Step S4.4 quantifying the deviation of a single frame of data from the normal baseline to generate a single frame deviation index; and Step S4.5 organizing the deviation index in chronological order to preserve the temporal correlation characteristics of the data.
[0021] As a further improvement to this application, step S5 involves using the isolated forest algorithm to perform anomaly scoring on each deviation distance value in the deviation distance value sequence, resulting in an anomaly score sequence for each frame, including: Step S5.1: Initialize the isolated forest model by setting the number of samples per tree and the upper limit of the number of samples per tree to obtain the initial isolated forest model; Step S5.2: Input the deviation distance value sequence into the initial isolated forest model, and construct the isolated forest training dataset by analyzing the dimension and numerical distribution of each data point; Step S5.3: Recursively partition the isolated forest training dataset using a binary tree structure, randomly select features and split points to continuously divide the subspace into left and right regions, construct multiple isolated trees trained separately, and obtain an isolated forest decision tree set. Step S5.4: For the current data point in the deviation distance value sequence, traverse each isolated tree in the isolated forest decision tree set, calculate the path length of the current data point from the root node to the leaf node, and obtain the path length estimate set of the current data point. Step S5.5: Calculate the arithmetic mean of the path length estimates set for the current data point and convert it into anomaly scores to obtain the initial anomaly score of the frame image corresponding to the current data point. Step S5.6: Repeat steps S5.4 to S5.5 to traverse all data points in the deviation distance value sequence to obtain the initial set of abnormal score values corresponding to each frame of image; Step S5.7: Sort the set of initial abnormal scores corresponding to each frame of image according to the original image acquisition timestamp to form an abnormal score sequence with the same time order as the deviation distance value sequence.
[0022] Beneficial effects of steps S5.1 to S5.7: This series of steps quantifies the degree of anomaly based on deviation distance sequences, identifying abnormal fluctuations in data without requiring anomaly sample labeling, thus improving the ability to perceive subtle changes in equipment operating status. It reduces the risk of misjudgment by a single model through ensemble learning, providing more discriminative quantitative indicators for subsequent anomaly detection and enhancing the reliability of verification results.
[0023] The process involves the following steps: Step S5.1 Initializes the model and sets basic parameters to provide a standardized framework for subsequent training; Step S5.2 Constructs a training dataset that meets the algorithm requirements, ensuring the input data format is compliant; Step S5.3 Constructs multiple isolated trees to form an integrated structure, improving the generalization ability of anomaly detection; Step S5.4 Calculates the path length of a single data point in each isolated tree, reflecting the relative isolation degree of the data point; Step S5.5 Integrates the calculation results of multiple trees and converts them into a unified anomaly score index; Step S5.6 Traverses all data points to complete anomaly scoring, obtaining a set of anomaly scores for the entire sequence; Step S5.7 Organizes the anomaly scores in chronological order, preserving the temporal correlation characteristics of the data.
[0024] As a further improvement of this application, step S6 involves comparing the abnormal score sequence with the hypersphere radius threshold one by one, marking frames with abnormal scores exceeding the hypersphere radius threshold as unqualified frames, and calculating the proportion of unqualified frames to the total number of frames to obtain the verification failure rate of the industrial appearance inspection equipment to be verified, including: Step S6.1: Determine whether the anomaly score of the current frame exceeds the hypersphere radius threshold, and obtain the Boolean value of the comparison result of the current frame; Step S6.2: If the comparison result of the current frame is true (Boolean value), generate an unqualified flag identifier for the current frame and associate the unqualified flag identifier with the corresponding current frame. Step S6.3: If the comparison result of the current frame is false (Boolean value), generate a qualified marker identifier for the current frame and associate the qualified marker identifier with the current frame to obtain the marking status of the current frame; Step S6.4: Repeat steps S6.1 to S6.3 to traverse all frames in the abnormal score sequence to obtain the set of marked states for all frames; Step S6.5: Count the number of frames with invalid flag identifiers in the flag state set to obtain the number of invalid frames; Step S6.6: Count the total number of frames in the marked state set, and divide the number of unqualified frames by the total number of frames to obtain the verification failure rate of the industrial appearance inspection equipment to be verified.
[0025] Beneficial effects of steps S6.1 to S6.6: This series of steps completes the determination of anomaly scores and the quantitative output of verification results, realizing an automated closed-loop verification process and eliminating the influence of subjective human judgment. Its standardized verification indicators facilitate horizontal and vertical comparisons of verification results from different devices and at different times, providing a clear basis for equipment status assessment.
[0026] The process includes the following steps: Step S6.1 compares the single-frame anomaly score with the judgment threshold to obtain a clear binary judgment result; Step S6.2 generates corresponding tags for abnormal frames to accurately identify unqualified samples; Step S6.3 generates corresponding tags for normal frames to distinguish the states of all samples; Step S6.4 traverses all data points to form a complete set of frame state tags; Step S6.5 counts the number of unqualified frames to provide basic data for the final index calculation; and Step S6.6 calculates the proportion of unqualified frames and outputs a quantitative verification conclusion that can be directly used for equipment evaluation.
[0027] To achieve the above objectives, this application also provides the following technical solutions: A verification device for industrial appearance inspection equipment, the verification device being applied to the verification method described above, the verification device comprising: The appearance inspection equipment data acquisition module is used to acquire multiple frames of images of the standard verification board of the industrial appearance inspection equipment to be verified under different light intensities and different shooting angles, and to perform data preprocessing on the multiple frames of images to obtain a preprocessed image set. The frequency domain feature matrix acquisition module is used to extract the amplitude spectrum and phase spectrum of each image in the preprocessed image set through Fourier spectrum analysis, and then flatten and connect them to obtain the first frequency domain feature matrix. The hypersphere parameter calculation module is used to input the first frequency domain feature matrix into the SVDD model for single-class boundary modeling, and to map the output data distribution of the normal detection device to the hypersphere in the high-dimensional feature space by minimizing the hypersphere radius, thereby obtaining the hypersphere center vector and the hypersphere radius threshold. The deviation distance value sequence calculation module is used to input the second frequency domain feature matrix obtained after the pre-acquired verification test image has been processed by the frequency domain feature matrix acquisition module and the hypersphere parameter calculation module into the SVDD model, calculate the Euclidean distance between the vector in the second frequency domain feature matrix and the center vector of the hypersphere, and obtain the deviation distance value sequence. The deviation distance value scoring module is used to score the anomalies of each deviation distance value in the deviation distance value sequence using the isolated forest algorithm, so as to obtain the anomaly score sequence corresponding to each frame. The verification failure rate statistics module is used to compare the abnormal score sequence with the hypersphere radius threshold one by one, mark the frames with abnormal scores exceeding the hypersphere radius threshold as unqualified frames, and calculate the proportion of unqualified frames to the total number of frames to obtain the verification failure rate of the industrial appearance inspection equipment to be verified.
[0028] To achieve the above objectives, this application also provides the following technical solutions: An electronic device includes a processor and a memory coupled to the processor, the memory storing program instructions executable by the processor; when the processor executes the program instructions stored in the memory, it implements the verification method of the industrial appearance inspection equipment as described above.
[0029] To achieve the above objectives, this application also provides the following technical solutions: A computer-readable storage medium storing program instructions, which, when executed by a processor, enable the verification method for the industrial appearance inspection equipment described above. Attached Figure Description
[0030] Figure 1 This is a schematic flowchart illustrating the steps of an embodiment of the verification method for an industrial appearance inspection device according to this application. Figure 2 This is a functional module diagram of an embodiment of a verification device for an industrial appearance inspection equipment according to this application; Figure 3 This is a schematic diagram of the structure of an embodiment of the electronic device of this application; Figure 4 This is a schematic diagram of the structure of one embodiment of the storage medium of this application. Detailed Implementation
[0031] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0032] The terms "first," "second," and "third" in this application are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first," "second," or "third" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified. All directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of this application are only used to explain the relative positional relationships and movements between components in a specific orientation (e.g., as shown in the figures). If the specific orientation changes, the directional indications also change accordingly. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices.
[0033] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0034] It should be noted that, due to the limited types and number of symbols or letters that can represent specific meanings, for embodiments with many formulas or codes, there may be situations where symbols or letters cannot meet the usage requirements. Therefore, the interpretation of formula symbols in the steps or sub-steps of the embodiments is only valid for the current step or sub-step.
[0035] If the same symbol has different interpretations in different steps or sub-steps, the interpretation in the current step or sub-step shall prevail; if the same symbol appears in different steps or sub-steps, but no interpretation is given in subsequent steps or sub-steps after its first appearance, the interpretation in the first step or sub-step shall be used.
[0036] like Figure 1 As shown, this embodiment provides an example of a verification method for industrial appearance inspection equipment. In this embodiment, the verification method includes the following steps: Step S1: Collect multiple frames of images of the standard verification board under different light intensities and shooting angles for the industrial appearance inspection equipment to be verified, and perform data preprocessing on the multiple frames of images to obtain a preprocessed image set.
[0037] Preferably, this step completes the standardized acquisition and full-process preprocessing of the original images required for verification. The core objective is to eliminate various systematic errors and random noise introduced by the acquisition system, providing unified and reliable data input for subsequent frequency domain feature extraction.
[0038] Furthermore, step S1 specifically includes the following steps: Step S1.1: Place the standard verification board on the inspection station of the industrial appearance inspection equipment to be verified, and trigger the image acquisition function of the inspection equipment in sequence according to the preset combination of light intensity gradient and shooting angle to obtain the original multi-frame image sequence.
[0039] Preferably, a standard verification plate specifically designed for tobacco packaging can be used. The plate surface includes common textured areas such as matte, glossy, and hot-stamped finishes found on cigarette packs, as well as standard color blocks, and is free of any physical defects. The verification plate is fixed at the center of the testing station of the equipment to be verified, ensuring complete consistency with the posture of the actual cigarette pack during operation.
[0040] Preferably, the preset light intensity gradients are 200 lux, 400 lux, 600 lux, 800 lux, 1000 lux, and 1200 lux, covering the normal light fluctuation range of the tobacco packaging production site; the preset shooting angle combinations are 0°, ±15°, and ±30° in the horizontal direction, and 0° and ±10° in the vertical direction, for a total of 15 posture combinations.
[0041] Preferably, data acquisition can be triggered by sending a 5VTTL level signal through the device's hardware trigger interface, with a trigger interval set to 500ms to ensure that the camera completes exposure and data transmission before triggering the next acquisition. The original image output format is 24-bit RGB true color, with a fixed resolution of 1920×1080 pixels.
[0042] Step S1.2: Read the RGB channel data of each frame in the original multi-frame image sequence, and merge the three-channel pixel values into a single-channel grayscale value by weighted averaging to obtain a grayscale image sequence.
[0043] Preferably, the ITU-R BT.601 standard weighted average method can be used for grayscale conversion. This method better matches the visual perception characteristics of tobacco packaging colors and can preserve the details of the appearance texture to the greatest extent. The conversion formula is as follows: Gray = 0.299 × R + 0.587 × G + 0.114 × B. Where R, G, and B are the pixel values of the red, green, and blue channels, respectively, with a value range of [0, 255]; Gray is the converted single-channel grayscale pixel value.
[0044] Preferably, the original RGB image sequence is traversed frame by frame, and the above calculation is performed on each pixel to obtain a grayscale image sequence with the same resolution as the original image.
[0045] For example, this step can be implemented using the following pseudocode: def preprocess_test_images(test_images, calib_mtx, calib_dist): preprocessed = [] for img in test_images: # Grayscale gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # Gray-scale normalization gray_norm = ((gray - gray.min()) / (gray.max() - gray.min() +1e-8) * 255).astype(np.uint8) # Distortion Correction h, w = gray_norm.shape new_cam_mtx, roi = cv2.getOptimalNewCameraMatrix(calib_mtx,calib_dist, (w,h), 1, (w,h)) undistorted = cv2.undistort(gray_norm, calib_mtx, calib_dist,None, new_cam_mtx) preprocessed.append(undistorted) return preprocessed Step S1.3: Map the grayscale values of each frame in the grayscale image sequence to the range of 0 to 255 by using Min-Max linear scaling to obtain a grayscale normalized image sequence.
[0046] Preferably, a single-frame Min-Max linear scaling method is used for grayscale normalization to eliminate the influence of uneven illumination within a single frame image. The normalization formula is as follows:
[0047] Among them, Gray min The minimum pixel value of a single frame of grayscale image, Graymax This represents the maximum pixel value of a single frame of a grayscale image. If Gray appears... max =Gray min In extreme cases, such as invalid frames that are entirely black or entirely white, all pixel values of the frame are set to 128 and marked as invalid frames, and the subsequent process automatically skips the frame.
[0048] Step S1.4: The intrinsic parameter matrix and distortion coefficients of the industrial appearance inspection equipment to be verified are calibrated using the Zhang Zhengyou calibration method to obtain the camera intrinsic parameter matrix and distortion coefficient vector.
[0049] Preferably, the Zhang Zhengyou planar calibration method is used to obtain the in-camera distortion coefficients. The calibration board is a 7×9 checkerboard pattern, with each square having a side length of 20mm, and is made of matte ceramic to avoid glare. Fifteen images of the calibration board are acquired at different angles and distances, and the corner detection accuracy is set to sub-pixel level (0.01 pixels).
[0050] Preferably, the camera intrinsic parameter matrix K is in the form of:
[0051] Among them, f x f y c is the equivalent focal length (in pixels) in the x and y directions. x c y These are the coordinates of the principal point of the image (in pixels).
[0052] Preferably, the distortion coefficients adopt a 5-parameter model of radial distortion + tangential distortion, in the form of: dist=[k1,k2,p1,p2,k3]. Where k1, k2, and k3 are radial distortion coefficients, and p1 and p2 are tangential distortion coefficients.
[0053] For example, this step can be implemented using the following pseudocode: import cv2 import numpy as np # Read calibration board image images = [cv2.imread(f"calib_{i}.png") for i in range(15)] # Detect chessboard corner points ret, corners = cv2.findChessboardCorners(images[0], (7,9), None) # Subpixel corner detection criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30,0.001) corners_subpix = cv2.cornerSubPix(cv2.cvtColor(images[0], cv2.COLOR_BGR2GRAY), corners, (11,11), (-1,-1), criteria) # Calibration Camera ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(obj_points, img_points, images[0].shape[:2], None, None) Step S1.5: Substitute the camera intrinsic parameter matrix and distortion coefficient vector into the distortion correction mapping function to perform pixel remapping on each frame of the grayscale normalized image sequence to obtain the distortion corrected image sequence.
[0054] Preferably, distortion correction is achieved through pixel remapping based on the in-camera distortion coefficients. First, the ideal distortion-free coordinates corresponding to the distorted pixel coordinates are calculated as follows:
[0055]
[0056] Where r2 = x2 + y2, x and y are the normalized image plane coordinates with the principal point as the origin.
[0057] Preferably, bilinear interpolation can be used for pixel value mapping. This method strikes a balance between computational efficiency and image quality, effectively preserving edge details. The grayscale-normalized image sequence is processed frame by frame to obtain the distortion-corrected image sequence.
[0058] Step S1.6: Sort the distortion-corrected image sequence according to the acquisition timestamp and summarize it to obtain the preprocessed image set.
[0059] Preferably, the acquisition timestamp of each frame of image is extracted (with millisecond precision), and the distortion correction image sequence is sorted in ascending order of timestamp to ensure the correctness of image timing.
[0060] Preferably, the sorted image sequences are aggregated into a preprocessed image set and stored in PNG lossless compression format to avoid image information loss. Metadata is added to each frame of the image, including information such as light intensity, shooting angle, and acquisition time, to facilitate subsequent data traceability.
[0061] Preferably, the preprocessed image set is randomly divided into a training subset and a validation subset, wherein the training subset accounts for 80% and is used for subsequent single-class boundary model training; the validation subset accounts for 20% and is used for evaluating the model's generalization ability.
[0062] Beneficial effects of steps S1.1 to S1.6: This series of steps completes the standardized acquisition and preprocessing of the original images required for verification, eliminating various systematic errors and random interferences during the acquisition process, and ensuring the consistency and comparability of the input data. It provides a reliable data foundation for subsequent feature extraction and model building, avoids biases introduced by manual samples, and supports the objective conduct of the verification process.
[0063] The steps are as follows: Step S1.1 covers the output status of the device under different operating conditions to ensure the comprehensiveness of the collected data; Step S1.2 simplifies the data dimensions while retaining the core appearance information to reduce the complexity of subsequent calculations; Step S1.3 unifies the image brightness range to eliminate numerical differences caused by illumination fluctuations; Step S1.4 obtains the device's own optical parameters to provide the necessary basis for image correction; Step S1.5 corrects the image distortion caused by the optical system to restore the true appearance of the target; Step S1.6 forms a structured dataset to facilitate batch processing and retrieval in subsequent processes.
[0064] Step S2: Extract the amplitude spectrum and phase spectrum of each image in the preprocessed image set through Fourier spectrum analysis, and then flatten and connect them to obtain the first frequency domain feature matrix.
[0065] Preferably, this step completes the feature transformation and structured representation of the spatial domain image to the frequency domain. The core objective is to extract the inherent texture and structural features of the image, avoiding the shortcomings of traditional spatial domain pixel comparison that is sensitive to illumination and displacement, and providing highly discriminative feature inputs for subsequent single-class boundary modeling.
[0066] Furthermore, step S2 specifically includes the following steps: Step S2.1: Read each distortion correction image sequentially from the preprocessed image set, and perform a two-dimensional discrete Fourier transform on the gray-level pixel matrix of each frame image to obtain the corresponding two-dimensional complex frequency domain matrix.
[0067] Preferably, a two-dimensional discrete Fourier transform (2D-DFT) is performed on each grayscale image in the preprocessed image set to convert the spatial domain pixel matrix into a complex frequency domain matrix. The transformation formula is as follows:
[0068] Where f(x,y) is the grayscale pixel value at spatial domain coordinates (x,y), H and W are the height and width of the image, respectively, F(u,v) is the complex value at frequency domain coordinates (u,v), and j is the imaginary unit.
[0069] Preferably, before the transformation, the image pixel values are converted from uint8 type to float32 type to avoid integer arithmetic overflow. After the transformation, a spectrum shift operation is performed to move the zero-frequency component from the upper left corner of the matrix to the center position, which facilitates subsequent spectrum analysis.
[0070] Step S2.2: Calculate the magnitude of each complex element in the two-dimensional complex frequency domain matrix, and rearrange the magnitudes of all complex elements according to the same matrix dimension to obtain the amplitude spectrum matrix of each frame image.
[0071] Preferably, the modulus is calculated for each complex element in the two-dimensional complex frequency domain matrix to obtain the amplitude value at the corresponding position. All amplitude values are then arranged according to the dimensions of the original matrix to form an amplitude spectrum matrix. The calculation formula is as follows:
[0072] Where Re(F(u,v)) is the real part of the complex value, and Im(F(u,v)) is the imaginary part of the complex value.
[0073] Preferably, a logarithmic transformation is performed on the amplitude spectrum matrix to compress the dynamic range and prevent high-energy low-frequency components from masking low-energy high-frequency details. The logarithmic transformation formula is as follows:
[0074] Step S2.3: Calculate the argument of each complex element in the two-dimensional complex frequency domain matrix, and rearrange the arguments of all complex elements according to the same matrix dimension to obtain the phase spectrum matrix of each frame image.
[0075] Preferably, the argument is calculated for each complex element in the two-dimensional complex frequency domain matrix to obtain the phase value at the corresponding position. All phase values are arranged according to the dimensions of the original matrix to form a phase spectrum matrix. The calculation formula is as follows:
[0076] Preferably, the phase spectrum has a value range of [-π, π], which contains the spatial location information of all structures in the image and is a key dimension for distinguishing different appearance features.
[0077] Step S2.4: The amplitude spectrum matrix and phase spectrum matrix of each frame image are concatenated according to the channel dimension to obtain the dual-channel spectrum matrix of each frame image.
[0078] Preferably, the amplitude spectrum matrix and phase spectrum matrix corresponding to a single frame image are concatenated along the channel dimension to form a dual-channel spectrum matrix. The dimensions of the concatenated matrix are (H, W, 2), where the first channel stores the logarithmically transformed amplitude spectrum and the second channel stores the phase spectrum. This operation simultaneously preserves the energy distribution information and structural location information of the image, significantly improving the feature's ability to perceive subtle appearance differences.
[0079] Step S2.5: Flatten the dual-channel spectral matrix of each frame image and arrange all elements of the matrix into a one-dimensional vector according to row priority to obtain the one-dimensional spectral vector of each frame image.
[0080] Preferably, a row-first (C-style) flattening operation is performed on the dual-channel spectral matrix of each frame image to convert the two-dimensional matrix into a one-dimensional spectral vector. The length of the flattened vector is H×W×2, and the length of the flattened vector is consistent across all images. Row-first flattening ensures that the order of elements in the feature vector corresponds to the spatial order of the original matrix, preserving the correlation of local features.
[0081] Step S2.6: The one-dimensional spectrum vector of each frame image is appended sequentially according to the order in which the original image appears in the preprocessed image set, forming the first frequency domain feature matrix in the form of a multi-row, single-column data table.
[0082] Preferably, all one-dimensional spectral vectors are appended sequentially according to the order in which the original images appear in the preprocessed image set, forming an N-row, M-column first frequency domain feature matrix, where N is the number of images in the preprocessed image set and M is the length of a single frame spectral vector.
[0083] Preferably, Z-score standardization can be performed on the feature matrix to eliminate the differences in numerical ranges between different feature dimensions and improve the stability of subsequent model training.
[0084] Beneficial effects of steps S2.1 to S2.6: This series of steps converts spatial domain images to the frequency domain, extracts the inherent texture and structural features of the image, avoids the limitations of traditional spatial domain pixel comparison, provides more discriminative feature inputs for subsequent modeling, and improves the stability and robustness of feature representation.
[0085] The process includes: step S2.1 performing frequency domain transformation on the image to separate different frequency components of the signal; step S2.2 extracting the amplitude information of the image to reflect the energy distribution of different frequency components; step S2.3 extracting the phase information of the image to preserve the spatial relationship of the structure; step S2.4 fusing the amplitude and phase information to preserve the complete frequency domain features of the image; step S2.5 converting the two-dimensional matrix into a one-dimensional vector to adapt to the input format of the subsequent model; and step S2.6 integrating the feature vectors of all images to form a unified structured feature matrix.
[0086] Step S3: Input the first frequency domain feature matrix into the SVDD model to perform single-class boundary modeling. By minimizing the hypersphere radius, the output data distribution of the normal detection device is mapped to the hypersphere in the high-dimensional feature space to obtain the hypersphere center vector and the hypersphere radius threshold.
[0087] Preferably, this step completes single-class boundary modeling, constructs an objective normal operation benchmark based on the frequency domain features of normal equipment output, and can complete model training without relying on scarce abnormal samples, solving the problem of difficulty in obtaining defect samples in industrial scenarios, and providing a quantifiable unified boundary for subsequent anomaly judgment.
[0088] Furthermore, step S3 specifically includes the following steps: Step S3.1: Initialize the SVDD model and input the first frequency domain feature matrix into the SVDD model. Map each feature vector in the first frequency domain feature matrix to the high-dimensional regenerating kernel Hilbert space through the kernel function to obtain a high-dimensional feature mapping matrix containing several support vectors.
[0089] Preferably, the Support Vector Data Description (SVDD) model is initialized, and the kernel function is chosen to be the Gaussian Radial Basis Function (RBF). This adapts to the nonlinear distribution characteristics of the frequency domain features, implicitly mapping low-dimensional features to a high-dimensional reproducing kernel Hilbert space, thus achieving the separability of linearly inseparable samples. The kernel function formula is as follows:
[0090] Where γ is the kernel width parameter, set to 1 / M (M is the frequency domain feature dimension); the penalty coefficient C is set to 0.01 to control the slack variable weights, balance the fitting ability and generalization ability, and avoid overfitting.
[0091] Preferably, the first frequency domain feature matrix is input into the model, and implicit high-dimensional mapping is completed through kernel tricks. This avoids the curse of dimensionality by eliminating the need for explicit computation of high-dimensional features and obtaining a high-dimensional feature mapping matrix.
[0092] For example, this step can be implemented using the following pseudocode: class SVDD: def __init__(self, C=0.01, gamma=None): self.C = C self.gamma = gamma self.X = None self.alpha = None self.center = None self.radius = None def fit(self, X): n_samples, n_features = X.shape if self.gamma is None: self.gamma = 1.0 / n_features self.X = X # Calculate the kernel matrix K = self._kernel_matrix(X) Step S3.2: Define a minimum hypersphere containing all support vectors in the high-dimensional feature mapping matrix, and solve the problem of minimizing the volume of the hypersphere using the Lagrange multiplier method to obtain the hypersphere optimization objective function.
[0093] Preferably, a minimum hypersphere optimization primal problem is defined, with the objective of minimizing the hypersphere volume while allowing a small number of noise samples to fall outside the hypersphere, and a relaxation variable ξi is introduced as a balance constraint. The primal problem formula is as follows:
[0094]
[0095] Where R is the radius of the hypersphere, a is the center of the hypersphere, and ξ i Let be the slack variable for the i-th sample.
[0096] Preferably, the Lagrange multiplier α can be introduced. i ≥0 and β i If the condition is greater than or equal to 0, the original problem is transformed into a dual convex quadratic programming problem, eliminating constraints and facilitating efficient solution. The formula for the dual problem is as follows:
[0097]
[0098] Where, α i α j The Lagrange multipliers corresponding to the i-th and j-th samples are used to transform the constraints of the original problem into part of the objective function; K(x i ,x j K(x) is a Gaussian radial basis function used to implicitly map low-dimensional frequency domain features to a high-dimensional reproducing kernel Hilbert space; i ,x i) represents the value of the kernel function at the sample itself, and is always equal to 1 for the Gaussian kernel; C is the same penalty coefficient as in the original problem, which limits the upper bound of the Lagrange multipliers; n is the same total number of samples as in the original problem.
[0099] Step S3.3: Solve the hypersphere optimization objective function iteratively using the sequential minimum optimization algorithm. In each iteration, select any pair of Lagrange multipliers for updating until convergence is obtained to obtain the optimal Lagrange multiplier vector.
[0100] Preferably, the Sequential Minimal Optimization (SMO) algorithm is used to solve the dual problem, avoiding the high computational complexity of traditional quadratic programming. The algorithm selects a pair of Lagrange multipliers at each step, fixes the remaining multipliers, analytically solves for the optimal value of this pair of multipliers, and iteratively updates until convergence.
[0101] Preferably, the iteration stopping threshold is set to the condition that all samples satisfy the KKT condition, or the objective function changes by less than 10 between two iterations. -5 Alternatively, the maximum number of iterations can reach 1000 to ensure a balance between training efficiency and accuracy.
[0102] Preferably, a heuristic multiplier selection strategy is adopted, which prioritizes the samples that most severely violate the KKT conditions as optimization targets, greatly accelerating the convergence speed and adapting to the training needs of large-scale frequency domain feature data.
[0103] For example, this step can be implemented using the following pseudocode: def smo(self, K, n_samples): alpha = np.zeros(n_samples) b = 0 passes = 0 tol = 1e-5 max_passes = 1000 while passes <max_passes: passes += 1 # Optimize the selection of traversed samples for i in range(n_samples): # Calculation error E_i = self._predict_E(i, K, alpha) # Check for violations of KKT conditions if self._check_KKT(alpha[i], E_i): # Randomly select the second sample j j = i while j == i: j = np.random.randint(0, n_samples) # Parse and update alpha[i] and alpha[j] alpha_i_old, alpha_j_old = alpha[i], alpha[j] L, H = self._get_LH(alpha[i], alpha[j]) eta = 2*K[i,j] - K[i,i]- K[j,j] if eta>= 0: continue alpha[j] -= E_i - E_j / eta alpha[j] = np.clip(alpha[j], L, H) alpha[i] += alpha_j_old - alpha[j] Step S3.4: Calculate the weighted combination of support vectors based on the optimal Lagrange multiplier vectors, and sum the eigenvectors corresponding to all non-zero Lagrange multipliers according to their weights to obtain the hypersphere center vector.
[0104] Preferably, the hypersphere center vector is calculated based on the optimal Lagrange multipliers obtained from the SMO solution. Only samples corresponding to non-zero Lagrange multipliers are support vectors; therefore, the center is the weighted sum of all support vectors, leveraging the sparsity of SVDD to reduce computation. The formula is as follows:
[0105] Where a is the center vector of the hypersphere, α i For optimal Lagrange multipliers, x i Let be the frequency domain feature vector of the i-th support vector.
[0106] Step S3.5: Select any support vector from the high-dimensional feature mapping matrix and calculate the Euclidean distance from the selected support vector to the center vector of the hypersphere to obtain the hypersphere radius threshold.
[0107] Preferably, any non-boundary support vector is selected (satisfying 0 < α). i <C), the sample falls exactly on the boundary of the hypersphere. The Euclidean distance from this sample to the center of the hypersphere is calculated; this distance is the hypersphere radius threshold. This threshold is automatically learned from the training data and does not require manual setting. The formula is as follows:
[0108] Where, x s The feature vectors are non-boundary support vectors.
[0109] Step S3.6: Store the hypersphere center vector and hypersphere radius threshold as SVDD model parameters to obtain the single-class boundary modeling of the SVDD model.
[0110] Preferably, the trained hypersphere center vector, hypersphere radius threshold, Lagrange multipliers, support vector samples, kernel function parameters, penalty coefficients, and preprocessed mean and standard deviation vectors from previous steps are stored together as a model file using a lossless serialization format to ensure the integrity and consistency of the parameters. The stored model can be directly loaded for subsequent validation processes without repeated training, enabling cross-device reuse of the model and significantly improving the execution efficiency of the validation process.
[0111] Beneficial effects of steps S3.1 to S3.6: This series of steps completes single-class boundary modeling based on normal equipment output data, eliminating the need for abnormal samples in training and solving the problem of scarce defect samples in industrial scenarios. It establishes an objective and unified benchmark for normal equipment operation, freeing it from reliance on manual experience, providing quantifiable evidence for subsequent anomaly detection, and improving the standardization and consistency of the verification process.
[0112] The process includes: Step S3.1, implementing high-dimensional mapping of the original features to enhance the ability to distinguish between different samples; Step S3.2, constructing a hypersphere optimization objective to clarify the boundary range of normal data; Step S3.3, efficiently solving the optimization problem to ensure the convergence and stability of model training; Step S3.4, calculating the center position of the hypersphere to determine the core region of normal data distribution; Step S3.5, determining the hypersphere radius threshold to define the boundary between normal and abnormal data; and Step S3.6, storing key model parameters to provide a reusable benchmark model for subsequent verification processes.
[0113] Step S4: Input the second frequency domain feature matrix obtained after the pre-acquired verification test image has undergone the same processing as in steps S1 to S2 into the SVDD model, calculate the Euclidean distance between the vector in the second frequency domain feature matrix and the center vector of the hypersphere, and obtain the deviation distance value sequence.
[0114] Preferably, this step completes the standardization and deviation quantification of the verification test data, strictly reuses the preprocessing and feature extraction process of the training phase, ensures that the processing specifications of the test data and the training data are completely consistent, eliminates the system deviation caused by different processes, correlates the test data with the established normal operation benchmark, and outputs a quantifiable deviation index to provide direct data support for subsequent anomaly identification.
[0115] Furthermore, step S4 specifically includes the following steps: Step S4.1: Collect verification test images of the industrial appearance inspection equipment to be verified, perform data preprocessing on the verification test images, and obtain a set of preprocessed verification test images.
[0116] Preferably, the verification test image of the device to be verified is acquired, and the preprocessing process is performed in complete accordance with step S1: grayscale reuse of ITU-R BT.601 weighted coefficients, grayscale normalization using single-frame Min-Max scaling, and distortion correction directly reuse of the camera intra-camera distortion coefficients obtained from step S1.4 calibration, without the need to re-execute the calibration process, ensuring that the processing specifications of the test data are completely aligned with the training data.
[0117] Preferably, the preprocessed image sequence forms a verification test preprocessed image set, which is completely consistent with the output format, resolution, and number of channels in the training phase, thus avoiding systematic errors introduced due to processing differences.
[0118] Step S4.2: Extract the amplitude spectrum and phase spectrum of each image in the verification test preprocessed image set through Fourier spectrum analysis, and then flatten and connect them to obtain the second frequency domain feature matrix.
[0119] Preferably, the frequency domain feature extraction process is performed in complete agreement with step S2: two-dimensional Fourier transform, spectrum shift, logarithmic transform of amplitude spectrum, phase spectrum calculation, dual-channel splicing, and row-first flattening to obtain the original second frequency domain feature matrix.
[0120] Preferably, the mean vector and standard deviation vector saved in step S2.6 during the training phase are reused to perform Z-score standardization on the second frequency domain feature matrix, instead of using the statistics of the test data itself, to ensure that the distribution of the feature dimensions is completely consistent with that during the training phase and to avoid feature space misalignment caused by distribution shift.
[0121] Step S4.3: Read the hypersphere center vector from the SVDD model parameters and divide the second frequency domain feature matrix by rows to obtain the second frequency domain feature vector corresponding to each frame image.
[0122] Preferably, the SVDD model file stored in step S3.6 is loaded, and core parameters such as the hypersphere center vector are read using a lossless serialization method to ensure that the floating-point precision of the parameters is not lost.
[0123] Preferably, the second frequency domain feature matrix is split by row, with each row corresponding to the standardized frequency domain feature vector of a test image frame, forming a single-frame feature vector list, which prepares for frame-by-frame deviation calculation. This splitting method supports subsequent parallel computing and can significantly improve the processing efficiency of large-scale test data.
[0124] Step S4.4: Calculate the Euclidean distance between the second frequency domain feature vector and the hypersphere center vector corresponding to each frame image to obtain the initial value of the deviation distance for each frame image.
[0125] Preferably, for each split single-frame frequency domain feature vector, the Euclidean distance between it and the hypersphere center vector is calculated to quantify the deviation of the frame data from the normal operating benchmark. The calculation formula is as follows: Among them, x i Let be the normalized frequency domain feature vector of the i-th test frame, 'a' be the hypersphere center vector of the SVDD model, and 'di' be the initial value of the deviation distance for that frame. The larger this distance, the greater the deviation of the frame's data from the normal baseline.
[0126] Step S4.5: Sort the initial values of the deviation distance of all frame images according to the timestamp of the verification test image acquisition to form a numerical sequence that increases in time points, and obtain the deviation distance value sequence of each frame image.
[0127] Preferably, the acquisition timestamp of each test image frame is extracted, with a timestamp precision at the millisecond level, consistent with the acquisition timestamp precision during the training phase. All initial deviation distance values are sorted in ascending order of timestamp to form a time-increasing sequence of deviation distance values. This preserves the temporal correlation characteristics of the data, provides correct temporal input for subsequent temporal anomaly detection, and avoids temporal misalignment problems caused by network transmission disorder.
[0128] Beneficial effects of steps S4.1 to S4.5: This series of steps standardizes and quantifies test data, ensuring consistency between the testing and modeling processes and eliminating systemic biases caused by different data processing methods. It correlates test data with established benchmarks, outputting quantifiable deviation indicators to provide direct data support for subsequent anomaly identification.
[0129] The process includes: Step S4.1 preprocessing the test images to ensure that the processing standards of the test data and the modeling data are consistent; Step S4.2 extracting the frequency domain features of the test data to form a feature matrix of the same dimension as the modeling features; Step S4.3 calling the stored model parameters and splitting the feature matrix to prepare for frame-by-frame deviation calculation; Step S4.4 quantifying the deviation of a single frame of data from the normal baseline to generate a single frame deviation index; and Step S4.5 organizing the deviation index in chronological order to preserve the temporal correlation characteristics of the data.
[0130] Step S5: The isolated forest algorithm is used to score the anomalies of each deviation distance value in the deviation distance value sequence to obtain the anomaly score sequence corresponding to each frame.
[0131] Preferably, this step quantifies the degree of anomaly based on the deviation distance sequence, employing an unsupervised isolated forest algorithm. This algorithm can identify abnormal fluctuations in the data without requiring anomaly sample labeling, improving the ability to perceive subtle changes in equipment operating status. It reduces the risk of misjudgment by a single model through ensemble learning, providing more discriminative quantitative indicators for subsequent anomaly detection and enhancing the reliability of the verification results.
[0132] Furthermore, step S5 specifically includes the following steps: Step S5.1: Initialize the isolated forest model by setting the number of samples per tree and the upper limit of the number of samples per tree to obtain the initial isolated forest model.
[0133] Preferably, the isolated forest model is initialized with the number of tree samples n_estimators set to 100 to balance the accuracy of anomaly detection with computational efficiency and avoid computational redundancy caused by too many trees; the maximum number of samples per tree max_samples is set to 256 to adapt to the detection requirements of univariate time series data and reduce the computational load of a single tree.
[0134] Preferably, the random seed is set to 42, and the random sampling and splitting process of the fixed algorithm is fixed to ensure the reproducibility of the verification results and meet the traceability requirements of the verification process in industrial production scenarios.
[0135] Step S5.2: Input the bias distance value sequence into the initial isolated forest model, and construct the isolated forest training dataset by analyzing the dimension and numerical distribution of each data point.
[0136] Preferably, the one-dimensional bias distance sequence is converted into a two-dimensional input format required by the Isolation Forest algorithm. The shape of the converted dataset is (n_samples, n_features), where n_samples is the total number of test frames and n_features is 1. This adapts the input specification of the algorithm and can complete the input adaptation without additional feature engineering.
[0137] Step S5.3: Recursively partition the isolated forest training dataset using a binary tree structure, randomly select features and split points to continuously divide the subspace into left and right regions, construct multiple isolated trees trained separately, and obtain an isolated forest decision tree set.
[0138] Preferably, recursive partitioning is performed on the training dataset. Each isolated tree randomly selects features and split points to continuously divide the subspace into left and right regions until the samples cannot be further divided or the preset maximum depth is reached, thereby constructing 100 independently trained isolated trees to form an integrated detection structure.
[0139] Preferably, the integrated structure of multiple trees can effectively reduce the random error of a single tree, avoid misjudgment caused by a single random split, improve the generalization ability of anomaly detection, and adapt to equipment status detection under different working conditions.
[0140] Step S5.4: For the current data point in the deviation distance value sequence, traverse each isolated tree in the isolated forest decision tree set, calculate the path length of the current data point from the root node to the leaf node, and obtain the path length estimate set of the current data point.
[0141] Preferably, for the current data point, traverse all isolated trees and calculate the number of nodes traversed from the root node to the leaf node to obtain a set of path length estimates for the data point. The shorter the path length, the more likely the data point is to be isolated in advance, and the higher its probability of being abnormal.
[0142] Step S5.5: Calculate the arithmetic mean of the path length estimates set for the current data point and convert it into anomaly scores to obtain the initial anomaly score of the frame image corresponding to the current data point.
[0143] Preferably, the arithmetic mean of the path length estimates is calculated, and combined with a harmonic series correction term, the average path length is transformed into a standardized outlier score in the 0-1 interval. The calculation formula is as follows:
[0144] Where E(h(x)) is the average path length of all isolated trees. Here, H is the sample size correction term, and H is the harmonic series. The closer this score is to 1, the higher the degree of anomaly of the data points.
[0145] Step S5.6: Repeat steps S5.4 to S5.5 to traverse all data points in the deviation distance value sequence to obtain the initial set of abnormal score values corresponding to each frame of image.
[0146] Preferably, the process of repeating path length calculation and anomaly score conversion is carried out by traversing all data points in the deviation distance sequence, completing the anomaly scoring of all test frames, and obtaining the initial set of anomaly score values corresponding to each frame image, covering the anomaly degree quantification results of all test frames.
[0147] Step S5.7: Sort the initial set of anomaly scores corresponding to each frame of image according to the original image acquisition timestamp to form an anomaly score sequence with the same time order as the deviation distance value sequence.
[0148] Preferably, all initial values of abnormal scores are sorted in ascending order according to the acquisition timestamps of the original test images to form an abnormal score sequence that is completely consistent with the time order of the deviation distance sequence. This preserves the temporal correlation characteristics of the data, provides correct temporal input for subsequent anomaly judgment, and avoids misjudgment caused by temporal misalignment.
[0149] Beneficial effects of steps S5.1 to S5.7: This series of steps quantifies the degree of anomaly based on deviation distance sequences, identifying abnormal fluctuations in data without requiring anomaly sample labeling, thus improving the ability to perceive subtle changes in equipment operating status. It reduces the risk of misjudgment by a single model through ensemble learning, providing more discriminative quantitative indicators for subsequent anomaly detection and enhancing the reliability of verification results.
[0150] The process involves the following steps: Step S5.1 Initializes the model and sets basic parameters to provide a standardized framework for subsequent training; Step S5.2 Constructs a training dataset that meets the algorithm requirements, ensuring the input data format is compliant; Step S5.3 Constructs multiple isolated trees to form an integrated structure, improving the generalization ability of anomaly detection; Step S5.4 Calculates the path length of a single data point in each isolated tree, reflecting the relative isolation degree of the data point; Step S5.5 Integrates the calculation results of multiple trees and converts them into a unified anomaly score index; Step S5.6 Traverses all data points to complete anomaly scoring, obtaining a set of anomaly scores for the entire sequence; Step S5.7 Organizes the anomaly scores in chronological order, preserving the temporal correlation characteristics of the data.
[0151] Step S6: Compare the abnormal score sequence with the hypersphere radius threshold one by one, mark the frames with abnormal scores exceeding the hypersphere radius threshold as unqualified frames, and calculate the proportion of unqualified frames to the total number of frames to obtain the verification failure rate of the industrial appearance inspection equipment to be verified.
[0152] Preferably, this step completes the determination of abnormal scores and the quantitative output of verification results, realizing an automated closed loop in the verification process and eliminating the influence of subjective human judgment. Its output of standardized verification indicators facilitates horizontal and vertical comparisons of verification results from different devices and at different times, providing a clear basis for equipment status assessment and fault location.
[0153] Furthermore, step S6 specifically includes the following steps: Step S6.1: Determine whether the anomaly score of the current frame exceeds the hypersphere radius threshold, and obtain the Boolean value of the comparison result of the current frame.
[0154] Preferably, the anomaly score of the current frame is extracted and compared numerically with the hypersphere radius threshold obtained from the SVDD model training to obtain a Boolean value of the binary comparison result for the current frame. This threshold is automatically learned from the training data of normal devices, without the need for manual setting, ensuring the objectivity of the judgment benchmark and avoiding bias caused by human experience.
[0155] Step S6.2: If the comparison result of the current frame is true (boolean value), generate an unqualified flag identifier for the current frame and associate the unqualified flag identifier with the corresponding current frame.
[0156] Preferably, if the comparison result of the current frame is true (i.e., the anomaly score exceeds the judgment threshold), an unqualified marker identifier is generated for the current frame, using binary 1 as the marker value. Simultaneously, this marker is associated with the metadata of the current frame (light intensity, shooting angle, and acquisition timestamp) to retain data for subsequent fault location analysis, facilitating the location of equipment faults under specific operating conditions.
[0157] Step S6.3: If the comparison result of the current frame is false (Boolean value), generate a qualified marker identifier for the current frame and associate the qualified marker identifier with the current frame to obtain the marker status of the current frame.
[0158] Preferably, if the comparison result of the current frame is false (i.e., the anomaly score does not exceed the judgment threshold), a qualified marker identifier is generated for the current frame, using binary 0 as the marker value. This marker is then associated with the metadata of the current frame to complete the state differentiation of a single frame and ensure the integrity of the state information for all frames.
[0159] Step S6.4: Repeat steps S6.1 to S6.3 to traverse all frames in the abnormal score sequence and obtain the set of marked states for all frames.
[0160] Preferably, the process of single-frame comparison and status marking is repeated, traversing all test frames in the abnormal score sequence, completing the status marking of all frames, obtaining the marked status set of all frames, covering the status judgment results of all test frames, and automatically skipping invalid frames marked in step S1 during the process to avoid interference from invalid data.
[0161] Step S6.5: Count the number of frames with invalid flag identifiers in the flag state set to obtain the number of invalid frames.
[0162] Preferably, the total number of unqualified tags in the marked state set is counted to obtain the total number of unqualified frames, providing basic statistical data for the final calculation of verification indicators. The statistical process only counts the marking results of valid frames, filtering out interference from invalid frames to ensure the accuracy of the statistical results.
[0163] Step S6.6: Count the total number of frames in the marked state set, and divide the number of unqualified frames by the total number of frames to obtain the verification failure rate of the industrial appearance inspection equipment to be verified.
[0164] Preferably, the total number of valid frames in the set of marked states is counted, and the number of unqualified frames is divided by the total number of valid frames to obtain the verification failure rate of the industrial appearance inspection equipment to be verified, which is then output as the final verification conclusion.
[0165] Preferably, the non-compliance rate is a standardized quantitative indicator that can be directly used to compare verification results of different devices at different times, supporting equipment status assessment and predictive maintenance. At the same time, it can automatically generate verification reports and realize digital traceability of the verification process.
[0166] Beneficial effects of steps S6.1 to S6.6: This series of steps completes the determination of anomaly scores and the quantitative output of verification results, realizing an automated closed-loop verification process and eliminating the influence of subjective human judgment. Its standardized verification indicators facilitate horizontal and vertical comparisons of verification results from different devices and at different times, providing a clear basis for equipment status assessment.
[0167] The process includes the following steps: Step S6.1 compares the single-frame anomaly score with the judgment threshold to obtain a clear binary judgment result; Step S6.2 generates corresponding tags for abnormal frames to accurately identify unqualified samples; Step S6.3 generates corresponding tags for normal frames to distinguish the states of all samples; Step S6.4 traverses all data points to form a complete set of frame state tags; Step S6.5 counts the number of unqualified frames to provide basic data for the final index calculation; and Step S6.6 calculates the proportion of unqualified frames and outputs a quantitative verification conclusion that can be directly used for equipment evaluation.
[0168] In summary, the overall beneficial effects of steps S1 to S6 of this application are as follows: This method replaces the traditional manual verification process, reducing on-site workload, eliminating verification deviations caused by insufficient consistency of manual samples, and avoiding the challenges of fragile physical samples, mixing, and management. The method relies entirely on data processing for verification, enabling digital retention and traceability of the verification process. It also provides data support for subsequent equipment fault location, improving the stability and standardization of quality control in tobacco packaging production.
[0169] Step S1 eliminates irrelevant interference factors in the original image, providing a unified data foundation for subsequent feature extraction; Step S2 mines the intrinsic features of the image from the frequency domain dimension, improving the ability to perceive subtle appearance differences; Step S3 establishes a single-class boundary model based on normal equipment output data, forming an objective and unified verification benchmark; Step S4 quantifies the deviation of the test data from the benchmark boundary, realizing the numerical representation of the verification results; Step S5 identifies abnormal fluctuations in the data sequence, enhancing the ability to detect intermittent equipment failures; Step S6 outputs the final verification conclusion through quantitative statistics, ensuring the objectivity and comparability of the verification results.
[0170] like Figure 2 As shown, this embodiment provides an embodiment of a verification device for industrial appearance inspection equipment. In this embodiment, the verification device is applied to the verification method as described in the above embodiment.
[0171] Specifically, the verification device includes an appearance inspection equipment data acquisition module 1, a frequency domain feature matrix acquisition module 2, a hypersphere parameter calculation module 3, a deviation distance value sequence calculation module 4, a deviation distance value scoring module 5, and a verification failure rate statistics module 6, which are connected electrically or through communication in sequence.
[0172] The system comprises the following modules: Appearance Inspection Equipment Data Acquisition Module 1, which acquires multiple frames of images of the standard verification board of the industrial appearance inspection equipment under different light intensities and shooting angles, and performs data preprocessing on these images to obtain a preprocessed image set; Frequency Domain Feature Matrix Acquisition Module 2, which extracts the amplitude and phase spectra of each image in the preprocessed image set through Fourier spectrum analysis, and then stitches, flattens, and aligns them to obtain the first frequency domain feature matrix; Hypersphere Parameter Calculation Module 3, which inputs the first frequency domain feature matrix into the SVDD model for single-class boundary modeling, and maps the output data distribution of the normal inspection equipment to the hypersphere in the high-dimensional feature space by minimizing the hypersphere radius, thus obtaining the hypersphere center vector and the hypersphere radius threshold; and Deviation Distance Value Sequence. The column calculation module 4 is used to input the second frequency domain feature matrix obtained after the pre-acquired verification test image has been processed by the frequency domain feature matrix acquisition module and the hypersphere parameter calculation module into the SVDD model, calculate the Euclidean distance between the vector in the second frequency domain feature matrix and the hypersphere center vector, and obtain the deviation distance value sequence; the deviation distance value scoring module 5 is used to score the abnormality of each deviation distance value in the deviation distance value sequence using the isolated forest algorithm, and obtain the abnormal score sequence corresponding to each frame; the verification failure rate statistics module 6 is used to compare the abnormal score sequence with the hypersphere radius threshold one by one, mark the frames with abnormal scores exceeding the hypersphere radius threshold as unqualified frames, and calculate the proportion of unqualified frames to the total number of frames to obtain the verification failure rate of the industrial appearance inspection equipment to be verified.
[0173] Figure 3This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Figure 3 As shown, the electronic device 7 includes a processor 71 and a memory 72 coupled to the processor 71.
[0174] The memory 72 stores program instructions for implementing the verification method of the industrial appearance inspection equipment of any of the above embodiments.
[0175] The processor 71 is used to execute program instructions stored in the memory 72 for the verification of industrial appearance inspection equipment.
[0176] The processor 71 can also be referred to as a CPU (Central Processing Unit). The processor 71 may be an integrated circuit chip with signal processing capabilities. The processor 71 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor.
[0177] Furthermore, Figure 4 This is a schematic diagram of the structure of a storage medium according to an embodiment of this application. See also: Figure 4 The storage medium 8 in this embodiment stores program instructions 81 capable of implementing all the above methods. These program instructions 81 can be stored in the storage medium as a software product and include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to perform all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, or terminal devices such as computers, servers, mobile phones, and tablets.
[0178] In the several embodiments provided in this application, it should be understood that the disclosed apparatus, devices, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or omitted. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, signal, or other forms.
[0179] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated units described above can be implemented in hardware or as software functional units. The above are merely embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made based on the description and drawings of this application, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A verification method for industrial appearance inspection equipment, characterized in that, The verification method includes: Step S1: Collect multiple frames of images of the standard verification board of the industrial appearance inspection equipment to be verified under different light intensities and shooting angles, and perform data preprocessing on the multiple frames of images to obtain a preprocessed image set. Step S2: Extract the amplitude spectrum and phase spectrum of each image in the preprocessed image set through Fourier spectrum analysis, and then flatten and connect them after splicing to obtain the first frequency domain feature matrix. Step S3: Input the first frequency domain feature matrix into the SVDD model to perform single-class boundary modeling. By minimizing the hypersphere radius, the output data distribution of the normal detection device is mapped to the hypersphere in the high-dimensional feature space to obtain the hypersphere center vector and the hypersphere radius threshold. Step S4: Input the second frequency domain feature matrix obtained after processing the pre-acquired verification test image in the same way as in steps S1 to S2 into the SVDD model, calculate the Euclidean distance between the vector in the second frequency domain feature matrix and the center vector of the hypersphere, and obtain the deviation distance value sequence. Step S5: The anomaly score of each deviation distance value in the deviation distance value sequence is obtained by using the isolated forest algorithm to obtain the anomaly score sequence corresponding to each frame; Step S6: Compare the abnormal score sequence with the hypersphere radius threshold one by one, mark the frames with abnormal scores exceeding the hypersphere radius threshold as unqualified frames, and calculate the proportion of unqualified frames to the total number of frames to obtain the verification failure rate of the industrial appearance inspection equipment to be verified.
2. The verification method according to claim 1, characterized in that, Step S1: Acquire multiple frames of images of the standard verification board under different light intensities and shooting angles using the industrial appearance inspection equipment to be verified, and perform data preprocessing on the multiple frames of images to obtain a preprocessed image set, including: Step S1.1: Place the standard verification board on the inspection station of the industrial appearance inspection equipment to be verified, and trigger the image acquisition function of the inspection equipment in sequence according to the preset combination of light intensity gradient and shooting angle to obtain the original multi-frame image sequence. Step S1.2: Read the RGB channel data of each frame in the original multi-frame image sequence, and combine the three-channel pixel values into a single-channel grayscale value by weighted averaging to obtain a grayscale image sequence; Step S1.3: Map the grayscale values of each frame in the grayscale image sequence to the range of 0 to 255 by Min-Max linear scaling to obtain a grayscale normalized image sequence; Step S1.4: The intrinsic parameter matrix and distortion coefficients of the industrial appearance inspection equipment to be verified are calibrated using the Zhang Zhengyou calibration method to obtain the camera intrinsic parameter matrix and distortion coefficient vector; Step S1.5: Substitute the camera intrinsic parameter matrix and the distortion coefficient vector into the distortion correction mapping function to perform pixel remapping on each frame of the grayscale normalized image sequence to obtain the distortion corrected image sequence. Step S1.6: Sort the distortion-corrected image sequence according to the acquisition timestamp and summarize it to obtain a preprocessed image set.
3. The verification method according to claim 1, characterized in that, Step S2: Extract the amplitude and phase spectra of each image in the preprocessed image set using Fourier spectrum analysis, and then stitch, flatten, and connect them to obtain the first frequency domain feature matrix, including: Step S2.1: Read each distortion correction image sequentially from the preprocessed image set, and perform a two-dimensional discrete Fourier transform on the gray-level pixel matrix of each frame image to obtain the corresponding two-dimensional complex frequency domain matrix. Step S2.2: Calculate the magnitude of each complex element in the two-dimensional complex frequency domain matrix, and rearrange the magnitudes of all complex elements according to the same matrix dimension to obtain the amplitude spectrum matrix of each frame image; Step S2.3: Calculate the argument of each complex element in the two-dimensional complex frequency domain matrix, and rearrange the arguments of all complex elements according to the same matrix dimension to obtain the phase spectrum matrix of each frame image; Step S2.4: The amplitude spectrum matrix and phase spectrum matrix of each frame image are concatenated according to the channel dimension to obtain the dual-channel spectrum matrix of each frame image; Step S2.5: Flatten the dual-channel spectral matrix of each frame image and arrange all elements of the matrix into a one-dimensional vector according to row priority to obtain the one-dimensional spectral vector of each frame image. Step S2.6: The one-dimensional spectrum vector of each frame image is appended sequentially according to the order in which the original image appears in the preprocessed image set, forming a first frequency domain feature matrix in the form of a multi-row, single-column data table.
4. The verification method according to claim 1, characterized in that, Step S3: Input the first frequency domain feature matrix into the SVDD model for single-class boundary modeling. By minimizing the hypersphere radius, the output data distribution of the normal detection device is mapped to the hypersphere in the high-dimensional feature space to obtain the hypersphere center vector and the hypersphere radius threshold, including: Step S3.1: Initialize the SVDD model and input the first frequency domain feature matrix into the SVDD model. Map each feature vector in the first frequency domain feature matrix to a high-dimensional regenerating kernel Hilbert space through a kernel function to obtain a high-dimensional feature mapping matrix containing several support vectors. Step S3.2: Define a minimum hypersphere containing all support vectors in the high-dimensional feature mapping matrix, and solve the problem of minimizing the volume of the hypersphere using the Lagrange multiplier method to obtain the hypersphere optimization objective function; Step S3.3: Solve the hypersphere optimization objective function iteratively using the sequential minimum optimization algorithm. In each iteration, select any pair of Lagrange multipliers for updating until convergence is obtained to obtain the optimal Lagrange multiplier vector. Step S3.4: Calculate the weighted combination of support vectors based on the optimal Lagrange multiplier vectors, and sum the feature vectors corresponding to all non-zero Lagrange multipliers according to their weights to obtain the hypersphere center vector; Step S3.5: Select any support vector from the high-dimensional feature mapping matrix and calculate the Euclidean distance from the selected support vector to the center vector of the hypersphere to obtain the hypersphere radius threshold. Step S3.6: Store the hypersphere center vector and the hypersphere radius threshold as SVDD model parameters to obtain the single-class boundary modeling of the SVDD model.
5. The verification method according to claim 1, characterized in that, Step S4: Input the second frequency domain feature matrix obtained after processing the pre-acquired verification test image in the same way as in steps S1 to S2 into the SVDD model, calculate the Euclidean distance between the vector in the second frequency domain feature matrix and the center vector of the hypersphere, and obtain the deviation distance value sequence, including: Step S4.1: Collect verification test images of the industrial appearance inspection equipment to be verified, and perform data preprocessing on the verification test images to obtain a set of preprocessed verification test images; Step S4.2: Extract the amplitude spectrum and phase spectrum of each image in the verification test preprocessed image set through Fourier spectrum analysis, and then flatten and connect them to obtain the second frequency domain feature matrix. Step S4.3: Read the hypersphere center vector from the SVDD model parameters, and divide the second frequency domain feature matrix by rows to obtain the second frequency domain feature vector corresponding to each frame image; Step S4.4: Calculate the Euclidean distance between the second frequency domain feature vector corresponding to each frame image and the center vector of the hypersphere to obtain the initial value of the deviation distance for each frame image; Step S4.5: Sort the initial values of the deviation distance of all frame images according to the timestamp of the verification test image acquisition to form a numerical sequence that increases in time, and obtain the deviation distance value sequence of each frame image.
6. The verification method according to claim 1, characterized in that, Step S5: Anomaly scoring is performed on each deviation distance value in the deviation distance value sequence using the isolated forest algorithm to obtain an anomaly score sequence corresponding to each frame, including: Step S5.1: Initialize the isolated forest model by setting the number of samples per tree and the upper limit of the number of samples per tree to obtain the initial isolated forest model; Step S5.2: Input the deviation distance value sequence into the initial isolated forest model, and construct the isolated forest training dataset by analyzing the dimension and numerical distribution of each data point; Step S5.3: Recursively partition the isolated forest training dataset using a binary tree structure, randomly select features and split points to continuously divide the subspace into left and right regions, construct multiple isolated trees trained separately, and obtain an isolated forest decision tree set. Step S5.4: For the current data point in the deviation distance value sequence, traverse each isolated tree in the isolated forest decision tree set, calculate the path length of the current data point from the root node to the leaf node, and obtain the path length estimate set of the current data point. Step S5.5: Calculate the arithmetic mean of the path length estimates set for the current data point and convert it into anomaly scores to obtain the initial anomaly score of the frame image corresponding to the current data point. Step S5.6: Repeat steps S5.4 to S5.5 to traverse all data points in the deviation distance value sequence to obtain the initial set of abnormal score values corresponding to each frame of image; Step S5.7: Sort the set of initial abnormal scores corresponding to each frame of image according to the original image acquisition timestamp to form an abnormal score sequence with the same time order as the deviation distance value sequence.
7. The verification method according to claim 1, characterized in that, Step S6: Compare the abnormal score sequence with the hypersphere radius threshold one by one, mark frames with abnormal scores exceeding the hypersphere radius threshold as unqualified frames, and calculate the proportion of unqualified frames to the total number of frames to obtain the verification failure rate of the industrial appearance inspection equipment to be verified, including: Step S6.1: Determine whether the anomaly score of the current frame exceeds the hypersphere radius threshold, and obtain the Boolean value of the comparison result of the current frame; Step S6.2: If the comparison result of the current frame is true (Boolean value), generate an unqualified flag identifier for the current frame and associate the unqualified flag identifier with the corresponding current frame. Step S6.3: If the comparison result of the current frame is false (Boolean value), generate a qualified marker identifier for the current frame and associate the qualified marker identifier with the current frame to obtain the marking status of the current frame; Step S6.4: Repeat steps S6.1 to S6.3 to traverse all frames in the abnormal score sequence to obtain the set of marked states for all frames; Step S6.5: Count the number of frames with invalid flag identifiers in the flag state set to obtain the number of invalid frames; Step S6.6: Count the total number of frames in the marked state set, and divide the number of unqualified frames by the total number of frames to obtain the verification failure rate of the industrial appearance inspection equipment to be verified.
8. A verification device for industrial appearance inspection equipment, wherein the verification device is applied to the verification method as described in any one of claims 1 to 7, characterized in that, The verification device includes: The appearance inspection equipment data acquisition module is used to acquire multiple frames of images of the standard verification board of the industrial appearance inspection equipment to be verified under different light intensities and different shooting angles, and to perform data preprocessing on the multiple frames of images to obtain a preprocessed image set. The frequency domain feature matrix acquisition module is used to extract the amplitude spectrum and phase spectrum of each image in the preprocessed image set through Fourier spectrum analysis, and then flatten and connect them to obtain the first frequency domain feature matrix. The hypersphere parameter calculation module is used to input the first frequency domain feature matrix into the SVDD model for single-class boundary modeling, and to map the output data distribution of the normal detection device to the hypersphere in the high-dimensional feature space by minimizing the hypersphere radius, thereby obtaining the hypersphere center vector and the hypersphere radius threshold. The deviation distance value sequence calculation module is used to input the second frequency domain feature matrix obtained after the pre-acquired verification test image has been processed by the frequency domain feature matrix acquisition module and the hypersphere parameter calculation module into the SVDD model, calculate the Euclidean distance between the vector in the second frequency domain feature matrix and the center vector of the hypersphere, and obtain the deviation distance value sequence. The deviation distance value scoring module is used to score the anomalies of each deviation distance value in the deviation distance value sequence using the isolated forest algorithm, so as to obtain the anomaly score sequence corresponding to each frame. The verification failure rate statistics module is used to compare the abnormal score sequence with the hypersphere radius threshold one by one, mark the frames with abnormal scores exceeding the hypersphere radius threshold as unqualified frames, and calculate the proportion of unqualified frames to the total number of frames to obtain the verification failure rate of the industrial appearance inspection equipment to be verified.
9. An electronic device, characterized in that, The method includes a processor and a memory coupled to the processor, the memory storing program instructions that can be executed by the processor; when the processor executes the program instructions stored in the memory, it implements the verification method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program instructions that, when executed by a processor, enable the verification method as described in any one of claims 1 to 7.