A computer vision-based yard cargo automatic identification method
Patent Information
- Application Number
- CN202611066981.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-17
- Publication Date
- 2026-10-13
AI Technical Summary
这类方法虽具备一定的识别效果,但在堆场图像中面临显著挑战:首先,堆场货物的图像采集常受到光照变化、阴影遮挡、低照环境等干扰,现有模型在不同光照条件下的鲁棒性不足,容易导致检测结果不稳定;其次,现有方法通常缺乏对多尺度语义信息的精细建模,无法有效兼顾局部纹理特征与全局语义信息,影响识别精度;当前模型在训练过程中往往未引入结构化的对比约束与语义蒸馏机制,无法充分利用不同分支特征间的互补性,限制了在复杂场景下的泛化能力
对保留预测框集合的边界框坐标执行图像边界裁剪与最小尺寸阈值过滤;将经非极大值抑制与阈值过滤后的保留预测框作为最终检测结果,输出对应的堆场货物类别标签与边界框坐。
Smart Images

Figure CN122906445A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and artificial intelligence, and in particular to an automatic identification method for yard cargo based on computer vision. Background Technology
[0002] In port terminals, logistics warehouses, and container yards, the types and sizes of goods are diverse, and their locations are densely distributed. Efficiently and accurately identifying the category and spatial location of goods is one of the key technologies for achieving intelligent yard management and automated scheduling. Traditional cargo identification methods mostly rely on manual inspection or tag-based identification methods using sensors such as RFID. However, these methods suffer from high deployment costs, low identification accuracy, and inability to handle non-standard goods, making them unsuitable for the actual needs of today's large-scale, high-frequency operations in container yards. In recent years, with the development of computer vision technology and deep learning models, image recognition-based cargo detection methods have been gradually applied in container yard scenarios, providing a feasible path to achieve non-contact, automated identification.
[0003] Existing computer vision-based cargo recognition methods mostly employ general object detection models, such as Faster R-CNN, YOLO series, or DETR frameworks, to directly perform end-to-end detection on cargo images in storage yards. While these methods achieve certain recognition results, they face significant challenges in storage yard images: First, image acquisition of storage yard cargo is often affected by changes in lighting, shadow occlusion, and low-light environments, and existing models lack robustness under different lighting conditions, easily leading to unstable detection results. Second, existing methods typically lack fine-grained modeling of multi-scale semantic information, failing to effectively balance local texture features with global semantic information, thus affecting recognition accuracy. Furthermore, current models often lack structured contrast constraints and semantic distillation mechanisms during training, failing to fully utilize the complementarity between features from different branches, thus limiting their generalization ability in complex scenes.
[0004] Therefore, existing technologies urgently need a yard cargo recognition method that can adapt to the complex lighting environment of yards, possess multi-scale feature modeling and semantic alignment capabilities, and achieve effective feature supervision and robustness enhancement during the training phase. Addressing these issues, this invention proposes a computer vision-based automatic yard cargo recognition method. It employs an improved DINOv2 model, constructs a dual-branch structure for both original and enhanced lighting, and introduces distillation supervision, projection comparison, and joint loss optimization mechanisms to achieve accurate identification of yard cargo categories and boundary locations, significantly improving recognition performance and practical value in complex environments. Summary of the Invention
[0005] One objective of this invention is to propose an automatic identification method for yard cargo based on an improved deep vision network. This invention fully integrates the improved DINOv2 visual backbone network, illumination enhancement branch, semantic distillation structure and projection contrast supervision mechanism, and describes in detail the training and inference process for multi-scale semantic feature modeling and robust cargo detection under complex lighting conditions. It has the advantages of high recognition accuracy, strong illumination adaptability and good model training stability.
[0006] An automatic identification method for yard cargo based on computer vision according to an embodiment of the present invention includes the following steps: Step 1: Acquire a sequence of images of cargo in the yard, perform preprocessing on the cargo image sequence, and obtain cargo images of the yard; Step 2: Input the original samples into the original illumination branch of the improved DINOv2 model, input the low-light enhanced samples into the enhanced illumination branch, and extract multi-scale semantic features; Step 3: Set up the projection head to map multi-scale semantic features to a unified-dimensional embedding space, generating projected feature vectors; Step 4: Set up the distillation head, use the semantic features output by the original illumination branch as teacher features, and use the semantic features output by the enhanced illumination branch as student features, perform semantic distillation, and generate distilled feature vectors; Step 5: Input the multi-scale semantic features into the yard cargo detection head, output the cargo category label and bounding box coordinates, calculate the classification loss and regression loss, and calculate the contrast loss by combining the projected feature vectors; Step 6: Output the category and location information of the cargo in the yard.
[0007] Optionally, the process of acquiring the cargo image sequence in the storage yard involves preprocessing the cargo image sequence, specifically: Image acquisition equipment is installed in the yard operation area. The image acquisition equipment includes fixed camera equipment and mobile image acquisition terminals. Perform image timestamp synchronization and image sequence number calibration operations on the acquired stockpile cargo image sequence to generate stockpile cargo image frames arranged in chronological order; Perform camera intrinsic parameter calibration and geometric distortion correction operations on the image frames of cargo in the yard to complete the image correction of radial and tangential distortion; The corrected image frames are processed by illumination equalization, white balance correction and color normalization to generate a balanced image frame of the yard cargo. Pixel denoising and local contrast enhancement are performed on the image frames of cargo in the yard to suppress image noise and interference from blurred areas. Based on reference points or markers in the yard ground area, perform image scale calibration to establish a mapping relationship between image pixel coordinates and actual physical dimensions, and output images of the yard cargo.
[0008] Optionally, the original samples are input into the original illumination branch of the improved DINOv2 model, and the low-light enhancement samples are input into the enhanced illumination branch to extract multi-scale semantic features, specifically: From the images of cargo in the yard, select image frames whose clarity meets the preset threshold and which completely cover the cargo area as the original samples; Perform size resampling and pixel normalization on the original sample; Based on image enhancement strategies, corresponding low-light enhanced samples are generated from the original samples; The original samples are input into the original illumination branch of the improved DINOv2 model to perform multi-scale feature extraction and output the original illumination multi-scale semantic features. The low-light enhancement samples are input into the enhanced lighting branch of the improved DINOv2 model to perform multi-scale feature extraction and output enhanced lighting multi-scale semantic features. Feature standardization and channel alignment are performed on the original illumination multi-scale semantic features and the enhanced illumination multi-scale semantic features respectively to obtain multi-scale semantic features.
[0009] Optionally, the step of setting the projection head to map multi-scale semantic features to a unified-dimensional embedding space specifically involves: Multi-scale semantic features are input into a two-layer fully connected mapping structure of the projection head; The first fully connected mapping structure receives the input multi-scale semantic feature set and outputs an intermediate mapping vector, on which the ReLU activation function is applied. The second fully connected mapping structure receives intermediate mapping vectors and outputs fixed-dimensional projection vectors, forming projection feature vectors in a unified embedding space.
[0010] Optionally, performing semantic distillation to generate a distilled feature vector specifically involves: The original multi-scale semantic features of illumination are input into the teacher's distillation head in the order of shallow features, medium features, and deep features; The enhanced illumination multi-scale semantic features are input into the student distillation head in the order of shallow features, medium features, and deep features; The distillation head includes a feature alignment layer, a nonlinear transformation layer, and a compression layer connected in sequence. The feature alignment layer is a fully connected mapping layer used to map the input multi-scale semantic features to a unified dimension of the distillation space; The nonlinear transformation layer performs nonlinear transformations on student features; The compression layer is a fully connected mapping layer used to output a distillation feature vector of fixed dimensions; The teacher's distillation feature vector and the student's distillation feature vector are input into the distillation loss calculation unit at the output end; The distillation loss calculation unit performs a difference measurement on the teacher's distillation feature vector and the student's distillation feature vector based on Euclidean distance and cosine similarity, and generates a distillation loss value. Optionally, the step of inputting multi-scale semantic features into the yard cargo detection head and outputting cargo category labels and bounding box coordinates specifically involves: Multi-scale semantic features are input into the classification branch and bounding box regression branch of the yard cargo detection head according to the scale; The classification branch outputs the class probability vectors at each scale. The bounding box regression branch outputs the bounding box coordinate parameters at various scales; The category probability vector is combined with the bounding box coordinate parameters to form the output result of the yard cargo detection head. The output result includes the yard cargo category label and the corresponding bounding box coordinates. Optionally, the calculation of classification loss and regression loss specifically involves: The images of cargo in the yard are filtered and manually labeled to generate training sample images containing category labels and the actual location bounding boxes of cargo in the yard. Calculate the intersection-union ratio (IUR) between the predicted bounding box and the labeled bounding box. When the IUR is greater than or equal to a preset threshold, establish a matching relationship between the predicted bounding box and the corresponding labeled bounding box and mark it as a positive sample. The positive sample inherits the yard cargo category label and bounding box coordinate information of the corresponding labeled bounding box to form a positive sample training label. When the crossover ratio is less than a preset threshold, the predicted bounding box is marked as a negative sample, and the negative sample is marked as the background category, thus forming negative sample training labels; The positive and negative training labels are mapped to the feature layers of each scale according to the scale position of the prediction box, generating a multi-scale training label set. The labeled box is the preset true location box of the cargo in the storage yard in the training sample image, and the predicted box is the bounding box coordinates output by the storage yard cargo detection head; The classification loss is calculated based on the class probability vectors output by the classification branch at each scale feature layer and the class labels in the corresponding multi-scale training label set; The regression loss is calculated based on the bounding box coordinate parameters output by the bounding box regression branch at each scale feature layer and the bounding box coordinate information in the corresponding multi-scale training label set; The regression loss is a weighted sum of the perfect intersection-union loss and the smoothed L1 loss.
[0011] Optionally, the step of calculating the contrast loss by combining the projected feature vectors specifically involves: Pair the projected feature vectors output from the original illumination branch and the enhanced illumination branch of the same pile of goods image sequence to construct consistent feature pairs; The projected feature vectors of cargo image sequences from different storage yards are paired to construct heterogeneous feature pairs; The similarity between consistent feature pairs and dissimilar feature pairs is calculated in a unified embedding space. Attraction constraints are applied to consistent feature pairs and separation constraints are applied to dissimilar feature pairs to obtain the contrastive loss. The distillation loss value is linearly combined with the classification loss, regression loss, and contrast loss according to preset weights to form the total training loss.
[0012] Optionally, the output of the category and location information of the cargo in the storage yard specifically includes: Set the optimizer, learning rate, and loss weight coefficients; initialize the parameters of the enhanced lighting branch, projection head, student distillation head, and yard cargo detection head. Perform gradient backpropagation to minimize the total training loss function, and iteratively update the parameters of the enhanced lighting branch, projection head, student distillation head, and yard cargo detection head, while keeping the parameters of the original lighting branch and teacher distillation head unchanged. Repeat the gradient backpropagation and iterative update process until the preset number of training rounds or the total training loss meets the convergence condition, complete the end-to-end optimization, and obtain the improved DINOv2 model after training. During the inference phase, the images of the yard cargo are input into the original lighting branch and the yard cargo detection head of the trained improved DINOv2 model, and the output is a set of prediction boxes, each of which contains a class probability vector and bounding box coordinate parameters. Take the maximum component of the category probability vector of each prediction box as the confidence score and record the corresponding yard cargo category label; Threshold filtering is performed on the predicted boxes based on a preset confidence threshold to obtain a set of predicted boxes with a confidence score not lower than the preset confidence threshold; The predicted bounding boxes with confidence scores not lower than a preset confidence threshold are grouped by category, and then sorted from high to low within each category group according to their confidence scores. Non-maximum suppression is performed within each category group: the prediction box with the highest current confidence score is selected as the retained prediction box, the intersection-union ratio (IU) of the retained prediction box and the other prediction boxes is calculated, and prediction boxes with IU ratios not lower than the preset IU threshold are deleted until the category groups are traversed, and the set of retained prediction boxes is output. Image boundary cropping and minimum size threshold filtering are performed on the bounding box coordinates of the retained predicted box set; the retained predicted boxes after non-maximum suppression and threshold filtering are used as the final detection results, and the corresponding yard cargo category labels and bounding box coordinates are output. Attached Figure Description
[0013] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is an overall flowchart of a computer vision-based automatic identification method for yard cargo proposed in this invention. Figure 2 This is a schematic diagram of the improved DINOv2 model structure of the automatic identification method for yard cargo based on computer vision proposed in this invention. Figure 3 This is a structural diagram of the semantic distillation module of a computer vision-based automatic identification method for yard cargo proposed in this invention. Detailed Implementation
[0014] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0015] refer to Figure 1-3 A computer vision-based method for automatic identification of cargo in a storage yard includes the following steps: Step 1: Acquire a sequence of images of cargo in the yard, perform preprocessing on the cargo image sequence, and obtain cargo images of the yard; Step 2: Input the original samples into the original illumination branch of the improved DINOv2 model, input the low-light enhanced samples into the enhanced illumination branch, and extract multi-scale semantic features; Step 3: Set up the projection head to map multi-scale semantic features to a unified-dimensional embedding space, generating projected feature vectors; Step 4: Set up the distillation head, use the semantic features output by the original illumination branch as teacher features, and use the semantic features output by the enhanced illumination branch as student features, perform semantic distillation, and generate distilled feature vectors; Step 5: Input the multi-scale semantic features into the yard cargo detection head, output the cargo category label and bounding box coordinates, calculate the classification loss and regression loss, and calculate the contrast loss by combining the projected feature vectors; Step 6: Output the category and location information of the cargo in the yard.
[0016] This invention proposes an automatic identification method for yard cargo based on an improved DINOv2 model. By constructing original illumination branches and enhanced illumination branches to extract multi-scale semantic features, a projection head is introduced to unify the feature dimensions, guiding the distillation head to perform semantic distillation with the original illumination features as the teacher and the enhanced illumination features as the student. Combined with the cargo detection head, the method completes joint prediction of category and location. During the training phase, the method jointly minimizes the classification loss, regression loss, and contrastive distillation loss, thereby significantly improving the model's robustness and detection accuracy under complex lighting conditions.
[0017] In this embodiment, the acquisition of the cargo image sequence in the storage yard, and the preprocessing of the cargo image sequence, specifically includes: Image acquisition equipment is set up in the yard operation area. The image acquisition equipment includes fixed camera equipment and mobile image acquisition terminals to acquire image sequences of goods in the yard. Perform image timestamp synchronization and image sequence number calibration operations on the acquired stockpile cargo image sequence to generate stockpile cargo image frames arranged in chronological order; Perform camera intrinsic parameter calibration and geometric distortion correction operations on the image frames of cargo in the yard to complete the image correction of radial and tangential distortion; The corrected image frames are processed by illumination equalization, white balance correction and color normalization to generate a balanced image frame of the yard cargo. Pixel denoising and local contrast enhancement are performed on the image frames of cargo in the yard to suppress image noise and interference from blurred areas. Based on reference points or markers in the yard ground area, perform image scale calibration to establish a mapping relationship between image pixel coordinates and actual physical dimensions, and output images of the yard cargo.
[0018] In this embodiment, the original samples are input into the original illumination branch of the improved DINOv2 model, and the low-light enhancement samples are input into the enhanced illumination branch to extract multi-scale semantic features, specifically as follows: From the images of cargo in the yard, select image frames whose clarity meets the preset threshold and which completely cover the cargo area as the original samples; Perform size resampling and pixel normalization on the original sample; Based on image enhancement strategies, corresponding low-light enhanced samples are generated from the original samples; The image enhancement strategy includes performing Gamma correction, histogram equalization, Retinex illumination equalization, and color normalization on the original samples to generate low-light enhanced samples.
[0019] The original samples are input into the original illumination branch of the improved DINOv2 model to perform multi-scale feature extraction and output the original illumination multi-scale semantic features. The low-light enhancement samples are input into the enhanced lighting branch of the improved DINOv2 model to perform multi-scale feature extraction and output enhanced lighting multi-scale semantic features. The multi-scale feature extraction includes: dividing the input image into image patches and performing linear embedding, inputting the patch into a multi-layer coding structure based on Vision Transformer, outputting feature sequences at different levels of the multi-layer coding structure, performing normalization and scale alignment on the feature sequences, obtaining shallow, medium and deep feature representations respectively, and forming multi-scale semantic features; the input image includes the original sample and the low-light enhanced sample. Feature standardization and channel alignment are performed on the original and enhanced multi-scale semantic features of illumination, respectively, to obtain multi-scale semantic features. The feature standardization is based on mean and variance normalization, and the channel alignment is achieved by transforming the number of channels of the original and enhanced multi-scale semantic features of illumination to a unified dimension through a one-dimensional fully connected mapping.
[0020] This invention proposes an automatic cargo identification method for yard operation environments. By deploying fixed and mobile image acquisition devices in the operation area, high-quality cargo image sequences are obtained. Preprocessing operations such as time synchronization, distortion correction, illumination equalization, pixel denoising, and scale calibration are sequentially performed to obtain image data with consistent brightness and comparable scale. Further, image frames meeting the required clarity are selected as original samples. Low-light enhancement samples are generated using strategies such as Gamma correction, histogram equalization, and Retinex. These samples are then input into the original illumination branch and the enhanced illumination branch of an improved DINOv2 model, respectively. Multi-scale semantic features are extracted using a Vision Transformer structure. Feature standardization and channel alignment operations unify the multi-scale representation of the original and enhanced samples, laying a structured semantic foundation for subsequent distillation and detection. This significantly improves the stability and generalization ability of cargo identification under complex lighting conditions.
[0021] In this embodiment, the step of setting the projection head to map multi-scale semantic features to a unified-dimensional embedding space specifically involves: Multi-scale semantic features are input into a two-layer fully connected mapping structure of the projection head; The first fully connected mapping structure receives the input multi-scale semantic feature set and outputs an intermediate mapping vector, on which the ReLU activation function is applied. The second fully connected mapping structure receives intermediate mapping vectors and outputs fixed-dimensional projection vectors, forming projection feature vectors in a unified embedding space.
[0022] In this embodiment, performing semantic distillation to generate a distillation feature vector specifically involves: The original multi-scale semantic features of illumination are input into the teacher's distillation head in the order of shallow features, medium features, and deep features; The enhanced illumination multi-scale semantic features are input into the student distillation head in the order of shallow features, medium features, and deep features; The shallow features are the local texture and edge feature sequences output by the first third of the encoding layer of the improved DINOv2 model; the middle features are the region contour and structural feature sequences output by the middle third of the encoding layer of the improved DINOv2 model; and the deep features are the global semantic and category feature sequences output by the last third of the encoding layer of the improved DINOv2 model.
[0023] The distillation head includes a feature alignment layer, a nonlinear transformation layer, and a compression layer connected in sequence. The feature alignment layer is a fully connected mapping layer used to map the input multi-scale semantic features to a unified dimension of the distillation space; The nonlinear transformation layer performs nonlinear transformations on student features; The compression layer is a fully connected mapping layer used to output a distillation feature vector of fixed dimensions; The teacher's distillation feature vector and the student's distillation feature vector are input into the distillation loss calculation unit at the output end; The distillation loss calculation unit performs a difference measurement on the teacher's and student's distillation feature vectors based on Euclidean distance and cosine similarity, generating a distillation loss value. : ; Distillation of the feature vector for teachers; Distill the feature vector for the student; Euclidean distance constraint; Cosine similarity; These are weighting coefficients used to balance the contributions of Euclidean and cosine losses.
[0024] The distillation loss value is combined with the student distillation feature vector to form a distillation supervision signal, which is then output.
[0025] The student distillation feature vector and the distillation loss value are weighted and concatenated to form an extended vector, which is then output as a distillation supervision signal.
[0026] This invention introduces a feature alignment mechanism with a unified embedding space and a multi-scale semantic distillation module based on the improved DINOv2 model. By setting up a projection head composed of two fully connected layers, multi-scale semantic features are mapped into projected feature vectors of a unified dimension, improving the expressive consistency of cross-scale feature fusion. Furthermore, the shallow, medium, and deep semantic features of the original illumination and enhanced illumination samples are respectively input into the teacher distillation head and the student distillation head. After feature alignment, nonlinear transformation, and compression operations, corresponding distillation feature vectors are generated. The difference between the two is measured by a distillation loss function constructed by fusing Euclidean distance and cosine similarity. The student distillation features and distillation loss are weighted and concatenated to form a distillation supervision signal, realizing effective supervision and guidance of the enhanced illumination branch, thereby enhancing the model's semantic alignment ability and target recognition robustness under complex illumination conditions.
[0027] In this embodiment, the step of inputting multi-scale semantic features into the yard cargo detection head and outputting cargo category labels and bounding box coordinates specifically involves: Multi-scale semantic features are input into the classification branch and bounding box regression branch of the yard cargo detection head according to the scale; The classification branch outputs the class probability vectors at each scale. The bounding box regression branch outputs the bounding box coordinate parameters at various scales; In the improved DINOv2 model, the classification branch and bounding box regression branch are used to predict the target query features output by the decoder, generating the category probability vector and bounding box coordinate parameters of the cargo in the yard, respectively. This invention, while retaining the decoder structure and target query mechanism of the original DINOv2 model, improves the robustness and accuracy of classification and localization by introducing illumination enhancement processing and multi-scale feature adaptation mechanisms, making it particularly suitable for target detection tasks in complex lighting and occlusion environments in yards.
[0028] The input image is processed by the backbone network and the feature extraction network to generate a multi-scale image feature map, which, along with a set of learnable target query vectors, is input into the Transformer decoder. The target query features output by the decoder are then input into the classification branch and the bounding box regression branch, respectively, to complete the category determination and location regression of the cargo targets in the yard.
[0029] The classification branch outputs the category probability vector for each target query, representing the likelihood of each target belonging to each category; the bounding box regression branch outputs the bounding box coordinate parameters for each target, representing the target's location range and size information in the input image. These two types of outputs are calculated independently at each scale feature layer and are ultimately used in subsequent training supervision and inference selection processes.
[0030] The category probability vector is combined with the bounding box coordinate parameters to form the output result of the yard cargo detection head. The output result includes the yard cargo category label and the corresponding bounding box coordinates.
[0031] This invention constructs a yard cargo detection head based on an improved DINOv2 model. By retaining the original decoder structure and target query mechanism, it introduces illumination enhancement and multi-scale feature adaptation strategies, effectively improving classification and localization accuracy in complex lighting and occlusion scenarios. Specifically, the multi-scale semantic features generated after image processing by the backbone network and feature extraction network, along with the learnable target query vector, are input into the Transformer decoder. The output target query features are then fed into the classification branch and bounding box regression branch, respectively, independently generating the category probability vector and bounding box coordinate parameters of the yard cargo at each scale. Finally, the detection results, containing the yard cargo category label and corresponding bounding box position, are output, providing a structured decision-making basis for subsequent training and inference processes.
[0032] In this embodiment, the calculation of classification loss and regression loss specifically involves: The images of cargo in the yard are filtered and manually labeled to generate training sample images containing category labels and the actual location bounding boxes of cargo in the yard. Calculate the intersection-union ratio (IUR) between the predicted bounding box and the labeled bounding box. When the IUR is greater than or equal to a preset threshold, establish a matching relationship between the predicted bounding box and the corresponding labeled bounding box and mark it as a positive sample. The positive sample inherits the yard cargo category label and bounding box coordinate information of the corresponding labeled bounding box to form a positive sample training label. When the crossover ratio is less than a preset threshold, the predicted bounding box is marked as a negative sample, and the negative sample is marked as the background category, thus forming negative sample training labels; The positive and negative training labels are mapped to the feature layers of each scale according to the scale position of the prediction box, generating a multi-scale training label set. The labeled box is the preset true location box of the cargo in the storage yard in the training sample image, and the predicted box is the bounding box coordinates output by the storage yard cargo detection head; The classification loss is calculated based on the class probability vectors output by the classification branch at each scale feature layer and the class labels in the corresponding multi-scale training label set. : ; The number of samples; This represents the predicted probability of the corresponding class in the class probability vector; The true class in the training labels (one-hot encoding); As a category balance factor; For difficult cases, the regulatory factor is...
[0033] The regression loss is calculated based on the bounding box coordinate parameters output by the bounding box regression branch at each scale feature layer and the bounding box coordinate information in the corresponding multi-scale training label set. : ; Complete intersection and union loss : ; ; For the predicted bounding box region, The area marked with a label. To surround and The smallest closure region.
[0034] Smoothing loss : ; These are the coordinate parameters of the prediction box; These are the coordinate parameters of the annotation box.
[0035] The regression loss is a weighted sum of the perfect intersection-union loss and the smoothing loss.
[0036] This invention effectively improves the classification and localization supervision accuracy in yard cargo detection tasks by introducing a rigorous positive and negative sample screening and matching mechanism, combined with a multi-scale training label construction method. During the training phase, yard cargo images are first manually labeled to generate realistic category labels and location bounding boxes. Then, positive and negative sample matching rules are set based on the intersection-union ratio (IU) between predicted and labeled boxes, constructing a training label set covering multi-scale feature layers. On this basis, the classification loss is calculated based on the category probability vector output by the classification branch and the realistic category labels, while the regression loss is calculated based on the bounding box coordinate parameters output by the bounding box regression branch and the realistic bounding boxes. The regression loss integrates the complete IU loss and the smoothed L1 loss to enhance robustness to errors in target size and location. This loss design balances sample class imbalance and regression accuracy, providing training assurance for the improved DINOv2 model to achieve high-precision target detection in the complex environment of a yard.
[0037] In this embodiment, the calculation of the contrast loss by combining the projection feature vectors specifically involves: Pair the projected feature vectors output from the original illumination branch and the enhanced illumination branch of the same pile of goods image sequence to construct consistent feature pairs; The projected feature vectors of cargo image sequences from different storage yards are paired to construct heterogeneous feature pairs; The similarity between consistent feature pairs and dissimilar feature pairs is calculated in a unified embedding space. An attraction constraint is applied to the consistent feature pairs and a separation constraint is applied to the dissimilar feature pairs to obtain the contrast loss. The attraction constraint maximizes the similarity of consistent feature pairs in the unified embedding space, and the separation constraint minimizes the similarity of dissimilar feature pairs in the unified embedding space. The two are combined to form the contrast loss.
[0038] The distillation loss value is linearly combined with the classification loss, regression loss, and contrast loss according to preset weights to form the total training loss; In this embodiment, the output of the category and location information of the cargo in the storage yard specifically refers to: Set the optimizer, learning rate, and loss weight coefficients; initialize the parameters of the enhanced lighting branch, projection head, student distillation head, and yard cargo detection head. Perform gradient backpropagation to minimize the total training loss function, and iteratively update the parameters of the enhanced lighting branch, projection head, student distillation head, and yard cargo detection head, while keeping the parameters of the original lighting branch and teacher distillation head unchanged. The iterative update includes: calculating the gradient of the total training loss function with respect to the parameters of the enhanced lighting branch, projection head, student distillation head, and yard cargo detection head based on the gradient backpropagation results, and using an optimizer to iteratively update the parameters of the enhanced lighting branch, projection head, student distillation head, and yard cargo detection head according to a set learning rate; Repeat the gradient backpropagation and iterative update process until the preset number of training rounds or the total training loss meets the convergence condition, complete the end-to-end optimization, and obtain the improved DINOv2 model after training. During the inference phase, the images of the yard cargo are input into the original lighting branch and the yard cargo detection head of the trained improved DINOv2 model, and the output is a set of prediction boxes, each of which contains a class probability vector and bounding box coordinate parameters. Take the maximum component of the category probability vector of each prediction box as the confidence score and record the corresponding yard cargo category label; Threshold filtering is performed on the predicted boxes based on a preset confidence threshold to obtain a set of predicted boxes with a confidence score not lower than the preset confidence threshold; The predicted bounding boxes with confidence scores not lower than a preset confidence threshold are grouped by category, and then sorted from high to low within each category group according to their confidence scores. Non-maximum suppression is performed within each category group: the prediction box with the highest current confidence score is selected as the retained prediction box, the intersection-union ratio (IU) of the retained prediction box and the other prediction boxes is calculated, and prediction boxes with IU ratios not lower than the preset IU threshold are deleted until the category groups are traversed, and the set of retained prediction boxes is output. Image boundary cropping and minimum size threshold filtering are performed on the bounding box coordinates of the retained predicted box set; the retained predicted boxes after non-maximum suppression and threshold filtering are used as the final detection results, and the corresponding yard cargo category labels and bounding box coordinates are output.
[0039] This invention constructs a pair of consistent and dissimilar features to calculate the contrastive loss, guiding the model to learn illumination-invariant discriminative features in a unified embedding space. This loss is then jointly optimized with classification loss, regression loss, and distillation loss to form the total training loss. Gradient backpropagation is used for end-to-end training and optimization of the enhanced illumination branch, projection head, student distillation head, and yard cargo detection head. During the inference phase, only the original illumination branch and yard cargo detection head are retained. Based on the class probability and bounding box coordinate parameters of the predicted box, combined with confidence filtering and non-maximum suppression strategies, the class label and location coordinates of each yard cargo are accurately output. This method exhibits strong illumination robustness and recognition accuracy in complex backgrounds, significantly improving the practicality and engineering adaptability of automatic yard cargo identification.
[0040] In this embodiment, the improvements of the modified DINOv2 model include: In the main structure, an original lighting branch and an enhanced lighting branch are set up. The two branches use the same VisionTransformer encoding structure and use independent parameters during the training phase. During the training phase, the parameters of the original lighting branch are frozen and retained for generating teacher features, while the parameters of the enhanced lighting branch are used for optimization and for generating student features. During the inference phase, only the original lighting branch and the yard cargo detection head are retained.
[0041] A hierarchical output and unified preprocessing process is adopted. When the number of coding layers is 24, the shallow features come from coding layers 1 to 8, the middle features come from coding layers 9 to 16, and the deep features come from coding layers 17 to 24. The original illumination multi-scale semantic features and the enhanced illumination multi-scale semantic features are subjected to feature standardization based on mean and variance, respectively. The number of channels at each scale is unified to the same dimension through a one-dimensional fully connected mapping, and the output is a multi-scale semantic feature group.
[0042] A projection head is connected in series after the multi-scale semantic features. The projection head consists of two fully connected mapping layers and an intermediate ReLU activation. The first layer receives the multi-scale semantic feature group and outputs the intermediate mapping vector. The second layer maps the intermediate mapping vector into a fixed-dimensional vector to obtain the projection feature vector in a unified embedding space. The projection head applies the original illumination branch and the enhanced illumination branch independently.
[0043] A semantic distillation module is set up; the teacher distillation head receives the shallow, medium, and deep features of the original illumination branch, and outputs the teacher distillation feature vector through the feature alignment layer and compression layer in sequence; the student distillation head receives the shallow, medium, and deep features of the enhanced illumination branch, and outputs the student distillation feature vector through the feature alignment layer, nonlinear transformation layer, and compression layer in sequence; the teacher distillation feature vector and the student distillation feature vector are sent to the distillation loss calculation unit to generate a distillation supervision signal, which is used to constrain the enhanced illumination branch.
[0044] Contrastive learning constraints are constructed using projected feature vectors; projected feature vectors obtained from cargo instances in the same yard in the original illumination branch and the enhanced illumination branch are paired as consistent feature pairs, and projected feature vectors obtained from cargo instances in different yards are paired as heterogeneous feature pairs; contrastive loss is calculated based on consistent feature pairs and heterogeneous feature pairs in a unified embedding space, and the contrastive loss and distillation supervision signal are used together to calculate the total loss during the training phase.
[0045] Example 1: To verify the feasibility of this invention in practice, it was applied to the intelligent monitoring system of a large logistics company's yard. This yard is characterized by its large scale, strong occlusion, and drastic changes in lighting. Traditional recognition schemes based on detection models such as Faster R-CNN and YOLOv5 often suffer from misidentification and missed identification in scenarios with insufficient lighting at night, reflective surfaces of goods, or overlapping stacks, making it difficult to meet the dual requirements of real-time performance and accuracy for actual deployment.
[0046] In the experimental deployment, fixed high-definition cameras were first deployed in key areas of the yard, supplemented by mobile image acquisition terminals, to continuously collect image sequences of goods during yard operations. During the data preprocessing stage, the image sequences underwent timestamp alignment, sequence number calibration, intrinsic parameter calibration, geometric distortion correction, white balance and illumination equalization processing, image denoising, and local contrast enhancement to ensure consistent quality standards for the input images under different lighting and angle conditions. Subsequently, a training phase was performed based on the image enhancement mechanism and improved DINOv2 model of this invention. This included a dual-pathway structure with original and enhanced illumination branches, a knowledge transfer mechanism between the teacher and student distillation heads, and a consistency feature guidance module under contrastive learning, forming a detection model with strong generalization ability and illumination robustness.
[0047] For training data, a total of 18,360 images of yard cargo were manually labeled, covering 8 typical types of yard cargo. The number of cargo in each type was reasonably distributed, and the images exhibited multi-angle, multi-lighting, and multi-scale features. The AdamW optimizer was used during training, with an initial learning rate of 0.0002, a batch size of 32, a distillation loss weight of 0.5, a contrastive loss weight of 0.3, and 50 training epochs. During the testing phase, only the original lighting branch and the yard cargo detection head were retained. After inputting the test image, the output was the class probability vector and bounding box coordinate parameters. The final results were filtered based on a confidence threshold (0.4) and non-maximum suppression (IoU threshold 0.5). Specific data are shown in Table 1. Table 1. Performance Comparison Data of the Improved DINOv2 Model in Yard Cargo Inspection Scenarios
[0048] As shown in Table 1, the comparative experiment selected YOLOv5, DeformableDETR, and the original DINOv2 model as the baseline, and evaluated various indicators on the standard test set and the low-light test set, respectively. The results show that the present invention achieves 92.1% mAP@0.5 in the standard scene and maintains an mAP level of 89.7% in the low-light scene, significantly better than YOLOv5 (82.3%) and the original DINOv2 (86.2%). The model of the present invention has a recall index as high as 91.5% in occluded scenes, significantly improving the ability to identify overlapping goods in the yard and effectively supporting the stable operation requirements of enterprises in nighttime operations and automatic counting.
[0049] In summary, by introducing an improved DINOv2 structure and an illumination enhancement mechanism, this invention effectively solves the problems of complex yard environments and insufficient robustness of traditional models, and has significant accuracy advantages and practical deployment value.
Claims
1. A method for automatic identification of cargo in a storage yard based on computer vision, characterized in that, Includes the following steps: Step 1: Acquire a sequence of images of cargo in the yard, perform preprocessing on the cargo image sequence, and obtain cargo images of the yard; Step 2: Input the original samples into the original illumination branch of the improved DINOv2 model, input the low-light enhanced samples into the enhanced illumination branch, and extract multi-scale semantic features; Step 3: Set up the projection head to map multi-scale semantic features to a unified-dimensional embedding space, generating projected feature vectors; Step 4: Set up the distillation head, using the original illumination multi-scale semantic features output by the original illumination branch as teacher features, and the enhanced illumination multi-scale semantic features output by the enhanced illumination branch as student features, perform semantic distillation, and generate distilled feature vectors. Step 5: Input the multi-scale semantic features into the yard cargo detection head, output the cargo category label and bounding box coordinates, calculate the classification loss and regression loss, and calculate the contrast loss by combining the projected feature vectors; Step 6: Output the corresponding yard cargo category label and bounding box coordinates.
2. The automatic identification method for yard cargo based on computer vision according to claim 1, characterized in that, The acquired sequence of cargo images from the storage yard undergoes preprocessing, specifically: Image acquisition equipment is installed in the yard operation area. The image acquisition equipment includes fixed camera equipment and mobile image acquisition terminals. Perform image timestamp synchronization and image sequence number calibration operations on the acquired stockpile cargo image sequence to generate stockpile cargo image frames arranged in chronological order; Perform camera intrinsic parameter calibration and geometric distortion correction operations on the image frames of cargo in the yard to complete the image correction of radial and tangential distortion; The corrected image frames are processed by illumination equalization, white balance correction and color normalization to generate a balanced image frame of the yard cargo. Pixel denoising and local contrast enhancement are performed on the image frames of cargo in the yard to suppress image noise and interference from blurred areas. Based on the reference points of the yard ground area, perform image scale calibration to establish the mapping relationship between image pixel coordinates and actual physical dimensions, and output the image of the yard cargo.
3. The automatic identification method for yard cargo based on computer vision according to claim 1, characterized in that, The original samples are input into the original illumination branch of the improved DINOv2 model, and the low-light enhanced samples are input into the enhanced illumination branch to extract multi-scale semantic features, specifically: From the images of cargo in the yard, select image frames whose clarity meets the preset threshold and which completely cover the cargo area as the original samples; Perform size resampling and pixel normalization on the original sample; Based on image enhancement strategies, corresponding low-light enhanced samples are generated from the original samples; The original samples are input into the original illumination branch of the improved DINOv2 model to perform multi-scale feature extraction and output the original illumination multi-scale semantic features. The low-light enhancement samples are input into the enhanced lighting branch of the improved DINOv2 model to perform multi-scale feature extraction and output enhanced lighting multi-scale semantic features. Feature standardization and channel alignment are performed on the original illumination multi-scale semantic features and the enhanced illumination multi-scale semantic features respectively to obtain multi-scale semantic features.
4. The automatic identification method for yard cargo based on computer vision according to claim 1, characterized in that, The setting of the projection head maps multi-scale semantic features to a unified-dimensional embedding space, specifically as follows: Multi-scale semantic features are input into a two-layer fully connected mapping structure of the projection head; The first fully connected mapping structure receives the input multi-scale semantic feature set and outputs an intermediate mapping vector, on which the ReLU activation function is applied. The second fully connected mapping structure receives intermediate mapping vectors and outputs fixed-dimensional projection vectors, forming projection feature vectors in a unified embedding space.
5. The automatic identification method for yard cargo based on computer vision according to claim 1, characterized in that, The semantic distillation process, which generates a distillation feature vector, specifically involves: The original multi-scale semantic features of illumination are input into the teacher's distillation head in the order of shallow features, medium features, and deep features; The enhanced illumination multi-scale semantic features are input into the student distillation head in the order of shallow features, medium features, and deep features; The distillation head includes a feature alignment layer, a nonlinear transformation layer, and a compression layer connected in sequence. The feature alignment layer is a fully connected mapping layer used to map the input multi-scale semantic features to a unified dimension of the distillation space; The nonlinear transformation layer performs nonlinear transformations on student features; The compression layer is a fully connected mapping layer used to output a distillation feature vector of fixed dimensions; The teacher's distillation feature vector and the student's distillation feature vector are input into the distillation loss calculation unit at the output end; The distillation loss calculation unit performs a difference measurement on the teacher's distillation feature vector and the student's distillation feature vector based on Euclidean distance and cosine similarity, and generates a distillation loss value.
6. The automatic identification method for yard cargo based on computer vision according to claim 1, characterized in that, The process of inputting multi-scale semantic features into the yard cargo detection head and outputting cargo category labels and bounding box coordinates is as follows: Multi-scale semantic features are input into the classification branch and bounding box regression branch of the yard cargo detection head according to the scale; The classification branch outputs the class probability vectors at each scale. The bounding box regression branch outputs the bounding box coordinate parameters at various scales; The category probability vector is combined with the bounding box coordinate parameters to form the output result of the yard cargo detection head. The output result includes the yard cargo category label and the corresponding bounding box coordinates.
7. The automatic identification method for yard cargo based on computer vision according to claim 1, characterized in that, The calculation of classification loss and regression loss is specifically as follows: The images of cargo in the yard are filtered and manually labeled to generate training sample images containing category labels and the actual location bounding boxes of cargo in the yard. Calculate the intersection-union ratio (IUR) between the predicted bounding box and the labeled bounding box. When the IUR is greater than or equal to a preset threshold, establish a matching relationship between the predicted bounding box and the corresponding labeled bounding box and mark it as a positive sample. The positive sample inherits the yard cargo category label and bounding box coordinate information of the corresponding labeled bounding box to form a positive sample training label. When the crossover ratio is less than a preset threshold, the predicted bounding box is marked as a negative sample, and the negative sample is marked as the background category, thus forming negative sample training labels; The positive and negative training labels are mapped to the feature layers of each scale according to the scale position of the prediction box, generating a multi-scale training label set. The labeled box is the preset true location box of the cargo in the storage yard in the training sample image, and the predicted box is the bounding box coordinates output by the storage yard cargo detection head; The classification loss is calculated based on the class probability vectors output by the classification branch at each scale feature layer and the class labels in the corresponding multi-scale training label set; The regression loss is calculated based on the bounding box coordinate parameters output by the bounding box regression branch at each scale feature layer and the bounding box coordinate information in the corresponding multi-scale training label set.
8. The automatic identification method for yard cargo based on computer vision according to claim 1, characterized in that, The calculation of the contrast loss by combining the projected feature vectors is specifically as follows: Pair the projected feature vectors output from the original illumination branch and the enhanced illumination branch of the same pile of goods image sequence to construct consistent feature pairs; The projected feature vectors of cargo image sequences from different storage yards are paired to construct heterogeneous feature pairs; The similarity between consistent feature pairs and dissimilar feature pairs is calculated in a unified embedding space. Attraction constraints are applied to consistent feature pairs and separation constraints are applied to dissimilar feature pairs to obtain the contrastive loss. The distillation loss value is linearly combined with the classification loss, regression loss, and contrast loss according to preset weights to form the total training loss.
9. The automatic identification method for yard cargo based on computer vision according to claim 1, characterized in that, The output corresponding yard cargo category label and bounding box coordinates are as follows: Set the optimizer, learning rate, and loss weight coefficients; initialize the parameters of the enhanced lighting branch, projection head, student distillation head, and yard cargo detection head. Perform gradient backpropagation to minimize the total training loss function, and iteratively update the parameters of the enhanced lighting branch, projection head, student distillation head, and yard cargo detection head, while keeping the parameters of the original lighting branch and teacher distillation head unchanged. Repeat the gradient backpropagation and iterative update process until the preset number of training rounds or the total training loss meets the convergence condition, complete the end-to-end optimization, and obtain the improved DINOv2 model after training. During the inference phase, the images of the yard cargo are input into the original lighting branch and the yard cargo detection head of the trained improved DINOv2 model, and the output is a set of prediction boxes, each of which contains a class probability vector and bounding box coordinate parameters. Take the maximum component of the category probability vector of each prediction box as the confidence score and record the corresponding yard cargo category label; Threshold filtering is performed on the predicted boxes based on a preset confidence threshold to obtain a set of predicted boxes with a confidence score not lower than the preset confidence threshold; The predicted bounding boxes with confidence scores not lower than a preset confidence threshold are grouped by category, and then sorted from high to low within each category group according to their confidence scores. Non-maximum suppression is performed within each category group: the prediction box with the highest current confidence score is selected as the retained prediction box, the intersection-union ratio (IU) of the retained prediction box and the other prediction boxes is calculated, and prediction boxes with IU ratios not lower than the preset IU threshold are deleted until the category groups are traversed, and the set of retained prediction boxes is output. Image boundary cropping and minimum size threshold filtering are performed on the bounding box coordinates of the retained predicted box set; the retained predicted boxes after non-maximum suppression and threshold filtering are used as the final detection results, and the corresponding yard cargo category labels and bounding box coordinates are output.