A structured target counting system based on prior knowledge
By introducing prior knowledge of structure and scene, constructing aspect ratio constraints and penalty mechanisms, and combining DBSCAN clustering and virtual box construction, the problems of false detection and missed detection in target detection in high-density arranged scenes are solved, and the stability and accuracy of detection are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGDONG POLYTECHNIC NORMAL UNIV
- Filing Date
- 2026-01-26
- Publication Date
- 2026-06-09
AI Technical Summary
Existing target detection methods are prone to false detections and false negatives in high-density scenes. They lack explicit modeling of the target's geometry and spatial distribution, resulting in unstable detection results and low accuracy.
By introducing structural prior knowledge and scenario prior knowledge, aspect ratio constraints are constructed, a penalty mechanism is introduced, and DBSCAN clustering and virtual box construction are combined to supplement and correct the detection boxes, thereby achieving structured analysis of the target.
It significantly reduces false positives, improves the stability and consistency of detection results, and enhances the robustness and applicability of the model, especially in complex industrial scenarios.
Smart Images

Figure CN122175865A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to industrial-grade counting technology, and more particularly to a structured target counting system based on prior knowledge. Background Technology
[0002] Currently, traditional tasks for counting and detecting targets with regular geometric structures mainly rely on general-purpose object detection frameworks such as YOLO and DETR. These methods, with their mature network architecture design and powerful feature learning capabilities, can achieve good performance in conventional scenarios. However, in real-world industrial environments where targets are densely stacked and have highly consistent structures, these methods still have significant limitations.
[0003] First, existing detection models mainly rely on data-driven feature learning during training, lacking explicit modeling of the consistency of standardized industrial target geometry. This makes it difficult to effectively suppress detection boxes that clearly do not conform to structural constraints, leading to structural anomaly predictions and false detections in high-density scenarios.
[0004] Secondly, these methods typically treat each detection target as an independent individual, ignoring the overall consistency of the spatial arrangement and structural distribution patterns of targets in industrial scenarios. They lack the ability to jointly reason based on the scenario structure, resulting in insufficient perception of missed targets in the event of local absence or occlusion. The structural consistency and stability of the detection results are difficult to guarantee, which in turn affects the final counting accuracy and application reliability. Summary of the Invention
[0005] The purpose of this invention is to provide a structured target counting system based on prior knowledge to solve the problems existing in the prior art.
[0006] The structured target counting system based on prior knowledge described in this invention includes the following steps in its workflow:
[0007] S1. Construct category-aware aspect ratio constraints; S2. Introduce aspect ratio violation penalty; S3. Cluster and sort based on x-coordinate; S4. Calculate the adjacent gaps and construct a virtual box; S5. Match the category and insert a new detection box; S6. Output the final detection and counting results; The structured target refers to a target object that has regular geometric structure features and presents a densely arranged form.
[0008] The structured target counting system based on prior knowledge described in this invention has the advantage that by introducing structural prior knowledge and scene prior knowledge, it breaks through the limitation of traditional target detection frameworks that rely solely on data-driven learning, enabling the target detection model to have significant geometric structure perception and scene understanding capabilities, thus demonstrating obvious technical advantages.
[0009] First, compared to traditional object detection methods that only optimize detection boxes based on regression errors and lack effective constraints on the geometric rationality of the target, this invention introduces a structural prior constraint mechanism during the training phase. By constructing a continuously differentiable penalty loss based on the aspect ratio structural features of the target, detection boxes that deviate significantly from the target's structural prior are suppressed. This effectively reduces the generation of structurally abnormal detection boxes without affecting normal detection results, significantly alleviates the false detection problem in high-density scenes, and improves the stability and reliability of detection results.
[0010] Furthermore, this invention allows for adjustable design of the structural prior constraint range and penalty intensity, ensuring that the structural constraints take effect within a reasonable range. This avoids excessive constraints interfering with normal detection results, achieving an effective balance between false positive suppression and false negative control. This mechanism enables the model to maintain stable performance under different industrial scenarios and target density conditions, significantly enhancing the robustness and applicability of the detection model.
[0011] Secondly, this invention further integrates scenario prior knowledge into the detection framework. During the reasoning stage, it combines the spatial distribution pattern of the target in the actual scenario to perform structured analysis on the detection results. By modeling the spatial relationship between adjacent detection boxes, it achieves adaptive supplementation and correction of potential missed targets, thereby effectively improving the integrity and consistency of detection results in complex and dense industrial scenarios.
[0012] The system described in this invention is particularly suitable for the detection and counting of target objects with regular geometric structure features and densely arranged in industrial production and logistics scenarios. Attached Figure Description
[0013] Figure 1 This is a flowchart of the system described in this invention. Detailed Implementation
[0014] To address the problem of false detections and missed detections in the detection and counting of structured targets, this invention proposes a structured target counting system based on prior knowledge. Here, a structured target refers to a target object with regular geometric features and a densely arranged form, such as: — Standardized physical trays used to hold screws, electronic components, or parts; — Boxes, frames, or industrial vehicles with fixed length-to-width ratios and structural dimensions; — Structured containers or carriers arranged in a regular manner in a conveyor belt, shelf, or storage unit.
[0015] The workflow of the system is as follows: Figure 1 As shown, the specific steps include: S1. Construct category-aware aspect ratio constraints; For the raw image dataset containing standardized industrial targets such as pallets and containers, manual annotation was performed using annotation tools such as LabelMe. Subsequently, based on statistical analysis of the ground truth (GT) bounding boxes in the dataset, the predefined aspect ratio range of the targets was obtained. Where c is the target category to be detected. These are the minimum and maximum aspect ratios of category c obtained statistically, defined as follows: These are scaling control parameters for the prior aspect ratio range of the structure, used to construct the target detection aspect ratio safety range. : .
[0016] For the total foreground sample The i-th generated foreground sample is First, obtain the actual category. And obtain the sample coordinates ,in and The x and y coordinates of the top-left and bottom-right corners of the prediction box are given, respectively. Then, the length of the prediction box is calculated. ,Width To avoid the division by zero problem, a numerical stability term is introduced. Thus, the aspect ratio of the predicted foreground sample bounding box is obtained as follows: Category safety interval For the i-th sample The corresponding interval is Thus, on the one hand, the aspect ratio of the predicted bounding box of the foreground sample was obtained, and on the other hand, the safe range of aspect ratio related to the corresponding category of the foreground sample was preserved, providing the necessary data conditions for the design of the subsequent aspect ratio penalty term.
[0017] S2. Introduce aspect ratio violation penalty; If the sample The predicted aspect ratio falls within the legal range of its category, i.e. If the predicted aspect ratio exceeds the legal range, no penalty will be imposed; otherwise, a penalty will be imposed. This introduces an additional penalty to the predicted bounding box. Specifically, an aspect ratio penalty function is defined. Then normalize it to obtain the corresponding penalty loss. ,in Assign a classification confidence weight to the predicted bounding box. This represents the total weight of all positive samples. Then, the penalty loss term is added to the original loss function to obtain the final optimization objective, the bounding box loss regression function. ,in, The intersection-union loss function is used to adjust the strength of the structural bias penalty term in the training loss. Its value is determined through system parameter analysis to form a stable co-optimization relationship between target positioning accuracy and structural rationality constraints.
[0018] S3. Cluster and sort based on x-coordinate; After the model completes inference, this step is performed based on a post-processing supplementary detection mechanism. In the post-processing stage, a set of candidate detection boxes is first obtained. The i-th box is represented as ,in and The x and y coordinates of the top left and bottom right corners of the detection box are respectively. It's a category label. This is a confidence score. Based on the "horizontal column distribution" in densely stacked scenes, the x-coordinate of the center of each detection box is... Clustering was performed using the DBSCAN method to obtain several corresponding columnar checkbox sets. , where k represents the aggregated k columns. Then, for each column of the bounding box set... According to the coordinates of the upper boundary of the detection box Arrange the boxes in ascending order to obtain a vertically ordered sequence of detection boxes. This provides the necessary prerequisites for subsequent gap detection and the construction of new detection frames.
[0019] S4. Calculate the adjacent gaps and construct a virtual box; For each sorted detection box sequence Calculate adjacent detection boxes sequentially and Vertical gap: Simultaneously, take the minimum height of these two adjacent boxes. : ; When the gap length satisfies If so, the gap is determined to correspond to a potential missed detection area, where The threshold value is set as the ratio. Then, a new virtual detection box is constructed within the corresponding gap, with the minimum left boundary value of the adjacent detection boxes used as the left boundary of the new box. The maximum value of the right boundary is used as the right boundary of the new box. The lower boundary of the upper detection box is used as the upper boundary of the new box. The upper boundary of the lower detection box is used as the lower boundary of the new box. .
[0020] S5. Match the category and insert a new detection box; After generating new detection boxes using the above method, they are matched by category and inserted into the original detection box set, thereby enabling the supplementary detection of missed targets: First, calculate the length of the newly constructed virtual detection box. ,Width And thus obtain the corresponding aspect ratio. , .
[0021] Subsequently, a priori aspect ratio dictionary was introduced. Each item in the dictionary is calculated by statistically analyzing the aspect ratio distribution of different categories of ground truth detection boxes in the dataset and taking the center value. The aspect ratio is used as the most representative prior for each category. Based on the prior information, the similarity score between the virtual detection box and each category is calculated: And select the category with the highest score. As the corresponding matching category The obtained confidence score is then added to the original detection box: The final set of predicted bounding boxes is updated as follows: This generates the final detection and counting results, which to some extent enables effective supplementary inspection of missed areas in stacked pallet scenarios.
[0022] S6. Output the final detection and counting results.
[0023] In summary, the system described in this invention is applicable to both single-category and multi-category supplementary detection scenarios. In the case of multi-category supplementary detection, the relationships and structural consistency between target categories are optimized through structural priors and aspect ratio constraints to prevent false detections and missed detections. In the case of single-category supplementary detection, this invention models the structural priors of a specific target category, making the relationships between detection boxes more accurate. This avoids the impact of multi-category crossover in traditional methods, ensuring relatively stable detection results. It is important to emphasize that the aspect ratio loss function itself is a universal constraint for various target types; its effect is consistent regardless of whether it is single-category or multi-category supplementary detection. Therefore, it can perform well in both applications, further improving detection accuracy and robustness.
[0024] For those skilled in the art, various other corresponding changes and modifications can be made based on the technical solutions and concepts described above, and all such changes and modifications should fall within the protection scope of the claims of this invention.
Claims
1. A structured target counting system based on prior knowledge, characterized in that, The workflow includes the following steps: S1. Construct category-aware aspect ratio constraints; S2. Introduce aspect ratio violation penalty; S3. Cluster and sort based on x-coordinate; S4. Calculate the adjacent gaps and construct a virtual box; S5. Match the category and insert a new detection box; S6. Output the final detection and counting results; The structured target refers to a target object that has regular geometric structure features and presents a densely arranged form.
2. The structured target counting system based on prior knowledge according to claim 1, characterized in that, In step S1, the specific steps are as follows: The original image dataset of structured targets is manually annotated; subsequently, based on statistical analysis of the ground truth detection boxes in the dataset, a predefined aspect ratio range of the targets is obtained. Where c is the target category to be detected. These are the minimum and maximum aspect ratios of category c obtained statistically, defined as follows: These are scaling control parameters for the prior aspect ratio range of the structure, used to construct the target detection aspect ratio safety range. : ; For the total foreground sample The i-th generated foreground sample is First, obtain the actual category. And obtain the sample coordinates ,in and The x and y coordinates of the top-left and bottom-right corners of the prediction box are given, respectively. Then, the length of the prediction box is calculated. ,Width , As a numerically stable term, the aspect ratio of the predicted foreground sample box is thus obtained as follows: Category safety interval For the i-th sample The corresponding interval is .
3. The structured target counting system based on prior knowledge according to claim 2, characterized in that, In step S2, the specific steps are as follows: If the sample The predicted aspect ratio is within the legal range of its category. No penalty is imposed if the predicted aspect ratio exceeds the legal range; otherwise, no penalty is imposed. If so, an additional penalty is introduced for the predicted bounding box; Define aspect ratio penalty function Then normalize it to obtain the corresponding penalty loss. ,in Assign a classification confidence weight to the predicted bounding box. The total weight of all positive samples is given; the penalty loss term is added to the original loss function to obtain the final optimization objective, the bounding box loss regression function. ,in, The intersection-union loss function is used to adjust the strength of the structural bias penalty term in the training loss.
4. The structured target counting system based on prior knowledge according to claim 3, characterized in that, In step S3, the specific steps are as follows: First, we obtain a set of candidate detection boxes. The i-th box is represented as ,in and The x and y coordinates of the top left and bottom right corners of the detection box are respectively. It's a category label. It is the confidence score; Based on the densely stacked scene, the center x-coordinate of each detection box Clustering is performed to obtain several corresponding columnar detection box sets. Where k represents the aggregated k columns; for each column of the detection box set According to the coordinates of the upper boundary of the detection box Arrange the boxes in ascending order to obtain a vertically ordered sequence of detection boxes. .
5. The structured target counting system based on prior knowledge according to claim 4, characterized in that, In step S4, the specific steps are as follows: For each sorted detection box sequence Calculate adjacent detection boxes sequentially and Vertical gap: Simultaneously, take the minimum height of these two adjacent boxes. : ; When the gap length satisfies If so, the current gap is determined to correspond to a potential missed detection area, where The threshold value is set as the ratio; a new virtual detection box is constructed within the corresponding gap, and the left boundary of the new box is taken as the minimum left boundary value of the adjacent detection boxes. The maximum value of the right boundary is used as the right boundary of the new box. The lower boundary of the upper detection box is used as the upper boundary of the new box. The upper boundary of the lower detection box is used as the lower boundary of the new box. .
6. The structured target counting system based on prior knowledge according to claim 5, characterized in that, In step S5, the specific steps are as follows: First, calculate the length of the newly constructed virtual detection box. ,Width And thus obtain the corresponding aspect ratio. , ; Subsequently, a priori aspect ratio dictionary was introduced. Take the center value As the most representative prior aspect ratio for the corresponding category; based on prior information, calculate the similarity score between the virtual detection box and each category: And select the category with the highest score. As the corresponding matching category The obtained confidence score is then added to the original detection box: The final set of predicted bounding boxes is updated as follows: This generates the final detection and counting results.