CN-122024143-A - Container detection method, apparatus, computer device, storage medium, and program product
Abstract
The present application relates to a container detection method, apparatus, computer device, storage medium, and program product. The method comprises the steps of extracting features of at least two scales from a current video frame containing a container to be detected to obtain first feature images of the current video frame under different scales, carrying out weighting processing on each first feature image according to feature differences between the current video frame and a previous video frame and priori position information of an opening area of the container to be detected to obtain weighted feature images corresponding to each first feature image, acquiring the current video frame and the previous video frame in the packaging process of the container to be detected, inputting each weighted feature image into a spatial attention module to carry out spatial feature analysis to obtain current container feature information of the container to be detected, wherein the current container feature information comprises the opening area feature, and determining the current opening and closing states of the container to be detected according to the opening area feature. The method can improve the detection efficiency of the container to be detected in the packaging process.
Inventors
- FAN GANG
- LI YUNZHU
- Lin Langqing
Assignees
- 厦门阿匹斯智能机器人有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260324
Claims (10)
- 1. A method of testing a container, the method comprising: extracting features of at least two scales from a current video frame containing a container to be detected to obtain a first feature map of the current video frame under different scales; Weighting each first characteristic image according to the characteristic difference between the current video frame and the previous video frame and the prior position information of the opening area of the container to be detected to obtain a weighted characteristic image corresponding to each first characteristic image, wherein the current video frame and the previous video frame are acquired in the process of packaging the container to be detected; Inputting each weighted feature map into a spatial attention module for spatial feature analysis to obtain current container feature information of the container to be detected, wherein the current container feature information comprises opening area features; And determining the current opening and closing state of the container to be detected according to the opening area characteristics.
- 2. The method according to claim 1, wherein the performing feature extraction of at least two scales on a current video frame containing a container to be detected to obtain a first feature map of the current video frame at different scales includes: Carrying out convolution processing on the current video frame to obtain a preliminary feature map; Uniformly splitting the preliminary feature map into at least two branch features in the channel dimension, wherein the different branch features adopt a residual error connection structure for feature interaction; Extracting features of each branch feature, and carrying out feature fusion on the extracted features based on residual error connection structures among different branch features to obtain an intermediate feature map; and downsampling the intermediate feature map by at least two scales to obtain a first feature map of the current video frame under different scales.
- 3. The method of claim 1, wherein the feature differences comprise feature differences between a first feature map at each scale and a second feature map of the previous video frame at the scale; and weighting each first feature map according to the feature difference between the current video frame and the previous video frame and the prior position information of the opening area of the container to be detected to obtain a weighted feature map corresponding to each first feature map, wherein the weighting feature map comprises: for each scale, determining the motion weight of the first feature map under the scale according to the feature difference between the first feature map under the scale and the second feature map of the previous video frame under the scale; Determining the position weight of each first feature map according to the priori position information of the opening area; And for each first feature map, carrying out weighting processing on the first feature map according to the motion weight and the position weight of the first feature map to obtain a weighted feature map corresponding to the first feature map.
- 4. The method of claim 1, wherein the spatial attention module comprises a pooling stitching unit, a convolution unit, and a weighting unit connected in sequence; Inputting each weighted feature map into a spatial attention module for spatial feature analysis to obtain current container feature information of the container to be detected, wherein the method comprises the following steps: inputting each weighted feature map into the pooling splicing unit to obtain a spatial attention feature map of each weighted feature map, wherein the pooling splicing unit carries out global average pooling and global maximum pooling treatment on each weighted feature map; The spatial attention feature images of the weighted feature images are input into the convolution unit, the convolution unit takes the opening area of the container to be detected as prior constraint, convolution processing is carried out on the spatial attention feature images, and the spatial attention weight images of the weighted feature images are output; And inputting each weighted feature map and each spatial attention weight map into the weighting unit to obtain the current container feature information of the container to be detected, wherein the weighting unit carries out weighted enhancement on the corresponding weighted feature map based on the input spatial attention weight map and outputs the current container feature information of the container to be detected.
- 5. The method of claim 1, wherein determining the current open and closed state of the container to be inspected based on the opening area characteristics comprises: Performing feature analysis on the opening area features to obtain container detection confidence and opening and closing state results; And when the detection confidence is higher than a preset threshold, determining the current opening and closing state of the container to be detected according to the opening and closing state result.
- 6. The method of any of claims 1-5, wherein the current container characteristic information further comprises container location information, the method further comprising: Determining an effective video frame interval of the packaging process of the container to be detected according to the opening and closing state of the container to be detected under a plurality of continuous video frames, wherein the plurality of continuous video frames comprise the current video frame and the last video frame; and detecting the objects in the container to be detected according to the container position information and the opening area characteristics in the effective video frame interval.
- 7. A container inspection apparatus, the apparatus comprising: the feature extraction module is used for extracting features of at least two scales from a current video frame containing a container to be detected to obtain a first feature map of the current video frame under different scales; The feature weighting module is used for carrying out weighting processing on each first feature map according to the feature difference between the current video frame and the last video frame and the prior position information of the opening area of the container to be detected to obtain weighted feature maps corresponding to each first feature map, wherein the current video frame and the last video frame are acquired in the process of packaging the container to be detected; The information determining module is used for inputting each weighted feature map into the spatial attention module for spatial feature analysis to obtain the current container feature information of the container to be detected, wherein the current container feature information comprises opening area features; and the state determining module is used for determining the current opening and closing state of the container to be detected according to the opening area characteristics.
- 8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
- 9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
- 10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
Description
Container detection method, apparatus, computer device, storage medium, and program product Technical Field The present application relates to the field of computer technology, and in particular, to a container detection method, apparatus, computer device, storage medium, and program product. Background In modern industrial production, packaging is used as a key link before product delivery, and the quality of the packaging directly influences the market reputation of the product and the economic benefits of enterprises, wherein the packaging is not perfect, the packaging is not easy to be assembled, and the like, which are common quality defects in the packaging process. The traditional detection mode is mostly dependent on manual naked eye detection, and has the problems of low efficiency, high omission factor, high labor cost, easiness in being influenced by subjective factors and the like. Disclosure of Invention In view of the foregoing, it is desirable to provide a container inspection method, apparatus, computer device, storage medium, and program product that can improve the inspection efficiency of containers to be inspected during packaging. In a first aspect, the present application provides a container inspection method comprising: extracting features of at least two scales from a current video frame containing a container to be detected to obtain a first feature map of the current video frame under different scales; Weighting each first characteristic image according to the characteristic difference between the current video frame and the previous video frame and the prior position information of the opening area of the container to be detected to obtain a weighted characteristic image corresponding to each first characteristic image, wherein the current video frame and the previous video frame are acquired in the process of packaging the container to be detected; Inputting each weighted feature map into a spatial attention module for spatial feature analysis to obtain current container feature information of the container to be detected, wherein the current container feature information comprises opening area features; And determining the current opening and closing state of the container to be detected according to the opening area characteristics. In one embodiment, the extracting features of at least two scales from a current video frame including a container to be detected to obtain a first feature map of the current video frame under different scales includes: Carrying out convolution processing on the current video frame to obtain a preliminary feature map; Uniformly splitting the preliminary feature map into at least two branch features in the channel dimension, wherein the different branch features adopt a residual error connection structure for feature interaction; Extracting features of each branch feature, and carrying out feature fusion on the extracted features based on residual error connection structures among different branch features to obtain an intermediate feature map; and downsampling the intermediate feature map by at least two scales to obtain a first feature map of the current video frame under different scales. In one embodiment, the feature differences include feature differences between a first feature map at each scale and a second feature map of the previous video frame at the scale; and weighting each first feature map according to the feature difference between the current video frame and the previous video frame and the prior position information of the opening area of the container to be detected to obtain a weighted feature map corresponding to each first feature map, wherein the weighting feature map comprises: for each scale, determining the motion weight of the first feature map under the scale according to the feature difference between the first feature map under the scale and the second feature map of the previous video frame under the scale; Determining the position weight of each first feature map according to the priori position information of the opening area; And for each first feature map, carrying out weighting processing on the first feature map according to the motion weight and the position weight of the first feature map to obtain a weighted feature map corresponding to the first feature map. In one embodiment, the spatial attention module comprises a pooling splicing unit, a convolution unit and a weighting unit which are sequentially connected; Inputting each weighted feature map into a spatial attention module for spatial feature analysis to obtain current container feature information of the container to be detected, wherein the method comprises the following steps: inputting each weighted feature map into the pooling splicing unit to obtain a spatial attention feature map of each weighted feature map, wherein the pooling splicing unit carries out global average pooling and global maximum pooling treatment on each weighted feature map; The