Method for establishing rotating target detection model applied to detecting upper and lower bed edges of baby crib
By constructing and optimizing the rotating target detection model, the problems of insufficient specialization and poor adaptability in crib edge detection were solved, achieving more accurate and robust crib edge detection and enhancing the model's detection capabilities in different scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU DIANZI UNIV
- Filing Date
- 2026-01-28
- Publication Date
- 2026-05-01
AI Technical Summary
Existing computer vision algorithms suffer from insufficient specialization, poor adaptability, and a lack of high-quality labeled datasets in detecting the edge of cribs, resulting in poor detection performance.
We construct a training dataset and perform data augmentation. We employ methods such as feature extraction and fusion, output prediction, loss calculation, and model optimization. We optimize the rotating target detection model using modulation focus loss function and modulation rotation loss function. We perform feature extraction and prediction through backbone network and detection head to solve the boundary discontinuity problem of eight-parameter regression.
It enables more accurate detection of the crib edge, enhances the robustness and practicality of the model in different scenarios, and improves detection accuracy and generalization ability.
Smart Images

Figure CN121960187A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision and target detection technology, specifically relating to a method for establishing a rotating target detection model for detecting the upper and lower edges of a baby crib. Background Technology
[0002] With the development of digital image processing technology and the improvement of computing power, computer vision technologies such as image processing, facial recognition, object detection, and object tracking have penetrated into people's daily lives. In families with infants, infant safety is a major concern for parents. As infants develop physical abilities, especially after they learn to stand, although crib safety rails can prevent accidental falls to some extent, they cannot completely eliminate the safety hazard of infants climbing over the rails and falling out. Therefore, accurate object detection along the top and bottom edges of the crib is particularly necessary. Traditional horizontal bounding box object detection has significant limitations in this area, thus necessitating the modification of existing network models to use rotational object detection for crib edge detection.
[0003] Currently, there are many methods for rotating object detection. Popular object representations for arbitrary directions include oriented bounding boxes, quadrilateral bounding boxes, and point sets. The crib edge in the video is an irregular quadrilateral, therefore, a quadrilateral bounding box-based rotating object detection algorithm is more suitable than a rotated rectangle. Quadrilaterals provide more accurate localization than rotated rectangles, better fit the object's shape, and significantly alleviate boundary issues. After analysis, eight parameters—position coordinates (x1, y1), (x2, y2), (x3, y3), and (x4, y4)—will be obtained through regression to characterize the crib edge.
[0004] Existing computer vision algorithms suffer from poor domain adaptability in bed edge detection tasks, lacking a detection model architecture specifically for bed edges. At the same time, the scarcity of labeled data in this field is a bottleneck, which restricts the application of related technologies in real-world scenarios. Summary of the Invention
[0005] In view of the above-mentioned problems, the present invention provides a method for establishing a rotating target detection model for detecting the upper and lower edges of a baby crib, which addresses the problems of insufficient specialization, poor adaptability, and lack of high-quality labeled datasets in existing target detection algorithms for crib edge detection tasks.
[0006] To solve the above-mentioned technical problems, the present invention adopts the following technical solution: A method for establishing a rotating target detection model for detecting the upper and lower edges of a baby crib includes the following steps: S10, Construct a training dataset: Collect images of cribs and label the coordinates of the four vertices of the upper and lower edges of the crib; perform data augmentation on the images, including: randomly adding objects or people to obscure the crib railing area, randomly grayscale the images to simulate infrared scenes, randomly adjusting the brightness, contrast and saturation of the images to simulate different lighting conditions, randomly cropping the image area based on the target size ratio and filling the boundaries with constant values, and finally scaling the images to a preset resolution. S20, Feature Extraction and Fusion: Obtaining Multi-Scale Feature Maps of the Image. The input image is fed into a configurable backbone network to extract multi-scale feature maps. The multi-scale feature maps are then fused through a feature pyramid network to obtain fused features rich in semantic and detail information. S30, Obtain prediction output: Input the fused features into the detection head, which includes a classification branch and a regression branch; S40, Processing Real Data: For each pixel on each output feature map, the model calculates its absolute coordinates on the original input image, takes the pixels that meet the conditions as the center reference point of the real box, calculates the offset of the four vertices of the real box relative to the center reference point as the real regression offset, and sends the predicted class score of the current class, the calculated position information and the real label corresponding to the class into the loss calculation module. S50, calculate various losses: use the modulation focus loss function to calculate the classification loss between the true category label and the predicted category score of the current category; use the modulation rotation loss function to calculate the regression loss between the true quadrilateral and the predicted quadrilateral of the current category; the modulation rotation loss function calculates the L1 loss of the predicted vertex under three different sortings and takes the minimum value to solve the boundary discontinuity problem of eight-parameter regression, and sums the classification loss and regression loss of all categories to obtain the total classification loss and the total regression loss. S60, Model Optimization and Evaluation: The total classification loss and total regression loss are merged into a total loss. The gradient is calculated through backpropagation, and the network weights are updated using the optimizer to minimize the loss. At the same time, the learning rate is dynamically adjusted according to the preset strategy. During the training process, model checkpoints are saved periodically, and the model performance is evaluated on the validation set to monitor its generalization ability. Finally, through iterative optimization, the model gradually learns the ability to accurately identify the bed edge and regress the quadrilateral vertices.
[0007] In one possible implementation, the classification branch in S30 outputs the classification score for each category corresponding to each spatial location through a 3x3 convolution.
[0008] In one possible implementation, the regression branch in S30 outputs eight parameters for each category independently through a 3x3 convolution, representing the offset of the four corner points relative to the center reference point of that location.
[0009] In one possible implementation, the modulation focus loss function in S50 is: ; Let be the predicted probability of the i-th sample; Let be the true label of the i-th sample, where 0 represents a negative sample and 1 represents a positive sample; , is the numerical stability constant; For global weight terms: ; Difficulty modulation factor: ; For dynamically adjusted items: ; Cross-entropy loss: .
[0010] In one possible implementation, the modulation rotation loss function in S50 is:
[0011] The loss consists of three parts: the first part is shifting the four vertices of the prediction box one position clockwise; the second part is keeping the order of the vertices of the prediction box unchanged; and the third part is shifting the four vertices of the prediction box one position counterclockwise. The minimum value among the above three cases is taken as the value of the modulation rotation loss function.
[0012] The present invention has the following beneficial effects: (1) The rotating target detection model designed for detecting the upper and lower edges of the crib adopts an arbitrary quadrilateral detection frame that is more suitable for the crib edge. It fits the irregular shape of the crib edge better than the traditional rectangular frame, and the positioning is more accurate.
[0013] (2) The modulation focus loss function designed is more in line with the real situation. By setting the parameters more flexibly, it can effectively enhance the model's detection of the crib in the picture and reduce false detections.
[0014] (3) The data augmentation strategy created uses targeted data augmentation methods such as occlusion, infrared and variable lighting in simulated real crib scenarios to construct a dataset with arbitrary quadrilateral detection boxes labeled, making the model more robust to different scenarios and more widely applicable. Attached Figure Description
[0015] Figure 1This is a flowchart illustrating the steps of a method for establishing a rotating target detection model for detecting the upper and lower edges of an infant's crib, according to an embodiment of the present invention. Figure 2 This is a block diagram illustrating the principle of a rotating target detection model in a specific application embodiment. Figure 3 This is a schematic diagram of category labels in a specific application example. Detailed Implementation
[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0017] See Figure 1 The diagram shows a flowchart of a method for establishing a rotating target detection model for detecting the upper and lower edges of an infant's crib, according to an embodiment of the present invention. The method includes the following steps: S10, Construct a training dataset: Collect images of cribs and label the coordinates of the four vertices of the upper and lower edges of the crib; perform data augmentation on the images, including: randomly adding objects or people to obscure the crib railing area, randomly grayscale the images to simulate infrared scenes, randomly adjusting the brightness, contrast and saturation of the images to simulate different lighting conditions, randomly cropping the image area based on the target size ratio and filling the boundaries with constant values, and finally scaling the images to a preset resolution. S20, Feature Extraction and Fusion: Obtaining Multi-Scale Feature Maps of the Image. The input image is fed into a configurable backbone network, such as... Figure 2 C2 to C5 represent feature maps of the backbone network. Multi-scale feature maps are then extracted and fused using a feature pyramid network to obtain fused features rich in semantic and detailed information, such as... Figure 2 F2 to F6 in the model are the feature levels used in the final prediction. S30, Obtain prediction output: Input the fused features into the detection head, which includes a classification branch and a regression branch; S40, Processing Real Data: For each pixel on each output feature map, the model calculates its absolute coordinates on the original input image, takes the pixels that meet the conditions as the center reference point of the real box, calculates the offset of the four vertices of the real box relative to the center reference point as the real regression offset, and sends the predicted class score of the current class, the calculated position information and the real label corresponding to the class into the loss calculation module. S50, calculate various losses: use the modulation focus loss function to calculate the classification loss between the true category label and the predicted category score of the current category; use the modulation rotation loss function to calculate the regression loss between the true quadrilateral and the predicted quadrilateral of the current category; the modulation rotation loss function calculates the L1 loss of the predicted vertex under three different sortings and takes the minimum value to solve the boundary discontinuity problem of eight-parameter regression, and sums the classification loss and regression loss of all categories to obtain the total classification loss and the total regression loss.
[0018] S60, Model Optimization and Evaluation: The total classification loss and total regression loss are merged into a total loss. The gradient is calculated through backpropagation, and the network weights are updated using the optimizer to minimize the loss. At the same time, the learning rate is dynamically adjusted according to the preset strategy. During the training process, model checkpoints are saved periodically, and the model performance is evaluated on the validation set to monitor its generalization ability. Finally, through iterative optimization, the model gradually learns the ability to accurately identify the bed edge and regress the quadrilateral vertices.
[0019] In a specific application example, the classification branch in S30 outputs the classification score for each category corresponding to each spatial location through a 3x3 convolution; the regression branch outputs 8 parameters independently for each category through a 3x3 convolution, representing the offset of the four corner points relative to the center reference point of that location.
[0020] In a specific application example, the modulation focus loss function in S50 is: ; Let be the predicted probability of the i-th sample; Let be the true label of the i-th sample, where 0 represents a negative sample and 1 represents a positive sample; , is the numerical stability constant; For global weight terms: ; Difficulty modulation factor: ; For dynamically adjusted items: ; Cross-entropy loss: .
[0021] The modulation rotation loss function is:
[0022] The loss consists of three parts: the first part is shifting the four vertices of the prediction box one position clockwise; the second part is keeping the order of the vertices of the prediction box unchanged; and the third part is shifting the four vertices of the prediction box one position counterclockwise. The minimum value among the above three cases is taken as the value of the modulation rotation loss function.
[0023] Specifically, combining S20 and S30, such as Figure 2 As shown, the rotating object detection model consists of three parts: a backbone network, a feature pyramid network, and a detection head. The backbone network is used to extract features of the crib, including various types of information such as shape, texture, and edges. First, a pre-trained backbone network (such as ResNet or MobileNetV2) is used to extract features from the crib in the image, outputting a feature pyramid, which typically contains feature maps at four different scales. The feature pyramid structure is used to fuse the feature maps output by the backbone network, which increases the semantic and detail information of the feature maps at each scale. The feature maps that need to be selected are fed into the detection head, which consists of two independent small convolutional networks: a classification branch and a regression branch. The feature map output by the classification branch is passed through four 3x3 convolutions, and its output channel number is equal to the number of categories. In this way, at each pixel position of the feature map, a vector is output, representing the "raw score" of each category of object present at that position. The feature map output by the regression branch is passed through four 3x3 convolutions, and its output channel number is 8 * the number of categories. Here, 8 corresponds to the 8 offset values of the 4 corner points of a quadrilateral bounding box relative to the "center" reference point. The model independently predicts a set of 8 coordinate values for each category.
[0024] For each category, the classification score and regression coordinates belonging to that category are sliced from the overall prediction results. The model calculates the absolute coordinates of each pixel in the original input image for each output feature map (f8, f16, ...). For example, for the F4 feature map with a stride of 16, its position (i, j) corresponds to the center coordinates of ((j+0.5)*8, (i+0.5)*8) in the original image. This positional information will serve as the "center" reference point for each predicted point, such as... Figure 3 As shown by the red dot in the image. Subsequent bounding box regression predictions are all based on offsets relative to reference points. Before calculating the loss, we need to obtain the ground truth data. First, we need to create classification labels. Based on the relationship between the ground truth bounding box and the points on the feature map, we assign a category label to each point in the central region within the ground truth bounding box. Pixels within the ground truth bounding box whose maximum relative offset from the four vertices of the bounding box is within the range of interest at the corresponding level are designated as the "center" reference point, such as... Figure 2 The blue location points are shown in the image. The four points of the ground truth bounding box are sorted in a certain order, and then the offset of the ground truth bounding box from the reference point is calculated as the true regression offset, such as... Figure 3Subtracting point (xs, ys) from points (x1, y1), (x2, y2), (x3, y3), and (x4, y4) yields eight offsets. The predicted results and the processed real data are then fed into the loss calculation module.
[0025] Since the model predicts independent classification and regression results for each category, iterative processing by category is required when calculating the loss. Modulation focus loss is used as the classification loss, calculating the difference between the predicted classification score and the true label to distinguish whether a location point is a "target" or "background". Modulation rotation loss is used as the regression loss. For the "target" center reference point labeled as a positive sample, the reference point is first added to its eight predicted coordinate offsets and eight true coordinate offsets to obtain eight predicted coordinate values and eight true coordinate values for the bed board. Then, the modulation rotation loss is used to calculate the difference between the eight predicted coordinate values and eight true coordinate values. To address the discontinuity in loss caused by the arbitrary order of quadrilateral vertices, this modulation rotation loss function calculates the L1 loss for the predicted vertices in the original order, one position clockwise, and one position counterclockwise, and takes the minimum value to ensure the continuity of loss calculation, thereby stabilizing the training process and improving localization accuracy. The classification loss and regression loss for all categories are summed separately to obtain the total classification loss and total regression loss.
[0026] After calculating the loss values for the original classification and regression outputs, the two are first merged into a total loss according to preset weights. Then, the gradients of the model parameters are calculated through backpropagation, and the optimizer is used to update the network weights based on these gradients to minimize the loss. At the same time, the learning rate is dynamically adjusted and the training status is monitored. During this process, model checkpoints are saved periodically and the performance is evaluated on the validation set. Finally, through this iterative optimization, the model gradually learns the ability to accurately predict the categories of the crib's upper and lower edges and to frame the quadrilateral crib edges.
[0027] It should be understood that the exemplary embodiments described herein are illustrative and not restrictive. Although one or more embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art will understand that various changes in form and detail may be made without departing from the spirit and scope of the invention as defined by the appended claims.
Claims
1. A method for establishing a rotating target detection model for detecting the edges of an infant's crib, characterized in that, Includes the following steps: S10, Construct the training dataset: Collect images of cribs and label the coordinates of the four vertices of the upper and lower edges of the crib; Data augmentation of the image includes: randomly adding objects or people to obscure the crib railing area, randomly converting the image to grayscale to simulate an infrared scene, randomly adjusting the brightness, contrast and saturation of the image to simulate different lighting conditions, randomly cropping the image area based on the target size ratio and filling the boundary with a constant value, and finally scaling the image to a preset resolution. S20, Feature Extraction and Fusion: Obtaining Multi-Scale Feature Maps of the Image. The input image is fed into a configurable backbone network to extract multi-scale feature maps. The multi-scale feature maps are then fused through a feature pyramid network to obtain fused features rich in semantic and detail information. S30, Obtain prediction output: Input the fused features into the detection head, which includes a classification branch and a regression branch; S40, Processing Real Data: For each pixel on each output feature map, the model calculates its absolute coordinates on the original input image, takes the pixels that meet the conditions as the center reference point of the real box, calculates the offset of the four vertices of the real box relative to the center reference point as the real regression offset, and sends the predicted class score of the current class, the calculated position information and the real label corresponding to the class into the loss calculation module. S50, calculate various losses: use the modulation focus loss function to calculate the classification loss between the true category label and the predicted category score of the current category; use the modulation rotation loss function to calculate the regression loss between the true quadrilateral and the predicted quadrilateral of the current category; the modulation rotation loss function calculates the L1 loss of the predicted vertex under three different sortings and takes the minimum value to solve the boundary discontinuity problem of eight-parameter regression, and sums the classification loss and regression loss of all categories to obtain the total classification loss and the total regression loss. S60, Model Optimization and Evaluation: The total classification loss and total regression loss are merged into a total loss. The gradient is calculated through backpropagation, and the network weights are updated using the optimizer to minimize the loss. At the same time, the learning rate is dynamically adjusted according to the preset strategy. During the training process, model checkpoints are saved periodically, and the model performance is evaluated on the validation set to monitor its generalization ability. Finally, through iterative optimization, the model gradually learns the ability to accurately identify the bed edge and regress the quadrilateral vertices.
2. The method for establishing a rotating target detection model for detecting the upper and lower edges of an infant crib as described in claim 1, characterized in that, The classification branch described in S30 outputs the classification score for each category corresponding to each spatial location through a 3x3 convolution.
3. The method for establishing a rotating target detection model for detecting the upper and lower edges of an infant's crib, as described in claim 1, is characterized in that... The regression branch described in S30 outputs 8 parameters independently for each category through a 3x3 convolution, representing the offset of the four corner points relative to the center reference point at that location.
4. The method for establishing a rotating target detection model for detecting the edges of an infant's crib as described in claim 1, characterized in that, The modulation focus loss function in S50 is: ; Let be the predicted probability of the i-th sample; Let be the true label of the i-th sample, where 0 represents a negative sample and 1 represents a positive sample; , is the numerical stability constant; For global weight terms: ; Difficulty modulation factor: ; For dynamically adjusted items: ; Cross-entropy loss: 。 5. The method for establishing a rotating target detection model for detecting the edges of an infant's crib as described in claim 1, characterized in that, The modulation rotation loss function in S50 is: ; The loss consists of three parts: the first part is shifting the four vertices of the prediction box one position clockwise; the second part is keeping the order of the vertices of the prediction box unchanged; and the third part is shifting the four vertices of the prediction box one position counterclockwise. The minimum value among the above three cases is taken as the value of the modulation rotation loss function.