Graphical contour detection method, system, storage medium and apparatus for industrial products

CN122066968BActive Publication Date: 2026-10-16HANGZHOU HUICUI INTELLIGENT TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202610525583.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-04-21
Publication Date
2026-10-16
Estimated Expiration
2046-04-21

AI Technical Summary

Technical Problem

[0004]本发明的目的是提供一种工业产品的图形轮廓检测方法、系统、存储介质和装置,用于解决传统轮廓检测方法对环境干扰敏感、对几何形变适应性差、参数调试复杂、在低对比度场景下性能不足以及判断逻辑单一缺乏智能性的问题

Benefits of technology

[0060] 1. Extremely robust: Since deep features are a high-level abstraction of the essence of the contour, they are not sensitive to changes in lighting, background noise and color. The network has already seen various changes during training, so it has learned to ignore these disturbances and focus on the structural information of the contour itself.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122066968B_ABST
    Figure CN122066968B_ABST
Patent Text Reader

Abstract

The application discloses a kind of industrial product's graphic contour detection method, system, storage medium and device, wherein method includes: obtaining the product image collected and pre-processing to obtain standard image;The standard image is input into the feature extraction network trained to obtain feature vector;Similar feature vector is obtained based on multidimensional similarity calculation of the feature vector and the feature library constructed;The detection result is obtained based on the similar feature vector input into the preset context perception decision maker, and the detection result includes binary label and / or confidence score.The application realizes high-precision, high-robustness intelligent detection of industrial product contour detection, significantly reduces the dependence on manual parameter adjustment, improves the detection accuracy and adaptability in low contrast, edge blur and other complex scenes, and forms an end-to-end, scalable and intelligent industrial vision detection solution.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and more specifically, to a method, system, storage medium, and apparatus for detecting the graphic contours of industrial products. Background Technology

[0002] In the field of industrial automation, detecting the presence or absence of specific graphic contours on products or their components is a fundamental and crucial task. Such applications are widely used in assembly verification (such as confirming that a part has been installed), label affixing inspection, determining the absence of pads or traces on printed circuit boards (PCBs), and identifying anti-counterfeiting labels on packaging.

[0003] The goal of detection is to make a rapid binary decision: whether a specified contour feature exists. However, in real industrial environments, this seemingly simple task faces many challenges: fluctuations in light intensity and angle, positional deviations and rotations of the product itself, interference from background textures, and minor deformations or edge blurring of the contour to be tested due to manufacturing processes. Summary of the Invention

[0004] The purpose of this invention is to provide a method, system, storage medium, and device for detecting the graphic contours of industrial products, which solves the problems of traditional contour detection methods such as sensitivity to environmental interference, poor adaptability to geometric deformation, complex parameter tuning, insufficient performance in low-contrast scenes, and lack of intelligence in simple judgment logic.

[0005] The first aspect of this invention provides a method for detecting the graphic contour of an industrial product, comprising the following steps:

[0006] Acquire product images and preprocess them to obtain standard images;

[0007] The standard image is input into a trained feature extraction network to obtain a feature vector;

[0008] Based on the aforementioned feature vectors and the constructed feature library, multi-dimensional similarity calculations are performed to obtain similar feature vectors;

[0009] The detection results are obtained by inputting the similar feature vectors into a preset context-aware decision-maker. The detection results include binary labels and / or confidence scores.

[0010] In this solution, the step of acquiring and preprocessing the collected product images to obtain standard images specifically includes:

[0011] The product image is obtained by acquiring the original digital image of the product captured by a preset industrial camera.

[0012] The standard image is obtained by performing region of interest extraction, grayscale conversion, size normalization, illumination compensation, and noise suppression on the product image.

[0013] In this scheme, the step of inputting the standard image into a trained feature extraction network to obtain a feature vector specifically includes:

[0014] Obtain the offline trained feature extraction network ;

[0015] The standard image is input into the feature extraction network, where multidimensional features are pooled into fixed-length features and then normalized to obtain the feature vector. .

[0016] In this solution, constructing the feature library specifically includes:

[0017] A labeled sample set is obtained by collecting sample data and performing filtering and preprocessing. The sample data includes positive sample images and negative sample images.

[0018] The labeled sample set is used to load a training convolutional neural network, wherein a contrastive learning or triplet loss strategy is used for training.

[0019] The trained standard positive sample images are input into the feature extraction network to obtain the feature library. And calculate the feature center of the feature library. ,in, , The number of vectors in the feature library. These are vectors from the feature library.

[0020] In this scheme, the step of obtaining similar feature vectors by performing multi-dimensional similarity calculations based on the feature vectors and the constructed feature library specifically includes:

[0021] Multi-dimensional similarity calculation includes calculating the distance between the feature vector and the center of the feature library, the distance to the nearest neighbor of the feature library, and the consistency of the feature space.

[0022] Calculating the distance to the feature library center specifically includes calculating the Euclidean distance between the feature vector and the feature library center. ;

[0023] Calculating the distance to the nearest neighbor in the feature library specifically includes calculating the minimum Euclidean distance from the feature vector to all vectors in the feature library. ;

[0024] Calculating feature space consistency specifically includes calculating the degree of dispersion of the distances between the feature vector and all vectors in the feature library, wherein the degree of dispersion... , , It is the average distance. The number of vectors in the feature library. The vectors in the feature library, For feature vectors;

[0025] Based on the Euclidean distance between the feature vector and the center of the feature library The minimum Euclidean distance from the feature vector to all vectors in the feature library. and degree of dispersion The similar feature vectors are obtained. .

[0026] In this scheme, obtaining the detection result by inputting the similar feature vector into a preset context-aware decision-maker specifically includes:

[0027] Obtain an offline-trained context-aware decision-maker, which is a lightweight model;

[0028] The similar feature vectors are input into the context-aware decision-maker for feature concatenation, forward inference, and decision threshold judgment to obtain the detection result. The threshold judgment is based on the confidence score to output whether there is a contour, and / or the output is based on the binary label to output whether there is a contour.

[0029] A second aspect of the present invention also provides a graphic contour detection system for industrial products, including a memory and a processor. The memory includes a graphic contour detection method program for industrial products, which, when executed by the processor, performs the following steps:

[0030] Acquire product images and preprocess them to obtain standard images;

[0031] The standard image is input into a trained feature extraction network to obtain a feature vector;

[0032] Based on the aforementioned feature vectors and the constructed feature library, multi-dimensional similarity calculations are performed to obtain similar feature vectors;

[0033] The detection results are obtained by inputting the similar feature vectors into a preset context-aware decision-maker. The detection results include binary labels and / or confidence scores.

[0034] In this solution, the step of acquiring and preprocessing the collected product images to obtain standard images specifically includes:

[0035] The product image is obtained by acquiring the original digital image of the product captured by a preset industrial camera.

[0036] The standard image is obtained by performing region of interest extraction, grayscale conversion, size normalization, illumination compensation, and noise suppression on the product image.

[0037] In this scheme, the step of inputting the standard image into a trained feature extraction network to obtain a feature vector specifically includes:

[0038] Obtain the offline trained feature extraction network ;

[0039] The standard image is input into the feature extraction network, where multidimensional features are pooled into fixed-length features and then normalized to obtain the feature vector. .

[0040] In this solution, constructing the feature library specifically includes:

[0041] A labeled sample set is obtained by collecting sample data and performing filtering and preprocessing. The sample data includes positive sample images and negative sample images.

[0042] The labeled sample set is used to load a training convolutional neural network, wherein a contrastive learning or triplet loss strategy is used for training.

[0043] The trained standard positive sample images are input into the feature extraction network to obtain the feature library. And calculate the feature center of the feature library. ,in, , The number of vectors in the feature library. These are vectors from the feature library.

[0044] In this scheme, the step of obtaining similar feature vectors by performing multi-dimensional similarity calculations based on the feature vectors and the constructed feature library specifically includes:

[0045] Multi-dimensional similarity calculation includes calculating the distance between the feature vector and the center of the feature library, the distance to the nearest neighbor of the feature library, and the consistency of the feature space.

[0046] Calculating the distance to the feature library center specifically includes calculating the Euclidean distance between the feature vector and the feature library center. ;

[0047] Calculating the distance to the nearest neighbor in the feature library specifically includes calculating the minimum Euclidean distance from the feature vector to all vectors in the feature library. ;

[0048] Calculating feature space consistency specifically includes calculating the degree of dispersion of the distances between the feature vector and all vectors in the feature library, wherein the degree of dispersion... , , It is the average distance. The number of vectors in the feature library. The vectors in the feature library, For feature vectors;

[0049] Based on the Euclidean distance between the feature vector and the center of the feature library The minimum Euclidean distance from the feature vector to all vectors in the feature library. and degree of dispersion The similar feature vectors are obtained. .

[0050] In this scheme, obtaining the detection result by inputting the similar feature vector into a preset context-aware decision-maker specifically includes:

[0051] Obtain an offline-trained context-aware decision-maker, which is a lightweight model;

[0052] The similar feature vectors are input into the context-aware decision-maker for feature concatenation, forward inference, and decision threshold judgment to obtain the detection result. The threshold judgment is based on the confidence score to output whether there is a contour, and / or the output is based on the binary label to output whether there is a contour.

[0053] A third aspect of the present invention provides a computer-readable storage medium comprising a program for detecting the graphic contour of an industrial product, wherein when executed by a processor, the program implements the steps of the graphic contour detection method for an industrial product as described in any of the preceding claims.

[0054] A fourth aspect of the present invention provides a graphic contour detection device for industrial products, comprising:

[0055] Optical imaging module and detection module, wherein,

[0056] The optical imaging module includes an industrial camera and a light source, wherein the industrial camera is used to acquire images and the light source is used to provide illumination;

[0057] The detection module includes an industrial computer with a high-performance GPU, used to implement the steps of the graphic contour detection method for an industrial product as described above.

[0058] In this solution, the device further includes a fixing module, which is used to support the industrial camera and the light source, wherein the fixing module includes a mechanical structure.

[0059] The present invention discloses a method, system, storage medium, and apparatus for detecting the graphic contour of industrial products, which has the following beneficial effects:

[0060] 1. Extremely robust: Since deep features are a high-level abstraction of the essence of the contour, they are not sensitive to changes in lighting, background noise and color. The network has already seen various changes during training, so it has learned to ignore these disturbances and focus on the structural information of the contour itself.

[0061] 2. Excellent deformation tolerance: The feature space trained through contrastive learning has natural invariance to translation, rotation, scaling and deformation within the allowable range of the target contour. As long as the contour to be tested is visually judged as "the same" contour, its feature vector will fall in the neighborhood of the feature library.

[0062] 3. Parameter tuning is greatly simplified: very few parameters need to be set manually. Most of the "knowledge" has been solidified into the network weights and feature library through offline training. When facing product changes, usually only the feature library needs to be updated, which greatly reduces maintenance costs and debugging time.

[0063] 4. Enhanced ability to handle blurred and low-contrast contours: Deep learning networks can learn and extract richer hierarchical features from images than traditional gradients. Even if the edges are not clear, the network may infer the existence of contours from information such as regional texture and global context, thus maintaining a high detection rate in low-contrast scenes.

[0064] 5. A smarter and more reliable decision-making mechanism: Based on multi-dimensional similarity measurement and machine learning decision-makers, it avoids the arbitrariness of single threshold judgment, can comprehensively consider the overall relationship between test samples and standard sample sets, and handles critical situations more reasonably and accurately, reducing the misjudgment rate.

[0065] 6. High versatility and scalability: The method framework of this invention does not depend on a specific contour shape. By changing the training data and feature library, it can be applied to various contour detection tasks, demonstrating strong versatility. Attached Figure Description

[0066] Figure 1 This invention illustrates the steps of a graphic contour detection method for an industrial product according to the present invention.

[0067] Figure 2 A flowchart illustrating a graphic contour detection method for an industrial product according to the present invention is shown.

[0068] Figure 3 A block diagram of a graphic contour detection system for industrial products according to the present invention is shown.

[0069] Figure 4 A schematic diagram of the composition of a graphic contour detection device for an industrial product according to the present invention is shown.

[0070] Component designation: 40 Graphic contour detection device for industrial products; 41 Optical imaging module; 411 Industrial camera; 412 Light source; 42 Detection module; 421 Industrial computer; 43 Fixing module; 431 Mechanical structure. Detailed Implementation

[0071] To better understand the above-mentioned objectives, features, and advantages of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, unless otherwise specified, the embodiments of the present invention and the features thereof can be combined with each other.

[0072] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and therefore the scope of protection of the invention is not limited to the specific embodiments disclosed below.

[0073] Traditional machine vision contour detection methods primarily rely on classic image processing algorithms, employing a series of preprocessing, edge extraction, and feature matching steps. The most similar implementations include edge detection operator-based methods, template matching-based methods, and image differencing-based methods.

[0074] Specifically, the background technology and existing technical solution one: The method based on edge detection operators is the most direct and traditional approach to contour detection. Its core is to utilize various gradient operators to highlight edge information in the image, and then determine the existence of the target contour by connecting and filtering edge points. Commonly used edge detection operators include Sobel, Prewitt, Laplacian, and the more advanced Canny operator. Taking the Canny operator as an example, its process typically includes:

[0075] 1) Apply a Gaussian filter to the original image Perform smoothing and noise reduction to obtain ;

[0076] 2) Calculate the gradient magnitude of the image. and direction :

[0077] ; ; ; in, The image after smoothing;

[0078] 3) Perform non-maximum suppression on the gradient magnitude to refine the edges;

[0079] 4) Apply dual thresholds (high threshold) and low threshold Edge concatenation and hysteresis thresholding are performed to obtain a binarized edge image. .

[0080] After obtaining the edge map, the algorithm uses the Hough Transform to detect specific shapes (such as lines and circles) or extracts connected components using a contour tracking algorithm. It then compares the geometric features of the connected components, such as area, perimeter, and circularity, with preset conditions to determine if the target contour exists. The advantage of this method is its intuitive principle and good performance for contours with high contrast and clear edges. However, its disadvantages are significant: First, it is very sensitive to parameters (such as Gaussian kernel size and Canny's dual thresholds), requiring tedious manual adjustments for different scenes. Second, in situations with uneven lighting, complex backgrounds, or blurred edges, it is prone to edge breakage or extracting a large number of irrelevant background edges, making subsequent feature matching and judgment extremely difficult and exhibiting poor robustness.

[0081] And background technology and existing technology solution 2: rigid template matching method, which is widely used in industrial vision. Its basic idea is to pre-acquire a "golden template" image or region containing the target contour. During detection, by examining the image to be inspected... Slide this template and calculate each position. Similarity measures are used to find the best matching position and score. The most commonly used similarity measure is the Normalized Cross-Correlation (NCC), which is calculated as follows:

[0082] ;

[0083] in, It is the average pixel value of the template. It is the average pixel value of the current window region of the image to be inspected. The maximum value exceeds the preset threshold. When the target contour is considered to exist, it is assumed to exist. Template matching works well for scenes with fixed positions and angles and stable imaging conditions. However, its limitation lies in its "rigidity": once the target contour undergoes even a slight rotation, scaling, or deformation due to perspective effects relative to the template, the matching accuracy drops sharply. Furthermore, this method is also sensitive to changes in illumination. Although NCC is somewhat invariant to linear illumination changes, nonlinear illumination changes or local shadows can still severely affect the matching results. The high computational cost is also a bottleneck for this method in high-resolution images or scenes with high real-time requirements.

[0084] And background technology and existing technology solution three: image difference-based method, which is suitable for situations where the background is relatively fixed or can be compared with a standard template image. It first requires a standard background image that does not contain the target outline. Alternatively, a standard template image containing a complete outline can be used. During detection, the image to be inspected is acquired. Then, a pixel-by-pixel difference operation is performed between this image and the standard image to obtain the difference image. :

[0085] ;

[0086] Subsequently, the difference image is thresholded, and the calculation formula is as follows: ,in As a differential threshold, in contour "presence / absence" detection, if the goal is to detect the absence of a contour, a significant differential signal is expected to appear in the contour region; conversely, if the goal is to detect the false presence of a contour, differences need to be found in non-contour regions. Finally, the judgment is made by analyzing the size and position of connected regions in the binarized differential image. This method is conceptually simple and computationally fast. However, its success heavily relies on perfect registration (alignment) between the image to be detected and the standard image. Any slight positional shift will generate strong differential pseudo-signals at the edges, interfering with the judgment. At the same time, it is also very sensitive to overall illumination drift and noise, and setting the threshold is also a challenge.

[0087] Through in-depth analysis of the aforementioned existing technical solutions, several key common shortcomings can be clearly summarized in their ability to detect the presence or absence of contours in complex industrial scenarios:

[0088] 1. Poor robustness to environmental interference: Existing methods (especially edge detection and image difference) are extremely sensitive to changes in illumination, fluctuations in background texture, and noise, which can easily lead to incomplete edge extraction or the generation of false edges. Difference methods, on the other hand, can produce a large number of false differences.

[0089] 2. Poor adaptability to geometric deformation: Rigid template matching cannot effectively handle contour rotation, dimensional changes, and minor but permissible deformations. In actual production, minor contour changes caused by product position deviations and mold wear are common, resulting in a high misjudgment rate for fixed template matching methods.

[0090] 3. High parameter dependence and complex debugging and maintenance: Whether it's the threshold in edge detection, the similarity threshold in template matching, or the difference threshold in the difference method, all need to be manually set and optimized by experienced engineers according to the specific scenario. When the production line changes products or environmental conditions change, re-debugging is required, resulting in high maintenance costs.

[0091] 4. Performance drops sharply in cases of blurred outlines or low contrast: When the contrast between the target outline and the background is not high and the edges are blurred, gradient-based methods have difficulty extracting effective edges, and the similarity score of template matching will also decrease significantly, leading to missed detections.

[0092] 5. The judgment logic is simple and lacks intelligence: Most existing methods rely on single, rigid threshold judgments, and cannot make intelligent inferences by comprehensively considering the overall shape of the contour and contextual information like the human eye. They are not capable of judging situations in a "critical" state (such as when most of the contour exists but a small part is missing).

[0093] To address these shortcomings, the present invention aims to provide an intelligent detection method for the presence or absence of graphic contours based on deep feature comparison and context awareness. This invention aims to surpass traditional pixel-level or template-level comparisons by introducing deep learning technology, enabling machines to learn the abstract essential features of contours and their contextual relationship with the surrounding environment. This allows for more robust judgments that are closer to human vision in complex environments. The core innovation and key protection points are as follows:

[0094] 1. A contour feature extraction network training method based on contrastive learning / triple loss: This method is specifically designed for contour presence / absence detection tasks and utilizes a specific process and loss function design to train a CNN feature extractor using metric learning techniques such as triple loss.

[0095] 2. Construction and usage method of standard feature library for contour presence / absence determination: Protect the technical solution of extracting feature vectors from multiple standard positive samples to construct a reference set, and use it as the benchmark for online detection and comparison.

[0096] 3. A multi-dimensional similarity measurement system for online detection: This system specifically protects the simultaneous calculation of the distance between the test sample features and the center of the feature library. Distance to nearest neighbor and feature space clustering degree A combined comparison method.

[0097] 4. Context-aware Decision Maker: This is an intelligent decision-making mechanism that takes multi-dimensional similarity measurement results as input and makes the final judgment on presence or absence through a lightweight machine learning model.

[0098] 5. A complete system process integrating offline training and online detection: from data preparation, network training, feature library construction, to online feature extraction, multi-dimensional comparison, and intelligent decision-making, an end-to-end system architecture and implementation plan.

[0099] Specifically, Figure 1 The diagram illustrates the steps of a graphic contour detection method for an industrial product according to the present invention.

[0100] like Figure 1 As shown, this invention discloses a method for detecting the graphic contour of industrial products, comprising the following steps:

[0101] S102, acquire the collected product image and perform preprocessing to obtain a standard image;

[0102] S104, Input the standard image into the trained feature extraction network to obtain the feature vector;

[0103] S106, Based on the feature vector and the constructed feature library, perform multi-dimensional similarity calculation to obtain a similar feature vector;

[0104] S108, the detection result is obtained by inputting the similar feature vector into a preset context-aware decision-maker.

[0105] It should be noted that, in this embodiment, as Figure 2 The diagram shows a flowchart of a graphic contour detection method for industrial products according to the present invention. It includes an offline training process and an online detection process. The offline training includes a feature extraction network model and a feature library. Further, during online detection, a collected product image is first acquired and preprocessed to obtain a standard image, which is then input as the image to be detected. Specifically, the standard image is input into the trained feature extraction network to obtain a feature vector. Then, based on the feature vector and the constructed feature library, a multi-dimensional similarity calculation is performed to obtain a similar feature vector. Correspondingly, the similar feature vector includes the Euclidean distance between the feature vector and the center of the feature library. The minimum Euclidean distance from the feature vector to all vectors in the feature library. and degree of dispersion Finally, the detection result is obtained by inputting the similar feature vector into a preset context-aware decision-maker. The detection result includes a binary label and / or a confidence score, which enables the output of whether or not there is a graphic contour based on the detection result. The specific process will be described in detail in the following specification.

[0106] According to an embodiment of the present invention, the step of acquiring the collected product image and performing preprocessing to obtain a standard image specifically includes:

[0107] The product image is obtained by acquiring the original digital image of the product captured by a preset industrial camera.

[0108] The standard image is obtained by performing region of interest extraction, grayscale conversion, size normalization, illumination compensation, and noise suppression on the product image.

[0109] It should be noted that, in this embodiment, the preset industrial camera exposes and images under the trigger signal, thus obtaining the original digital image of the product captured by the preset industrial camera to obtain the product image. The product image is then processed by extracting the region of interest, grayscale conversion, size normalization, illumination compensation, and noise suppression to obtain the standard image. Among them, the region of interest extraction is performed by cropping the corresponding target area according to the preset coordinates. Illumination compensation can be achieved by histogram equalization or adaptive gamma correction. Noise suppression can be performed by Gaussian filtering or median filtering if necessary.

[0110] According to an embodiment of the present invention, the step of inputting the standard image into a trained feature extraction network to obtain a feature vector specifically includes:

[0111] Obtain the offline trained feature extraction network ;

[0112] The standard image is input into the feature extraction network, where multidimensional features are pooled into fixed-length features and then normalized to obtain the feature vector. .

[0113] It should be noted that, in this embodiment, the offline-trained feature extraction network is first obtained. Then, the standard image is input into the feature extraction network, wherein the feature extraction network... The forward propagation passes through convolutional layers, pooling layers, and activation layers, extracting features at specific layers of the network (such as after a global average pooling layer). These multidimensional features are pooled into fixed-length features and then normalized to obtain the feature vector. For example, the feature vector is obtained through L2 normalization.

[0114] According to an embodiment of the present invention, constructing the feature library specifically includes:

[0115] A labeled sample set is obtained by collecting sample data and performing filtering and preprocessing. The sample data includes positive sample images and negative sample images.

[0116] The labeled sample set is used to load a training convolutional neural network, wherein a contrastive learning or triplet loss strategy is used for training.

[0117] The trained standard positive sample images are input into the feature extraction network to obtain the feature library. And calculate the feature center of the feature library. ,in, , The number of vectors in the feature library. These are vectors from the feature library.

[0118] It should be noted that, in this embodiment, the sample data is collected and preprocessed to obtain a labeled sample set. The sample data includes positive sample images and negative sample images. That is, a large number of "positive sample" images containing the target contour and "negative sample" images not containing the target contour are collected. The positive samples should cover as many normal variations that may occur in production as possible, such as different positional offsets, slight rotations, lighting fluctuations, and permissible process deformations. The negative samples should include various possible interference situations, such as background defects, foreign objects, and instances where the contour is partially or completely missing. The target contour area (or the entire image, if the background is fixed) in all sample images is labeled to obtain the labeled sample set.

[0119] Furthermore, in this embodiment, feature extraction is achieved by designing and training a convolutional neural network. The core task of the network is not direct classification (present / absent), but feature extraction. The network uses a pre-trained backbone (such as the convolutional part of ResNet or VGG) as the feature extractor, removing its top fully connected classification layer. A strategy of "contrastive learning" or "triplet loss" can be used to train the network. Taking the principle of triplet loss as an example: each training iteration inputs a triple to the network: an anchor sample (Anchor, A positive sample), a positive sample ,and They are of the same class, i.e., both contain contours), and a negative sample (Negative). (excluding outlines).

[0120] The goal of the network is to ensure that the distance between the anchor sample and the positive sample in the feature space is much smaller than the distance between the anchor sample and the negative sample. Let... Given the feature vectors extracted by the network, the triplet loss is... Defined as:

[0121] ;

[0122] in, Represents Euclidean distance. It is a boundary value that forces the minimum interval between positive and negative sample pairs. By minimizing this loss, the network learns to map images with the same contour to nearby points in the feature space, while mapping images without contour to more distant points.

[0123] Finally, after training is complete, a batch of validated, high-quality "standard" positive sample images (e.g., multiple contour samples acquired under ideal conditions) are input into the trained feature extraction network. In this process, a set of corresponding vectors is obtained. This set of vectors constitutes the standard reference set for "contour existence," denoted as the feature library. Simultaneously, the center of this set of eigenvectors can be calculated. And the statistical divergence of its characteristic distribution (such as mean distance or covariance matrix), where, The number of vectors in the feature library. These are vectors from the feature library.

[0124] According to an embodiment of the present invention, the step of performing multi-dimensional similarity calculation based on the feature vector and the constructed feature library to obtain a similar feature vector specifically includes:

[0125] Multi-dimensional similarity calculation includes calculating the distance between the feature vector and the center of the feature library, the distance to the nearest neighbor of the feature library, and the consistency of the feature space.

[0126] Calculating the distance to the feature library center specifically includes calculating the Euclidean distance between the feature vector and the feature library center. ;

[0127] Calculating the distance to the nearest neighbor in the feature library specifically includes calculating the minimum Euclidean distance from the feature vector to all vectors in the feature library. ;

[0128] Calculating feature space consistency specifically includes calculating the degree of dispersion of the distances between the feature vector and all vectors in the feature library, wherein the degree of dispersion... , , It is the average distance. The number of vectors in the feature library. The vectors in the feature library, For feature vectors;

[0129] Based on the Euclidean distance between the feature vector and the center of the feature library The minimum Euclidean distance from the feature vector to all vectors in the feature library. and degree of dispersion The similar feature vectors are obtained. .

[0130] It should be noted that, in this embodiment, the multi-dimensional similarity measurement is not simply a matter of calculating the distance between the feature vector and the center of the feature library. A more comprehensive comparison is then performed, which includes calculating the distance between the feature vector and the center of the feature library, the distance to the nearest neighbor of the feature library, and the consistency of the feature space.

[0131] Specifically, in this embodiment, calculating the distance to the feature library center includes calculating the Euclidean distance between the feature vector and the feature library center. ; and calculating the distance to the nearest neighbor in the feature library, specifically including calculating the minimum Euclidean distance from the feature vector to all vectors in the feature library. ; and calculating feature space consistency, specifically including calculating the degree of dispersion of the distance between the feature vector and all vectors in the feature library, wherein the obtained degree of dispersion , , For the degree of dispersion, This is for intermediate calculations. It is the average distance. The number of vectors in the feature library. The vectors in the feature library, These are the eigenvectors.

[0132] Finally, based on the Euclidean distance between the feature vector and the center of the feature library... The minimum Euclidean distance from the feature vector to all vectors in the feature library. and degree of dispersion The similar feature vectors are obtained. .

[0133] According to an embodiment of the present invention, the step of obtaining the detection result by inputting the similar feature vector into a preset context-aware decision-maker specifically includes:

[0134] Obtain an offline-trained context-aware decision-maker, which is a lightweight model;

[0135] The similar feature vectors are input into the context-aware decision-maker for feature concatenation, forward inference, and decision threshold judgment to obtain the detection result. The threshold judgment is based on the confidence score to output whether there is a contour, and / or the output is based on the binary label to output whether there is a contour.

[0136] It should be noted that, in this embodiment, the final "present / absent" decision is not based on a single threshold, but is made by a lightweight decision-maker (such as a logistic regression model or a small neural network, corresponding to the context-aware decision-maker in this embodiment), by integrating the above-mentioned multiple metrics and possible contextual information. The input of the context-aware decision-maker is represented as a similarity feature vector. .

[0137] Furthermore, it should be noted that this decision-maker is trained offline using a validation set with labels (present / absent), enabling it to learn how to weigh these metrics. For example, even... Slightly larger, but if Very small and Even if the value is very high, the decision-maker may still judge it as "present." This approach in this embodiment is much more flexible and robust than a single threshold. Furthermore, simple contextual information, such as the average gray level of the detection area (as a rough estimate of illumination), can be incorporated as additional input to the decision-maker.

[0138] Furthermore, it should be noted that the output of whether or not a contour exists is determined based on a threshold based on the confidence score, and / or based on a binary label, where the binary label corresponds to "1" (contour present) and "0" (no contour present); the confidence score... :if If it is determined to have an outline, then it is determined to have no outline. It is located between "0 and 1".

[0139] Furthermore, to enable intelligent judgment, this invention pre-constructs a standard feature library. This feature library consists of a set of feature vectors obtained from a large number of verified standard positive sample images through the aforementioned feature extraction network, and the center vector of this feature library is calculated. During online detection, the feature vectors of the image to be tested are compared with this feature library in multiple dimensions for similarity calculation. This calculation is not a simple comparison, but comprehensively considers three key indicators: first, calculating the distance between the feature vector to be tested and the center vector of the feature library; second, calculating the minimum distance from the feature vector to be tested to all vectors in the feature library; and third, evaluating the degree of dispersion of the feature vector to be tested and the overall distribution of the feature library. These three indicators together constitute a comprehensive similarity feature vector.

[0140] Finally, this comprehensive similarity feature vector is input into a pre-defined, offline-trained, lightweight context-aware decision-maker. This decision-maker mimics human comprehensive judgment logic, performing weighted analysis and reasoning on the multi-dimensional input information to output the final detection result. The detection result can be a simple binary label or a confidence score representing the probability of existence. By introducing deep learning and metric learning techniques, this method achieves strong robustness to changes in illumination, positional shifts, rotation, scaling, and minor deformations, significantly reducing reliance on manual parameter adjustments and improving detection accuracy and adaptability in complex industrial scenarios such as low contrast and blurred edges.

[0141] Example of a specific architecture for a feature extraction network: The core of the feature extraction network is a modified convolutional neural network. For example, a widely used and efficient network architecture (such as ResNet) can be used as a base, but its top fully connected classification layer can be removed. The network input is a preprocessed standard image (e.g., a grayscale image resized to a fixed size). The image is processed sequentially through multiple convolutional layers, pooling layers, and non-linear activation functions, progressively extracting hierarchical features from edges and textures to the overall contour. At the end of the network, global average pooling is used to transform the final feature map into a fixed-length feature vector. This vector is then mapped to a lower-dimensional feature space (e.g., 128-dimensional or 256-dimensional) through a fully connected layer, and finally normalized to output a normalized feature vector that can be used for distance metrics. The network is trained offline using a large number of labeled positive sample (containing the target contour) and negative sample (not containing the target contour) images, employing contrastive learning or triplet loss strategies. The training objective is to bring image features with the same contour closer together in the feature space, while keeping image features of different categories further apart.

[0142] Specific architecture examples of context-aware decision-makers: The context-aware decision-maker is a lightweight machine learning model. Its input is a multi-dimensional similarity feature vector calculated in the preceding steps (containing three scalar values: distance to the center of the feature library, distance to the nearest neighbor, and feature space consistency). This decision-maker can be a simple multilayer perceptron, for example, containing a hidden layer with several neurons and an output neuron. The hidden layer uses a non-linear activation function to learn complex decision logic, and the output layer uses a sigmoid function to map the calculation result to a confidence score between zero and one. This score directly reflects the probability that the target contour exists in the image being tested. In the offline phase, the decision-maker is trained using a batch of labeled validation set data (its multi-dimensional similarity feature vectors and corresponding true "present / absent" labels) to learn how to comprehensively weigh the three similarity metrics to make accurate judgments.

[0143] Figure 3 A block diagram of a graphic contour detection system for industrial products according to the present invention is shown.

[0144] like Figure 3 As shown, this invention discloses a graphic contour detection system for industrial products, including a memory and a processor. The memory includes a graphic contour detection method program for industrial products. When the processor executes the graphic contour detection method program for industrial products, it performs the following steps:

[0145] Acquire product images and preprocess them to obtain standard images;

[0146] The standard image is input into a trained feature extraction network to obtain a feature vector;

[0147] Based on the aforementioned feature vectors and the constructed feature library, multi-dimensional similarity calculations are performed to obtain similar feature vectors;

[0148] The detection results are obtained by inputting the similar feature vectors into a preset context-aware decision-maker. The detection results include binary labels and / or confidence scores.

[0149] It should be noted that when the graphic contour detection system for industrial products disclosed in this application is applied, the specific process corresponds to the graphic contour detection method for industrial products described in the above embodiments. Since the specific implementation details of the system application are consistent with the content of the graphic contour detection method for industrial products described above, no further details will be provided in this embodiment.

[0150] A third aspect of the present invention provides a computer-readable storage medium comprising a program for detecting the graphic contour of an industrial product, wherein when the program is executed by a processor, it implements the steps of the graphic contour detection method for an industrial product as described in any of the preceding claims.

[0151] A fourth aspect of the present invention provides a graphic contour detection device 40 for industrial products, comprising:

[0152] Optical imaging module 41 and detection module 42, wherein,

[0153] The optical imaging module 41 includes an industrial camera 411 and a light source 412. The industrial camera 411 is used to acquire images, and the light source 412 is used to provide illumination.

[0154] The detection module 42 includes an industrial computer 421 with a high-performance GPU, used to implement the steps of the graphic contour detection method for an industrial product as described above.

[0155] It should be noted that, in this embodiment, as Figure 4 The diagram shows the composition of a graphic contour detection device 40 for industrial products. The device further includes a fixing module 43, which supports the industrial camera 411 and the light source 412. The fixing module 43 includes a mechanical structure 431. The optical imaging module 41 includes the industrial camera 411 and the light source 412. The industrial camera 411 is used to acquire images, and the light source 412 is used to provide illumination. The detection module 42 includes an industrial computer 421 with a high-performance GPU, used to implement the steps of the graphic contour detection method for industrial products described above.

[0156] This invention discloses a method, system, storage medium, and device for detecting the graphic contours of industrial products. By introducing deep learning and metric learning technologies, it achieves high-precision and robust intelligent detection of the "presence" or "absence" of industrial product contours. Utilizing a feature extraction network trained with triplet loss, it can learn the essential abstract features of the contours and construct a standard feature library as a comparison benchmark. During online detection, through multi-dimensional similarity measurement and a context-aware decision-maker, it achieves strong robustness to changes in illumination, positional shifts, rotation, scaling, and minute deformations, significantly reducing reliance on manual parameter adjustments and improving detection accuracy and adaptability in complex scenarios such as low contrast and blurred edges. Ultimately, it forms an end-to-end, scalable, and intelligent industrial vision inspection solution.

[0157] In the several embodiments provided by this invention, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.

[0158] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.

[0159] In addition, in the various embodiments of the present invention, each functional unit can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.

[0160] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0161] Alternatively, if the integrated units of this invention are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.

Claims

1. A method for detecting the graphic contour of an industrial product, characterized in that, Includes the following steps: Acquire product images and preprocess them to obtain standard images; The standard image is input into a trained feature extraction network to obtain a feature vector; Based on the aforementioned feature vectors and the constructed feature library, multi-dimensional similarity calculations are performed to obtain similar feature vectors; The detection result is obtained by inputting the similar feature vector into a preset context-aware decision-maker. Specifically, this includes: obtaining an offline-trained context-aware decision-maker, which is a lightweight model; inputting the similar feature vector into the context-aware decision-maker to perform feature concatenation, forward inference, and decision threshold judgment to obtain the detection result, wherein the threshold judgment is based on the confidence score to output whether there is a contour, and / or the output is based on the binary label to output whether there is a contour. Specifically, the step of performing multi-dimensional similarity calculations based on the feature vector and the constructed feature library to obtain similar feature vectors includes: Multi-dimensional similarity calculation includes calculating the distance between the feature vector and the center of the feature library, the distance to the nearest neighbor of the feature library, and the consistency of the feature space. Calculating the distance to the feature library center specifically includes calculating the Euclidean distance between the feature vector and the feature library center. ; Calculating the distance to the nearest neighbor in the feature library specifically includes calculating the minimum Euclidean distance from the feature vector to all vectors in the feature library. ; Calculating feature space consistency specifically includes calculating the degree of dispersion of the distances between the feature vector and all vectors in the feature library, wherein the degree of dispersion... , , It is the average distance. The number of vectors in the feature library. The vectors in the feature library, For feature vectors; Based on the Euclidean distance between the feature vector and the center of the feature library The minimum Euclidean distance from the feature vector to all vectors in the feature library. and degree of dispersion The similar feature vectors are obtained. .

2. The method for detecting the graphic contour of an industrial product according to claim 1, characterized in that, The process of acquiring and preprocessing product images to obtain standard images specifically includes: The product image is obtained by acquiring the original digital image of the product captured by a preset industrial camera. The standard image is obtained by performing region of interest extraction, grayscale conversion, size normalization, illumination compensation, and noise suppression on the product image.

3. The method for detecting the graphic contour of an industrial product according to claim 2, characterized in that, The step of inputting the standard image into the trained feature extraction network to obtain the feature vector specifically includes: Obtain the offline trained feature extraction network ; The standard image is input into the feature extraction network, where multidimensional features are pooled into fixed-length features and then normalized to obtain the feature vector. .

4. The method for detecting the graphic contour of an industrial product according to claim 3, characterized in that, Constructing the feature library specifically includes: A labeled sample set is obtained by collecting sample data and performing filtering and preprocessing. The sample data includes positive sample images and negative sample images. The labeled sample set is used to load a training convolutional neural network, wherein a contrastive learning or triplet loss strategy is used for training. The trained standard positive sample images are input into the feature extraction network to obtain the feature library. And calculate the feature center of the feature library. ,in, , The number of vectors in the feature library. These are vectors from the feature library.

5. A graphic contour detection system for industrial products, characterized in that, The system includes a memory and a processor. The memory contains a program for detecting the graphic contour of an industrial product. When the processor executes the program for detecting the graphic contour of an industrial product, it performs the following steps: Acquire product images and preprocess them to obtain standard images; The standard image is input into a trained feature extraction network to obtain a feature vector; Based on the aforementioned feature vectors and the constructed feature library, multi-dimensional similarity calculations are performed to obtain similar feature vectors; The detection result is obtained by inputting the similar feature vector into a preset context-aware decision-maker. Specifically, this includes: obtaining an offline-trained context-aware decision-maker, which is a lightweight model; inputting the similar feature vector into the context-aware decision-maker to perform feature concatenation, forward inference, and decision threshold judgment to obtain the detection result, wherein the threshold judgment is based on the confidence score to output whether there is a contour, and / or the output is based on the binary label to output whether there is a contour. Specifically, the step of performing multi-dimensional similarity calculations based on the feature vector and the constructed feature library to obtain similar feature vectors includes: Multi-dimensional similarity calculation includes calculating the distance between the feature vector and the center of the feature library, the distance to the nearest neighbor of the feature library, and the consistency of the feature space. Calculating the distance to the feature library center specifically includes calculating the Euclidean distance between the feature vector and the feature library center. ; Calculating the distance to the nearest neighbor in the feature library specifically includes calculating the minimum Euclidean distance from the feature vector to all vectors in the feature library. ; Calculating feature space consistency specifically includes calculating the degree of dispersion of the distances between the feature vector and all vectors in the feature library, wherein the degree of dispersion... , , It is the average distance. The number of vectors in the feature library. The vectors in the feature library, For feature vectors; Based on the Euclidean distance between the feature vector and the center of the feature library The minimum Euclidean distance from the feature vector to all vectors in the feature library. and degree of dispersion The similar feature vectors are obtained. .

6. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a graphic contour detection method program for an industrial product, which, when executed by a processor, implements the steps of a graphic contour detection method for an industrial product as described in any one of claims 1 to 4.

7. A graphic contour detection device for industrial products, characterized in that, include: Optical imaging module and detection module, wherein, The optical imaging module includes an industrial camera and a light source, wherein the industrial camera is used to acquire images and the light source is used to provide illumination; The detection module includes an industrial computer with a high-performance GPU, used to implement the steps of the graphic contour detection method for an industrial product as described in any one of claims 1 to 4.

8. The graphic contour detection device for industrial products according to claim 7, characterized in that, The device further includes a fixing module for supporting the industrial camera and the light source, wherein the fixing module includes a mechanical structure.

Citation Information

Patent Citations

  • Region-of-interest segmentation method and device, electronic equipment and storage medium

    CN116778166A

  • Two-dimensional irregular accessory identification method based on depth image retrieval

    CN121884383A

  • Cross-transformer neural network system for few-shot similarity determination and classification

    US20210383226A1