Target existence detection method, system and device

By employing template matching, affine transformation, and grayscale analysis, the accuracy and real-time performance issues of target presence/absence detection in complex industrial scenarios are addressed, achieving high-precision and robust target detection applicable to various industrial vision scenarios such as parts assembly and packaging contents inspection.

CN121811080APending Publication Date: 2026-04-07SUZHOU TIANMAI THERMAL TECH
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-30
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing technologies struggle to achieve high-precision, robust, and real-time target detection in complex industrial scenarios, especially when the target and background colors are similar or when the pose changes. This results in high false detection and false negative rates, as well as significant computational overhead, making it difficult to meet the real-time requirements of industrial detection.

Method used

The method employs template generation and matching, affine transformation, and grayscale analysis. The target pose information is calculated through template matching algorithm, the detection area is aligned using affine transformation, and the presence or absence of the target is determined through grayscale analysis. Preprocessing is performed by combining Gaussian filtering, histogram equalization, and adaptive thresholding. Normalized cross-correlation algorithm and feature point matching algorithm are used to improve matching stability.

Benefits of technology

It significantly reduces the false detection rate and false negative rate, improves the detection accuracy and real-time performance in complex industrial environments, meets the detection needs of high-speed industrial production lines, and is computationally efficient, making it suitable for a variety of industrial vision scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121811080A_ABST
    Figure CN121811080A_ABST
Patent Text Reader

Abstract

The invention provides a target existence detection method, system and device, and relates to the technical field of target detection. The method comprises the following steps: generating a template; quickly calculating pose information of a target in the current image by utilizing a feature point matching or normalized cross-correlation template matching algorithm and combining image pyramid search; generating a homogeneous transformation matrix by adopting a two-point method according to the template and the target pose information, and performing rigid affine transformation on the detection area to realize accurate alignment; calculating and comparing the gray average value and the gray deviation of the transformed region and the template region; and finally, judging whether the target exists or not through a set threshold value. The system comprises an image acquisition module, a preprocessing module, a template matching module, an affine transformation module, a gray analysis module, a result output module and the like, and a feedback module can be integrated to optimize a template library. According to the method, template matching, affine transformation and gray statistics are combined, and the detection accuracy, real-time performance and robustness in complex industrial scenes such as color interference, position deviation and rotation are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of target detection technology, specifically to a method, system, and apparatus for detecting the presence or absence of a target. Background Technology

[0002] In the field of industrial automation, such as parts assembly, product packaging, and quality inspection, quickly and accurately determining the presence of a target object is crucial for ensuring production efficiency and product quality. Machine vision technology, due to its non-contact and high-efficiency characteristics, has become the mainstream method for detecting the presence or absence of targets.

[0003] Existing visual inspection solutions often face the following challenges when dealing with complex industrial scenarios: Color interference can cause traditional methods based on global grayscale thresholds or simple color segmentation to fail when the target color is similar to the background color, leading to high false positive or false negative rates. For example, when detecting the presence of a dark part on a dark background, low contrast makes the target difficult to distinguish.

[0004] In actual production lines, the position (translation) and angle (rotation) of target objects may change due to vibration, conveyor belt errors, and other reasons. Many existing methods, such as fixed-area detection or matching algorithms insensitive to pose changes, exhibit significantly reduced detection stability in such cases, potentially misclassifying normally present but misplaced targets as missing.

[0005] Poor environmental adaptability, uneven lighting, shadows, noise and other common industrial environmental interferences can seriously affect the performance of detection algorithms that rely on absolute gray values ​​or fixed features.

[0006] To address the aforementioned issues, existing technologies have proposed various improvement schemes. For example, Chinese invention patent application CN120912915A (published on November 7, 2025) discloses a low-light image target detection method and apparatus based on color channel transformation enhancement. The method includes the following steps: constructing an image target detection network based on color channel transformation enhancement, which introduces learnable parameters to transform pixel values ​​of different color channels, and then performing image enhancement; calculating the detection result using the enhanced image and the original image; calculating the detection loss between the enhanced image and the original image, and determining whether to use regression loss to optimize the image enhancement process based on the detection loss. This invention alleviates the performance degradation problem of target detection algorithms caused by low image contrast, blurred boundaries, and noise interference in low-light scenes. However, it focuses on improving image quality to serve general detection networks and does not specifically address the issues of similar target and background colors and rapid pose alignment. Furthermore, the deployment cost of deep learning solutions is high.

[0007] For example, Chinese invention patent application CN120894542A (published on November 4, 2025) discloses a target detection method and system based on computer vision. The method includes preprocessing an image of the target to be detected to obtain a preprocessed image; performing detail enhancement and environmental compensation on the preprocessed image to obtain an enhanced image; performing clustering and segmentation on the enhanced image to obtain an environmental image and a foreground image; performing a first correction processing on the environmental image and a second correction processing on the foreground image to obtain a first corrected image and a second corrected image; combining the first corrected image and the second corrected image to obtain a final corrected image; performing denoising and background suppression on the final corrected image to obtain a denoised image; acquiring a template training image; training a preset detection model using the template training image; inputting the denoised image into the trained preset detection model for target detection; and outputting the target detection result. This invention can improve the accuracy of target detection and avoid misidentification. However, its process is lengthy, computationally expensive, and difficult to guarantee the real-time performance of industrial detection.

[0008] For example, Chinese invention patent application CN117214176A (published on December 12, 2023) discloses a visual inspection method and system for improving box packaging yield, including the following steps: S1: Acquiring an image of the inside of the box: Illuminating the box with a light source and using a camera at a certain angle to capture the inside of the box, completing the image acquisition of the inside of the box, and storing the image; S2: Detecting the presence or absence of a target, using at least one of the following methods: Method 1: Target edge detection; Method 2: Target content detection; S3: Outputting instructions. This invention automatically performs visual inspection of the inside of the box to determine whether there is a missing certificate of conformity or instruction manual, preventing defective products with missing certificates of conformity or instruction manuals from entering subsequent processes and the market. However, it is mainly based on edge or content extraction, has limited adaptability to changes in target pose, and does not involve a step of precise alignment of regions through geometric transformation.

[0009] Therefore, there is an urgent need in this field for a dedicated target presence / absence detection scheme that can take into account high precision, strong robustness, high real-time performance, and effectively address the challenges of similar target background colors and pose changes. Summary of the Invention

[0010] To address the above technical problems, this invention provides a method for detecting the presence or absence of a target, comprising the following steps: Step S1: Template generation. The target is manually placed in the camera's field of view to obtain a template image. After preprocessing, the contour features of the target in the template image are extracted. A template library is established and the coordinates of the detection area in the template image are obtained to generate template pose information. Step S2: Template matching. The target pose information of the detection region in the current image is calculated using a template matching algorithm. Step S3: Affine transformation and region alignment. Based on the target pose information and the template pose information, the method of generating a homogeneous transformation matrix at two points is used to perform an affine transformation on the auxiliary material detection area, and the transformed detection area is aligned with the detection area in the template image. Step S4: Gray-scale analysis, calculate the average gray-scale value and gray-scale deviation of the detection area in the current image and the detection area in the template image; Step S5: Target detection.

[0011] Furthermore, the preprocessing in step S1 includes: using Gaussian filtering to eliminate noise, using histogram equalization to enhance contrast, and using an adaptive thresholding method to dynamically adjust parameters based on local image characteristics.

[0012] Furthermore, the contour features in step S1 include one or more of edges, corners, and shape descriptors; the extraction method for the contour features is multi-scale feature extraction.

[0013] Furthermore, the template pose information mentioned in step S1 is the first calibration pose (x1, y1, r1), where x1 is the x-axis coordinate of the template image, y1 is the y-axis coordinate of the template image, and r1 is the angle of the template image.

[0014] Furthermore, step S2 includes the following steps: Step S21: Template construction, calculate relevant data for the template image, generate edge point set and related data information to construct the template; Step S22: Feature extraction, calculating relevant data for the target image; Step S23: Calculate the correlation between the target image and the template image using a template matching algorithm to determine the matching criteria; Step S24: Pyramid search. Create a multi-level image pyramid model. According to the matching criteria, perform a search layer by layer from top to bottom to determine the location region of the target in the template image and obtain the coordinates of the target to generate the target pose information.

[0015] Furthermore, the relevant data may be gradients, image pixels, or signal sequences.

[0016] Furthermore, the template matching algorithm in step S23 is either the Normalized Cross-Correlation (NCC) algorithm or the feature point matching algorithm.

[0017] Furthermore, the calculation formula for the normalized cross-correlation algorithm is as follows: Where NCC represents the normalized cross-correlation, and E represents the first set of correlated data. The average value I of the first set of related data is used for the second set of related data. This represents the average value of the second set of related data. The core function of the normalized cross-correlation algorithm is to measure the similarity between two sets of data (such as image pixels or signal sequences). The normalized cross-correlation algorithm can effectively resist changes in illumination.

[0018] Furthermore, the calculation formula for the feature point matching algorithm is as follows: ,in, For gradient correlation, The gradient vector of the template image. Let be the gradient vector of the target image. The length of the gradient vector of the template image. This represents the length of the gradient vector of the target image. Feature point matching (such as SIFT or ORB) is suitable for rotation and scaling scenarios.

[0019] Furthermore, the target pose information is a second calibration pose (x2, y2, r2), where x2 is the x-axis coordinate of the target image, y2 is the y-axis coordinate of the target image, and r2 is the angle of the target image.

[0020] Furthermore, the template matching algorithm is a combination of feature point matching algorithm and Local Binary Pattern (LBP) descriptor, and step S2 includes the following steps: Step S221: Construct an LBP texture template. Within the detection area of ​​the template image, calculate the LBP value for each pixel and convert the template image into an LBP pattern map. Step S222: Feature extraction, calculate similarity for the target image, and generate edge point set and related information; Step S223: Similarity comparison, using the converted LBP values ​​to perform similarity calculation; Step S224: Pre-screen or weighted screening determines the location region of the target in the template image, obtains the coordinates of the target, and generates target pose information.

[0021] The LBP descriptor converts local grayscale comparisons in an image into binary patterns, effectively extracting texture information that is insensitive to illumination. When combined with template matching, it adds a "texture consistency" constraint to the matching process, preventing the algorithm from relying solely on easily changing grayscale values. This allows it to maintain a higher matching success rate when faced with lighting fluctuations, noise interference, or different surfaces of the same material.

[0022] Traditional methods may rely on features such as grayscale and edges. Introducing LBP (Layered Backpropagation) allows for the description of local texture structures. The original LBP compares the center pixel with 8 neighboring pixels within a 3×3 neighborhood to generate an 8-bit binary number (256 LBP codes) reflecting the texture. The improved circular LBP operator can have any P sampling points within a circular neighborhood of radius R, adapting to textures at different scales. It can also handle non-integer coordinate sampling points through bilinear interpolation. For example, in face recognition, LBP effectively represents facial texture features. LBP descriptors provide a new way to describe feature points; their encoding reflects local texture patterns, exhibits grayscale invariance, and is more stable under varying lighting conditions. For instance, in target detection in outdoor scenes with variable lighting, feature points based on LBP descriptors are less affected by lighting, resulting in more reliable matching. Due to the uniqueness of LBP features, matching criteria and algorithms need adjustment. Traditional matching methods based on Euclidean distance may not be suitable for LBP features; therefore, matching metrics tailored to the characteristics of LBP encoding need to be designed, such as calculating the similarity of LBP histograms to measure the degree of feature point matching. For targets with rich textures, LBP significantly improves detection performance, such as accurately capturing texture anomalies in the detection of surface defects on industrial parts. However, for targets with scarce textures, its descriptive ability is limited, and it may need to be combined with other features (such as HOG) to adapt to different target detection scenarios. LBP calculation is relatively simple and fast, and compared with some complex feature extraction methods, it can improve detection speed, especially in scenarios with high real-time requirements (such as target detection in video surveillance).

[0023] Furthermore, the pre-screening method is as follows: calculate the LBP histogram of the template and the target image, perform texture similarity screening, and exclude regions with completely inconsistent texture structures.

[0024] Furthermore, the weighted filtering method is as follows: in the similarity score, the similarity based on LBP features is used as a weight and fused with the original grayscale matching score, thereby giving more emphasis to matching with consistent textures.

[0025] Furthermore, step S3 includes the following steps: Step S31: Based on the target pose information and the template pose information, the preset angle is the difference between the first calibration angle and the second calibration angle. The second calibration pose (x2, y2, r2) is translated into the coordinate system of the first calibration pose (x1, y1, r1). Step S32: Set both the first calibration angle r1 and the second calibration angle r2 to 0, transform the first calibration pose and the compensated second pose to obtain the transformed first calibration pose (x1, y1, 0) and the second compensated pose (x1', y1', 0'); generate the affine transformation matrix HomMat2D based on the transformed first calibration pose and the second compensated pose. Step S33: Align the transformed detection region with the target detection region in the template image. The two-point method generates a transformation matrix based on the target center point and a reference point to achieve precise alignment. For example, in electronic component detection, the center point can be the geometric center of the component, and the reference point is a specific pin position, ensuring that the transformed region is consistent with the template. Aligning the transformed detection region with the target region in the template image ensures the consistency of the detection region; the alignment process can reduce detection errors caused by target displacement. Furthermore, the transformation parameters can be iteratively optimized to handle nonlinear deformation and improve accuracy in complex scenes.

[0026] Furthermore, the formula for calculating the average grayscale value in step S4 is as follows: F=|R|, Where R is the detection region, p is a pixel originating from the detection region R, g(p) is the gray value of pixel p, F is the plane of the detection region R, and |R| is the number of pixels in the detection region.

[0027] Furthermore, the formula for calculating the grayscale deviation in step S5 is as follows: Where R is the detection region, p is a pixel originating from the detection region R, g(p) is the gray value of pixel p, and F is the plane of the detection region R. This refers to the average grayscale value. The average grayscale value is a core parameter in image processing that describes the brightness of a region. It is based on the statistical mean brightness of all pixels, reflecting the overall brightness of the image. Grayscale deviation (standard deviation) measures the dispersion of pixel brightness. It is calculated by taking the square root of the variance between the pixel value and the mean, quantifying the image contrast or noise level.

[0028] Furthermore, the specific method of step S5 is as follows: set a threshold, compare the grayscale deviation between the current image and the template image, and determine whether the target exists; if the deviation exceeds the threshold, the target is determined to exist; otherwise, the target is determined not to exist.

[0029] Furthermore, the method for setting the threshold is as follows: obtain the value of the threshold when the target is present and when it is absent, optimize the appropriate value based on historical data using machine learning algorithms, such as vector machine (SVM) or neural network models, and automatically learn the optimal threshold based on a large amount of sample data.

[0030] The present invention also provides a target presence / absence detection system, comprising: Image acquisition module: used to acquire the current image; Preprocessing module: Performs preprocessing operations such as denoising and enhancement on the image; Template matching module: Extracts the target contour, performs template matching, and calculates pose change information; Affine transformation module: Generates a homogeneous transformation matrix based on pose change information and performs affine transformation on the detection area; Grayscale analysis module: Calculates and compares the average grayscale value and deviation between the current image and the template image; Result output module: Outputs the detection results to the control system.

[0031] Furthermore, the target presence / absence detection system also includes a feedback module for automatically updating the template library based on the detection results. The feedback module integrates anomaly detection algorithms, such as identifying template degradation trends based on cluster analysis, thereby providing early warnings and updates.

[0032] The present invention also provides a target presence detection device, characterized in that it includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is loaded by the processor, it executes the above-described target presence detection method.

[0033] Compared with existing technologies, the advantages and effects of this application are as follows: 1. This application aligns the current detection area with the template area through affine transformation, eliminating comparison errors caused by target translation and rotation. Based on this, grayscale statistical analysis is performed, which can effectively detect subtle changes in grayscale distribution caused by the presence or absence of the target. Even if the target and background colors are similar, reliable discrimination can be achieved by calculating the statistical characteristics of the grayscale of the region (such as standard deviation), significantly reducing the false detection rate and false negative rate.

[0034] 2. The template matching algorithm of this application (such as gradient-based feature point matching algorithm or normalized cross-correlation algorithm NCC algorithm) has good invariance to uniform illumination changes and noise. The affine transformation model can well adapt to the rigid motion (translation, rotation) of the target in the plane. This combination enables the present invention to maintain stable detection performance in complex industrial environments with illumination fluctuations, target position and angle changes, and slight noise.

[0035] 3. This invention has a clear process and is computationally efficient. Template matching employs an image pyramid search strategy, significantly accelerating the matching process. Affine transformation and grayscale statistics are both computationally inexpensive mathematical operations. The entire method avoids the inference overhead of heavy models such as deep learning, greatly improving processing speed on general-purpose processors and meeting the real-time detection requirements of high-speed industrial production lines.

[0036] 4. The detection system in this application features a modular design, making it easy to integrate into existing industrial vision systems and PLC control networks. The feedback module enables adaptive updates to the template library to address potential equipment aging or slow scene changes during long-term operation. This method is universally applicable, not only for detecting the presence or absence of parts but also for a wide range of industrial vision scenarios such as electronic component assembly, packaging contents inspection, and material sorting.

[0037] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the preferred embodiments of this application are described in detail below with reference to the accompanying drawings.

[0038] The above and other objects, advantages and features of this application will become more apparent to those skilled in the art from the following detailed description of specific embodiments in conjunction with the accompanying drawings. Attached Figure Description

[0039] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In all drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn to scale.

[0040] in: Figure 1 A flowchart illustrating whether a detection method exists for the objective of this application; Figure 2 This application provides a practical demonstration of the absence of a detection system for its target. Figure 1 ; Figure 3 This application provides a practical demonstration of the absence of a detection system for its target. Figure 2 . Detailed Implementation

[0041] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, 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 some embodiments of this application, not all embodiments. In the following description, specific details such as specific configurations and components are provided merely to help fully understand the embodiments of this application. Therefore, those skilled in the art should understand that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this application. In addition, for clarity and brevity, descriptions of known functions and structures are omitted in the embodiments.

[0042] It should be understood that the phrase "an embodiment" or "this embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "an embodiment" or "this embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments.

[0043] Furthermore, reference numerals and / or letters may be repeated in different examples within this application. Such repetition is for the purpose of simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or settings discussed.

[0044] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, B exists alone, and A and B exist simultaneously. The term " / and" describes another type of relationship between related objects, indicating that two relationships can exist. For example, A / and B can mean: A exists alone, and A and B exist alone. In addition, the character " / " in this article generally indicates that the related objects before and after it have an "or" relationship.

[0045] In this article, the term "at least one" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, "at least one of A and B" can mean: A exists alone, A and B exist simultaneously, or B exists alone.

[0046] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion.

[0047] Example 1 This embodiment describes a method for detecting the presence or absence of a target.

[0048] Please refer to Figure 1 As shown, Figure 1 This is a flowchart illustrating whether there is a detection method for the objective of this application.

[0049] Step S1: Template generation. The target is manually placed in the camera's field of view to obtain a template image. After preprocessing, the contour features of the target in the template image are extracted. A template library is established and the coordinates of the detection area in the template image are obtained to generate template pose information. Step S2: Template matching. The target pose information of the detection region in the current image is calculated using a template matching algorithm. Step S3: Affine transformation and region alignment. Based on the target pose information and the template pose information, the method of generating a homogeneous transformation matrix at two points is used to perform an affine transformation on the auxiliary material detection area, and the transformed detection area is aligned with the detection area in the template image. Step S4: Gray-scale analysis, calculate the average gray-scale value and gray-scale deviation of the detection area in the current image and the detection area in the template image; Step S5: Target detection.

[0050] The technical advantages of this embodiment are as follows: It utilizes a template matching algorithm based on feature point matching or normalized cross-correlation, combined with image pyramid search, to quickly calculate the pose information of the target in the current image; based on the pose information of the template and the target, a homogeneous transformation matrix is ​​generated using a two-point method, and a rigid affine transformation is performed on the detection region to achieve precise alignment; the average grayscale value and grayscale deviation of the transformed region and the template region are calculated and compared; finally, the presence or absence of the target is determined by a set threshold. The system includes modules for image acquisition, preprocessing, template matching, affine transformation, grayscale analysis, and result output, and can integrate a feedback module to optimize the template library. Combining template matching, affine transformation, and grayscale statistics significantly improves the detection accuracy, real-time performance, and robustness in complex industrial scenarios with color interference, positional shifts, and rotations.

[0051] Example 2 Based on Example 1, this example discloses a further design of step S2 of the target presence / absence detection method.

[0052] Furthermore, step S2 includes the following steps: Step S21: Template construction, calculate relevant data for the template image, generate edge point set and related data information to construct the template; Step S22: Feature extraction, calculating relevant data for the target image; Step S23: Calculate the correlation between the target image and the template image using a template matching algorithm to determine the matching criteria; Step S24: Pyramid search. Create a multi-level image pyramid model. According to the matching criteria, perform a search layer by layer from top to bottom to determine the location region of the target in the template image and obtain the coordinates of the target to generate the target pose information.

[0053] Furthermore, the relevant data may be gradients, image pixels, or signal sequences.

[0054] Furthermore, the template matching algorithm in step S23 is either the Normalized Cross-Correlation (NCC) algorithm or the feature point matching algorithm.

[0055] Furthermore, the calculation formula for the normalized cross-correlation algorithm is as follows: Where NCC represents the normalized cross-correlation, and E represents the first set of correlated data. The average value I of the first set of related data is used for the second set of related data. This represents the average value of the second set of related data. The core function of the normalized cross-correlation algorithm is to measure the similarity between two sets of data (such as image pixels or signal sequences). The normalized cross-correlation algorithm can effectively resist changes in illumination.

[0056] Furthermore, the calculation formula for the feature point matching algorithm is as follows: ,in, For gradient correlation, The gradient vector of the template image. Let be the gradient vector of the target image. The length of the gradient vector of the template image. This represents the length of the gradient vector of the target image. Feature point matching (such as SIFT or ORB) is suitable for rotation and scaling scenarios.

[0057] Furthermore, the target pose information is a second calibration pose (x2, y2, r2), where x2 is the x-axis coordinate of the target image, y2 is the y-axis coordinate of the target image, and r2 is the angle of the target image.

[0058] Furthermore, the template matching algorithm is a combination of feature point matching algorithm and Local Binary Pattern (LBP) descriptor, and step S2 includes the following steps: Step S221: Construct an LBP texture template. Within the detection area of ​​the template image, calculate the LBP value for each pixel and convert the template image into an LBP pattern map. Step S222: Feature extraction, calculate the gradient for the target image, and generate edge point set and gradient information; Step S223: Calculate the similarity of the target image and generate an edge point set and related information; Step S224: Pre-screen or weighted screening determines the location region of the target in the template image, obtains the coordinates of the target, and generates target pose information.

[0059] Furthermore, the pre-screening method is as follows: calculate the LBP histogram of the template and the target image, perform texture similarity screening, and exclude regions with completely inconsistent texture structures.

[0060] Furthermore, the weighted filtering method is as follows: in the similarity score, the similarity based on LBP features is used as a weight and fused with the original grayscale matching score, thereby giving more emphasis to matching with consistent textures.

[0061] The technical advantages of this embodiment are as follows: This embodiment specifies the template matching steps and provides multiple algorithm options. The Normalized Cross-Correlation (NCC) algorithm is employed, which is advantageous because it is completely immune to linear illumination changes in the image, making it particularly suitable for industrial environments where illumination conditions may vary uniformly. The gradient-based feature point matching algorithm is employed, which is advantageous because it is sensitive to edge features and provides robust matching results when the target has a clear outline. Furthermore, the introduction of Local Binary Pattern (LBP) descriptors combined with matching can extract texture information that is insensitive to illumination, significantly improving the matching success rate and accuracy in scenarios such as changes in target surface texture or different surfaces of the same material, thus enhancing the overall adaptability of the method.

[0062] Example 3 Based on Example 1, this example discloses a further design of step S3 of the target presence / absence detection method.

[0063] Furthermore, step S3 includes the following steps: Step S31: Based on the target pose information and the template pose information, the preset angle is the difference between the first calibration angle and the second calibration angle. The second calibration pose (x2, y2, r2) is translated into the coordinate system of the first calibration pose (x1, y1, r1). Step S32: Set both the first calibration angle r1 and the second calibration angle r2 to 0, transform the first calibration pose and the compensated second pose to obtain the transformed first calibration pose (x1, y1, 0) and the second compensated pose (x1', y1', 0'); generate the affine transformation matrix HomMat2D based on the transformed first calibration pose and the second compensated pose. Step S33: Align the transformed detection region with the detection target region in the template image.

[0064] The technical advantages of this embodiment are as follows: By utilizing the target's pose (coordinates and angles) in the image, a precise transformation matrix describing the position and angular differences between the target and the template can be generated through concise and efficient geometric calculations. This transformation rigidly aligns the detection area to the template coordinate system, ensuring that subsequent grayscale comparisons are performed between spatially corresponding regions. This eliminates interference from grayscale distribution changes caused by target movement or rotation, allowing the "presence" judgment to focus entirely on the existence of the target object itself. Combining template matching and affine transformation enables rapid positioning and detection, meeting the needs of industrial automation; the processing time for a single frame image can be controlled within milliseconds. For example, in a logistics sorting system, this device can process dozens of images per second, supporting high-speed assembly line operation. The target pose changes are highly adaptable, ensuring detection stability; for example, within a 30-degree rotation range, the detection accuracy remains above 90%. Furthermore, this method exhibits good resistance to partial occlusion or noise interference, making it suitable for harsh industrial environments.

[0065] Example 4 Based on Example 3, this example discloses a further design of step S4 in the target presence / absence detection method.

[0066] Furthermore, the formula for calculating the grayscale deviation in step S4 is as follows: Where R is the detection region, p is a pixel originating from the detection region R, g(p) is the gray value of pixel p, and F is the plane of the detection region R. It is the average grayscale value.

[0067] Furthermore, the specific method of step S5 is as follows: set a threshold, compare the grayscale deviation between the current image and the template image, and determine whether the target exists; if the deviation exceeds the threshold, the target is determined to exist; otherwise, the target is determined not to exist.

[0068] Furthermore, the method for setting the threshold is as follows: obtain the value of the threshold when the target is present and when it is absent, optimize the appropriate value based on historical data using machine learning algorithms, such as vector machine (SVM) or neural network models, and automatically learn the optimal threshold based on a large amount of sample data.

[0069] The technical advantages of this embodiment are as follows: It clearly defines the use of grayscale mean and standard deviation (bias) as analytical indicators. The mean reflects the overall brightness, while the standard deviation can sensitively capture grayscale fluctuations within a region. When a target is present, its texture and edges introduce additional grayscale variations, typically resulting in a significant difference in the standard deviation of that region compared to the template region containing only the background. By comparing this statistic, the target can be reliably identified. Furthermore, an adaptive threshold setting method based on machine learning (such as SVM and neural networks) is proposed. Its advantage lies in its ability to dynamically optimize the judgment boundary based on historical detection data, enabling the system to possess self-learning and self-optimization capabilities, further improving its adaptability and detection accuracy to different products and working conditions. By comparing grayscale deviations, the false detection problem when the target and background colors are similar is effectively solved; experimental data shows that the false detection rate is less than 5% in standard tests. Specifically, in the automotive parts inspection scenario, this method maintains an accuracy rate of over 95% even under varying lighting conditions, significantly outperforming traditional methods.

[0070] Example 5 Based on any of the above embodiments, this embodiment discloses a target presence / absence detection system.

[0071] Please refer to Figure 2-3 , Figure 2 This application provides a practical demonstration of the absence of a detection system for its target. Figure 1 ; Figure 3 This application provides a practical demonstration of the absence of a detection system for its target. Figure 2 ; A target presence / absence detection system includes: Image acquisition module: Used to acquire the current image; it can be used with a camera, light source, and image acquisition card; the camera can be a high-resolution industrial camera, and the light source needs to provide uniform illumination to reduce shadows. In specific implementations, a multispectral camera can be integrated to handle the detection of special materials and expand the application range.

[0072] Preprocessing module: Performs preprocessing operations such as noise reduction and enhancement on the image; the module can be integrated onto a digital signal processor (DSP) to accelerate processing. For example, on a high-speed production line, the preprocessing module can use an FPGA to implement real-time filtering to ensure image quality.

[0073] Template matching module: Extracts target contours, performs template matching, and calculates pose change information; this module can be implemented using an embedded system for low-latency computation. Furthermore, GPU acceleration technology can be introduced to support rapid retrieval of large-scale template libraries.

[0074] Affine Transformation Module: Generates a homogeneous transformation matrix based on pose change information and performs affine transformation on the detection region. The transformation is based on linear algebra calculations to ensure the accuracy of geometric correction. The module design supports multi-threaded processing to handle high-concurrency detection tasks.

[0075] Grayscale analysis module: Calculates and compares the average grayscale value and deviation between the current image and the template image; the module can integrate threshold adaptive function to improve detection flexibility. For example, in food packaging inspection, the module can automatically adjust the threshold according to the packaging color to ensure stability under different materials.

[0076] The results output module outputs the detection results to the control system and feeds them back to the template library update module. The output interface supports multiple protocols, such as Ethernet or serial communication. Furthermore, the module can be equipped with data encryption to ensure industrial data security.

[0077] Furthermore, the target presence / absence detection device also includes a feedback module for automatically updating the template library based on the detection results. The feedback module integrates anomaly detection algorithms, such as identifying template degradation trends based on cluster analysis, thereby providing early warnings and updates.

[0078] The technical advantages of this embodiment are: it maps the method to specific software and hardware system modules. The modular design of the system allows image acquisition, processing, analysis, and output to each perform their respective functions, facilitating development, debugging, and maintenance. The added feedback module is an intelligent extension of the invention, which has the benefit of monitoring detection performance, automatically identifying template degradation or scene drift trends through cluster analysis and other means, and providing early warnings or updating the template, thus achieving closed-loop optimization and long-term stable operation of the detection system and reducing manual maintenance costs.

[0079] The above description is merely a preferred embodiment of the present invention and does not limit the scope of protection of the present invention. Various modifications and variations are possible with respect to the present invention. Any changes, modifications, substitutions, integrations, and parameter alterations to these embodiments within the spirit and principles of the present invention fall within the scope of protection of the claims of the present invention.

Claims

1. A method for detecting the presence or absence of a target, characterized in that, Includes the following steps: Step S1: Template generation. The target is manually placed in the camera's field of view to obtain a template image. After preprocessing, the contour features of the target in the template image are extracted. A template library is established and the coordinates of the detection area in the template image are obtained to generate template pose information. Step S2: Template matching. The target pose information of the detection region in the current image is calculated using a template matching algorithm. Step S3: Affine transformation and region alignment. Based on the target pose information and the template pose information, the method of generating a homogeneous transformation matrix at two points is used to perform an affine transformation on the auxiliary material detection area, and the transformed detection area is aligned with the detection area in the template image. Step S4: Gray-scale analysis, calculate the average gray-scale value and gray-scale deviation of the detection area in the current image and the detection area in the template image; Step S5: Target detection.

2. The target presence / absence detection method according to claim 1, characterized in that, Step S2 includes the following steps: Step S21: Template construction, calculate relevant data for the template image, generate edge point set and related data information to construct the template; Step S22: Feature extraction, calculating relevant data for the target image; Step S23: Calculate the correlation between the target image and the template image using a template matching algorithm to determine the matching criteria; Step S24: Pyramid search. Create a multi-level image pyramid model. According to the matching criteria, perform a search layer by layer from top to bottom to determine the location region of the target in the template image and obtain the coordinates of the target to generate the target pose information.

3. The target presence / absence detection method according to claim 2, characterized in that, The template matching algorithm in step S23 is either the Normalized Cross-Correlation (NCC) algorithm or the Feature Point Matching algorithm.

4. The target presence / absence detection method according to claim 3, characterized in that, The calculation formula for the normalized cross-correlation algorithm is as follows: Where NCC represents the normalized cross-correlation, and E represents the first set of correlated data. The average value I of the first set of related data is used for the second set of related data. This represents the average value of the second set of related data.

5. The target presence / absence detection method according to claim 3, characterized in that, The calculation formula for the feature point matching algorithm is as follows: ,in, For gradient correlation, The gradient vector of the template image. Let be the gradient vector of the target image. The length of the gradient vector of the template image. is the length of the gradient vector of the target image.

6. The target presence / absence detection method according to claim 1, characterized in that, Step S3 includes the following steps: Step S31: Based on the target pose information and the template pose information, the preset angle is the difference between the first calibration angle and the second calibration angle. The second calibration pose (x2, y2, r2) is translated into the coordinate system of the first calibration pose (x1, y1, r1). Step S32: Set both the first calibration angle r1 and the second calibration angle r2 to 0, transform the first calibration pose and the compensated second pose to obtain the transformed first calibration pose (x1, y1, 0) and the second compensated pose (x1', y1', 0'); generate the affine transformation matrix HomMat2D based on the transformed first calibration pose and the second compensated pose. Step S33: Align the transformed detection region with the detection target region in the template image.

7. The target presence / absence detection method according to claim 1, characterized in that, The formula for calculating the average grayscale value in step S4 is as follows: ,F=|R|, Where R is the detection region, p is a pixel originating from the detection region R, g(p) is the gray value of pixel p, F is the plane of the detection region R, and |R| is the number of pixels in the detection region.

8. The target presence / absence detection method according to claim 1, characterized in that, The formula for calculating the grayscale deviation in step S4 is: Where R is the detection region, p is a pixel originating from the detection region R, g(p) is the gray value of pixel p, and F is the plane of the detection region R. It is the average grayscale value.

9. A target presence / absence detection system, characterized in that, A method for detecting the presence or absence of a target as described in any one of claims 1-8, comprising: an image acquisition module for acquiring a current image; Preprocessing module: Performs preprocessing operations such as denoising and enhancement on the image; Template matching module: Extracts the target contour, performs template matching, and calculates pose change information; Affine transformation module: Generates a homogeneous transformation matrix based on pose change information and performs affine transformation on the detection area; Grayscale analysis module: Calculates and compares the average grayscale value and deviation between the current image and the template image; Result output module: Outputs the detection results to the control system.

10. A target presence / absence detection device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program that, when loaded by the processor, executes the method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Visual detection method and system for boxing yield

    CN117214176A

  • Target detection method and system based on computer vision

    CN120894542A

  • Low-illumination image target detection method and device based on color channel conversion enhancement

    CN120912915A