Single-stage live pig body size information rapid detection method based on key point regression

By adding a key point linear regression model to the YOLOv8-Pose model and deploying it to the edge computing device, the problems of high labor intensity, low accuracy and high computing resource consumption of traditional pig body ruler information detection methods are solved, and pig body ruler information is realized Fast, accurate and real-time detection.

CN119131834APending Publication Date: 2024-12-13FUZHOU NONGFUTENG INFORMATION TECH CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411088421.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

The traditional pig body ruler information detection method has high labor intensity and is prone to cause pig stress response. The detection accuracy decreases when the ambient light changes or the skin is stained. The two-stage detection algorithm consumes a lot of computing resources and the single-stage detection accuracy is low.

Method used

Using a single-stage pig pose classification and body ruler detection model based on YOLOv8-Pose, the key point detection accuracy is improved by adding a key point linear regression model, and the model is deployed to edge computing devices. The depth camera is used to predict key points on the pig's back in real time. Pixel coordinates, converted to world coordinates to obtain body rule information.

Benefits of technology

It realizes fast, accurate and real-time detection of pig body ruler information, reduces the demand for computing resources, is suitable for edge computing environments, and improves detection accuracy and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119131834A_ABST
    Figure CN119131834A_ABST
Patent Text Reader

Abstract

The invention discloses a single-stage live pig body size information rapid detection method based on key point regression, and relates to the technical field of animal husbandry facilities. The method comprises the following steps: (1) data acquisition (S1); (2) making a data set (S2); (3) creating a configuration file of the data set (S3); (4) adding a key point regression model (S4); (5) training the YOLOv8-Pose model (S5); (6) performing model evaluation (S6); (7) deploying the model (S7); (8) image registration (S8); and (9) coordinate transformation (S9). According to the method, the prediction precision of a YOLOv8-Pose algorithm on the positions of the live pig back key points is improved by adding a key point linear regression algorithm, RGB images are inferred in real time through a key point detection model, key point pixel coordinates are obtained, depth values corresponding to the pixel coordinates are obtained through image registration, the pixel coordinates are converted into world coordinates based on the imaging principle, and the real-time prediction precision of the positions of the live pig back key points is improved. And finally calculating to obtain live pig body size information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of animal husbandry facilities, and in particular to a single-stage rapid detection method for pig body size information based on key point regression. Background Art

[0002] Pork is the most widely consumed meat in the world. Improving the quality of pigs and increasing meat production are crucial to promoting the development of the pig industry. Studies have shown that by performing parameter analysis on pig body size information, the body condition of pigs can be effectively predicted and their feeding status can be deeply understood. By precisely controlling the feed ratio and dosage, the feed conversion rate can be improved, and the economic benefits of the farm can be significantly improved. In addition, the pig body size information trait has genetic characteristics. By monitoring the pig body size information and selecting breeding pigs with high-quality genes, it will help promote the further development of the breeding pig industry. The traditional pig body size information detection method is not only labor-intensive but also causes stress reactions in pigs, which not only affects the normal feed intake of pigs, but may also cause the death of pigs in severe cases. Therefore, it is particularly important to develop a rapid and non-destructive detection method for pig body size information parameters.

[0003] In past studies, the detection of pig body size information mainly used traditional image processing methods: through the removal algorithm of the pig's head and tail based on envelope analysis, the pig's body with a bent posture was removed, and the intersection points of the envelope line and the pig's body were extracted as key points. And the skeletonization algorithm combined with the Hough transform algorithm was used to detect whether the pig's head was crooked, so as to select the ideal posture of the pig's back image for body size measurement. However, in the above studies, traditional image recognition technology was used to identify the coordinates of the key points on the pig's back. Although the accuracy is relatively high, these methods are only applicable to the extraction of pig key points in a single scene. When the ambient light changes or the pig's skin is affected by dirt, the detection accuracy may drop significantly.

[0004] In existing research, the method for detecting the body size information of live pigs mainly uses deep learning technology to predict the position of key points. For example, the YOLOv5 target detection model is first used to identify the pig's posture, and then the HRST key point prediction model based on the heat map is used to predict the position coordinates of the key points of the pig's body to achieve the body size measurement of the live pig. In the algorithm for detecting the body size information of live pigs based on deep learning, two models are usually used, namely a classification model and a key point detection model. Although the two-stage body size detection method improves the detection accuracy, it has a large demand for computing resources and it is difficult to effectively deploy the algorithm to the edge computing device. The single-stage HRST key point prediction model based on the heat map ignores the linear relationship between the key points, resulting in the detection accuracy cannot be further improved. Therefore, the present invention proposes a single-stage method for rapid detection of live pig body size information based on key point regression. Summary of the invention

[0005] The purpose of the present invention is to overcome the problem that the two-stage detection algorithm cannot detect in real time and the single-stage key point detection algorithm has low accuracy, and to provide a single-stage pig body size information rapid detection method based on key point regression.

[0006] The object of the present invention is achieved in that:

[0007] The collected pig back image data is used to train a pig posture classification and body size detection model based on YOLOv8-Pose. The key point detection accuracy is improved by adding a key point linear regression model, and the model is deployed to the edge computing device. The RGB image of the pig back collected by the inference depth camera is then used to predict the pixel coordinates of the key points on the pig back in real time. The world coordinates of the key points are obtained according to the depth image to obtain the pig body size information, and finally the automatic detection of the pig body size information is realized.

[0008] Specifically, the steps are as follows:

[0009] ① Data collection: Build a pig limiting fence device, with an RBG camera installed on the top of the device. When the pig completely enters the limiting fence device, collect the unobstructed RGB image of the pig's back;

[0010] ② Dataset creation: The collected pig back images are divided into natural standing posture and unnatural standing posture. The labeling software labelme is used to annotate the key point positions and postures of the pig back;

[0011] ③ Create a configuration file for the data set: Write the pig's standing posture and key point information into the configuration file as the basic condition for simultaneously training the model for key point detection and target classification;

[0012] ④Add key point regression model: Increase the accuracy of key point prediction by performing linear regression on the key point coordinates extracted by the feature extraction network;

[0013] ⑤YOLOv8-Pose model training: Use the prepared data set to train the improved YOLOv8-Pose model to obtain a real-time detection model with high accuracy in pig posture classification and key point detection;

[0014] ⑥Model evaluation: Use the model to infer the test set images, and calculate the Euclidean distance error between the predicted key point coordinates on the test set and the real key point coordinates on the test set to evaluate the model accuracy;

[0015] ⑦Model deployment: Deploy the model to the Jetson Orin NX development board to achieve real-time inference of the model on the embedded device;

[0016] ⑧ Image registration: The depth image is registered with the RGB image, and the hip height, shoulder height and body height of the pig are obtained by comparing the detected key point pixels with the depth values ​​of the corresponding pixel coordinates in the depth image;

[0017] ⑨Coordinate conversion: According to the imaging principle, the pixel coordinates are converted into world coordinates, and the pig's body length, hip width and shoulder width data are obtained by calculating the distance between two points of the world coordinates.

[0018] The step ④ is:

[0019] After the image passes through the backbone feature extraction network and the feature fusion layer, the position coordinates of the key points extracted according to the image features will be obtained. The obtained key point coordinates will be input into the MLP model, and linear regression operations will be performed on each key point to learn the linear relationship between the key points and improve the model accuracy. By introducing the nonlinear activation function SiLU activation function and multi-level regression operations in the MLP model, the neural network can more flexibly learn to model complex nonlinear relationships, adapt to information of different scales, and realize end-to-end training, which helps to effectively capture and represent the key point positions of the target, thereby improving the accuracy of accurate prediction of the key point positions.

[0020] The step ⑥ is:

[0021] Use the trained single-stage pig key point prediction model based on key point regression to infer the pictures in the test set, obtain the key point prediction label file in text format, and save the name of the picture as the corresponding label name; use the python program to read the predicted key point coordinates and the real key point coordinates of each picture at the same time, and calculate the Euclidean distance error of the key point. The smaller the error, the higher the accuracy of the model. The key point Euclidean distance error calculation formula is as follows:

[0022]

[0023] L: Euclidean distance between the true point and the predicted point

[0024] (x1, y1): real point pixel coordinates (x2, y2): predicted point pixel coordinates

[0025] The step ⑦ is:

[0026] A. Install Ubuntu 20.04 system in the Jetson Orin NX development board as the underlying basic environment;

[0027] B. Install the python3.8 interpreter in the Ubuntu20.04 system, and configure torch2.0.0+nv23.05, torchvision0.15.1, python3.8.10 and Ultralytics environment in the python3.8 interpreter to ensure that the key point prediction model trained in the Windows system can infer the real-time detection image of the camera in the Ubuntu20.04 system;

[0028] C. Use the trained model to infer the RGB image detected by the depth camera in real time to obtain the pixel coordinates of the key points on the pig's back, and obtain the pixel coordinates of the center point of the pig's buttocks, shoulder, and abdomen by calculating the center coordinates of the key points of the buttocks, shoulders, and head and tail.

[0029] The step ⑧ is:

[0030] a. Use Zhang Zhengyou's calibration method to obtain the internal and external parameter matrices of the RBG camera and IR camera. This study uses a monocular structured light camera model Astra pro. The camera receives speckles reflected by objects at different distances through the IR module to obtain a depth map. (where f x Use pixels to describe the length of the focal length in the x-axis direction, f uses pixels to describe the length of the focal length in the y-axis direction, and u o With v o Represents the coordinates of the center point of the camera photosensitive plate in the pixel coordinate system) and the external parameter matrix (where R is the rotation matrix and T is the translation vector) and the conversion formula between world coordinates and pixel coordinates, the scale factor Z of the depth camera and RGB camera is obtained; the calculation formula of world coordinates and pixel coordinates is as follows:

[0031]

[0032] Z: scale factor;

[0033] X W , Y W ,Z W : world coordinates;

[0034] a. Align the pixel coordinates in the RGB image with the pixel coordinates in the IR image according to the external parameter matrix and the internal parameter matrix of the RBG camera and the IR camera, so that each pixel coordinate in the RGB image has a unique depth value corresponding to it; the specific formula for converting the pixel coordinates in the RGB image with the pixel coordinates in the IR image is as follows:

[0035]

[0036] Zd : scale factor of the IR camera;

[0037] The inverse matrix of the IR camera external parameters;

[0038] The inverse matrix of the IR camera intrinsic parameters;

[0039] Z c : RBG camera scale factor;

[0040] K c : RGB camera external parameters;

[0041] M c : RGB camera intrinsic parameters.

[0042] The present invention has the following advantages and positive effects:

[0043] The invention improves the prediction accuracy of the YOLOv8-Pose algorithm for the key point positions on the back of pigs by adding a key point linear regression algorithm, obtains the key point pixel coordinates by real-time inference of the RGB image through the key point detection model, obtains the depth value corresponding to the pixel coordinates by image registration, converts the pixel coordinates into world coordinates based on the imaging principle, and finally calculates the body size information of the pigs. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 is a flow chart of the present method;

[0045] Figure 2 It is the model structure diagram;

[0046] Figure 3 is the model loss iteration graph. DETAILED DESCRIPTION

[0047] The following is a detailed description with reference to the accompanying drawings and embodiments:

[0048] 1. Single-stage rapid detection method of pig body size information based on key point regression

[0049] like Figure 1 , the method comprises the following steps:

[0050] ① Data collection: Build a pig limiting fence device, and install an RBG camera on the top of the device. When the pig completely enters the limiting fence device, collect the unobstructed RGB image of the pig's back - S1;

[0051] ②Dataset creation: The collected pig back images are divided into natural standing posture and unnatural standing posture. The key points of the pig back are annotated using the labeling software labelme-S2;

[0052] ③ Create a configuration file for the data set: Write the pig’s standing posture and key point information into the configuration file as the basic condition for simultaneously training the model for key point detection and target classification - S3;

[0053] ④Add key point regression model: Increase the accuracy of key point prediction by performing linear regression on the key point coordinates extracted by the feature extraction network-S4;

[0054] ⑤YOLOv8-Pose model training: Use the prepared data set to train the improved YOLOv8-Pose model to obtain a real-time detection model-S5 with high accuracy in pig posture classification and key point detection;

[0055] ⑥Model evaluation: Use the model to infer the test set images, calculate the Euclidean distance error between the predicted key point coordinates on the test set and the real key point coordinates on the test set to evaluate the model accuracy - S6;

[0056] ⑦Model deployment: Deploy the model to the Jetson Orin NX development board to achieve real-time inference of the model on the embedded device - S7;

[0057] ⑧ Image registration: The depth image is registered with the RGB image, and the hip height, shoulder height and body height of the pig are obtained by comparing the pixel coordinates of the detected key points with the depth values ​​of the corresponding pixel coordinates in the depth image - S8;

[0058] ⑨Coordinate conversion: According to the imaging principle, the pixel coordinates are converted into world coordinates, and the pig's body length, hip width and shoulder width data are obtained by calculating the distance between two points of the world coordinates - S9.

[0059] 2. Steps

[0060] ①Data collection

[0061] This patent collected image data of pig backs at a pig farm in Fuzhou, and collected a total of 4,477 images of pig backs. Finally, 1,000 images of unobstructed pig backs and pigs in different postures were selected for training the key point detection model of the pig back.

[0062] ②Dataset creation

[0063] The 1000 images of the pig's back collected were divided into natural standing posture and unnatural standing posture, of which there were 450 natural standing postures and 550 unnatural standing postures. The labeling software labelme was used to mark the key points of the neck, left shoulder, right shoulder, left hip, right hip and tail root on the pig's back to obtain the pixel coordinate information of each key point. Different label names were given to the pigs in natural standing posture and unnatural standing posture respectively, which were used to train the pig posture classification model. The data set was divided into training set, validation set and test set in a ratio of 6:2:2, and finally the natural standing images and unnatural standing posture images were mixed. There were 600 images in the training set, including 330 unnatural standing posture images and 270 natural standing posture images, and 200 images in the validation set and test set, including 110 unnatural standing posture images and 90 natural standing posture images. By evenly distributing the data set, it is ensured that the model can be fully trained.

[0064] ③Create a configuration file for the dataset

[0065] 1. The original YOLOv8-Pose algorithm can predict the key point position and target category in the image at the same time, but the target category label and key point position information of the data need to be marked in the configuration file of the data set; the YOLOv8-Pose algorithm can detect key points and identify target categories at the same time by calculating the key point position prediction loss and target detection loss for the predicted results to optimize the model; the specific calculation method of the loss function is as follows:

[0066] A. Classification loss function and target detection loss: The YOLOv8-Pose algorithm outputs a category for each prediction box, so the target detection function and the classification loss function are calculated at the same time, but the calculation methods are different.

[0067] Ⅰ. The classification loss is calculated using the BCEWithLogitsLoss (Binary Cross Entropy With LogitsLoss) loss function. This loss calculation method combines the Sigmoid activation function and the BCELoss (Binary CrossEntropyLoss) function into one class; this function is numerically more stable than using the ordinary Sigmoid activation function followed by the BCELoss function. The specific calculation formula is as follows:

[0068] L cls =-w n [y n ·logσ(x n )+(1-y n )·log(1-σ(xn )] (4)

[0069] w n : The weight of the loss function;

[0070] σ: Sigmoid activation function;

[0071] x n ; predicted value;

[0072] y n : true value.

[0073] Ⅱ. The loss function of the object detection bounding box is a combination of DFL (Distribution Focal Loss) and CIoU (Complete Intersection over Union); DFL aims to enhance feature learning capabilities by considering the relative spatial positions of features; and DFL provides directions for identifying spatial distributions to help retain detailed spatial information. It does not directly reduce the loss of object detection, but can help improve overall performance by enhancing the effectiveness of training features. It enables the network to quickly focus on the true value of close objects and improve prediction accuracy; the specific formula is as follows:

[0074] L dfl =-[(y i+1 -y)log(S i )+(yy i )log(S i+1 )] (5)

[0075] y: true label;

[0076] y i+1 ,;Nearby values ​​of the true label y;

[0077] S i : Probability distribution of network output

[0078] Compared with the traditional IoU metric, CIOU has significant advantages in target detection because it comprehensively considers the complete intersection between target boxes, avoids generating high matching evaluation scores in highly overlapping areas, and calculates the target loss value by considering multiple factors such as the center point, width and height of the target box; therefore, CIOU more accurately reflects the matching quality of the target box, making the model more accurate and reliable when evaluating target detection performance; the specific target detection loss function calculation formula is as follows:

[0079]

[0080] The coordinates of the predicted box k at position (i, j), where s is the scaling factor;

[0081] B. Keypoint detection loss function: OKS (Object Keypoint Similarity) function. The OKS keypoint loss function comprehensively considers the similarity between keypoints, rather than focusing only on the accuracy of a single keypoint. By calculating the overlap between the predicted keypoints and the true keypoints, the OKS loss function provides a comprehensive evaluation of the overall keypoint detection performance. Its inherent scale invariance enables accurate comparisons on objects of different scales, regardless of the size of the object, which is critical for processing targets of different scales. In addition, the OKS loss function also has the ability to weight keypoints according to their importance, allowing different importance weights to be set for different keypoints, thereby more flexibly capturing the importance and accuracy of keypoints. The specific calculation formula for the OKS keypoint loss function is as follows:

[0082]

[0083] d n : Euclidean distance between the predicted point and the true point

[0084] k n : The weight of the key point

[0085] s: image scaling

[0086] δ(v n ): indicates the visibility of the point

[0087] Next, for each key point, learn a confidence parameter to determine whether the object under test has the key point. The confidence calculation formula is as follows:

[0088]

[0089] Confidence of the predicted nth keypoint

[0090] C. Total loss function: Finally, the sum of all losses of anchor boxes, key point prediction, and classification is calculated as the model loss for each training;

[0091]

[0092] λ: Gain ratio of different losses

[0093] ⑥Model evaluation

[0094] After the image passes through the backbone feature extraction network and the feature fusion layer, the key point position coordinates extracted according to the image features will be obtained. After the key point coordinates are extracted, the image enters the MLP layer to perform linear regression between the key points. The advantage of the MLP layer in key point regression lies in its nonlinear modeling ability. By introducing the nonlinear activation function SiLU activation function and multi-level feature extraction, the neural network can more flexibly learn and model complex nonlinear relationships, adapt to information of different scales, realize end-to-end training, and have scalability, which helps to effectively capture and represent the key point positions of the target, thereby improving the accuracy of accurate prediction of the key point positions.

[0095] The specific model structure is as follows Figure 2 .

[0096] The model training was conducted under Win11 system. The computer CPU used was Intel(R) Core(TM) i5-13400F, memory was 32GB, GPU was GeForce GTX 4070, and deep learning framework was Pytorch 1.13.1. During training, the stochastic gradient descent algorithm was used as the optimizer to optimize the neural network. The batch size was set to 16 and the iteration cycle was set to 1500. After 1500 iterations, the model loss gradually decreased and eventually stabilized, as shown in Figure 1. Figure 3 As shown. Finally, after experimental comparison, the number of model parameters increased by 0.15% after adding the linear model to YOLOv8n-Pose. The key point detection accuracy increased by 11.91%; the specific model accuracy comparison is shown in Table 1; the model improves the model accuracy while slightly increasing the number of parameters, and the model loss value decreased by 7% by adding the linear layer; by adding the key point linear regression model, the model's reasoning speed is guaranteed to remain unchanged, and the model parameters are also guaranteed to remain unchanged, which provides a basis for the subsequent real-time detection of pig body size information.

[0097] Table 1 Comparison of accuracy of linear regression models

[0098]

[0099] ⑦Model deployment

[0100] Deploy the trained YOLOv8n-Pose+MLP model in the Jetson Orin NX development board for real-time inference. The specific steps are as follows:

[0101] a. Install Ubuntu 20.04 system in the Jetson Orin NX development board as the underlying basic environment.

[0102] b. Install the python3.8 interpreter in the Ubuntu20.04 system, and configure torch2.0.0+nv23.05, torchvision0.15.1, python3.8.10 and Ultralytics environment in the python3.8 interpreter to ensure that the key point prediction model trained in the Windows system can infer the RGB images detected by the camera in real time in the Ubuntu20.04 system.

[0103] c. Use the program to infer the RGB image detected by the depth camera in real time to obtain the pixel coordinates of the key points on the pig's back. And by calculating the center coordinates of the key points of the buttocks, shoulders, and head and tail, the pixel coordinates of the center point of the pig's buttocks, shoulders, and abdomen are obtained.

[0104] ⑧ Image registration

[0105] Use the trained single-stage pig key point prediction model based on key point regression to infer the pictures in the test set, obtain the key point prediction label file in text format, and save the name of the picture as the corresponding label name; use the python program to read the predicted key point coordinates and the real key point coordinates of each picture at the same time, and calculate the Euclidean distance error of the key point. The smaller the error, the higher the accuracy of the model. The key point Euclidean distance error calculation formula is as follows:

[0106]

[0107] L: Euclidean distance between the true point and the predicted point;

[0108] (x1, y1): real point pixel coordinates;

[0109] (x2, y2): pixel coordinates of the predicted point;

[0110] ⑨Coordinate conversion

[0111] The pixel coordinates of the center points of the pig's buttocks, shoulders, and the head and tail are calculated by calculating the center coordinates between the key points. The depth value corresponding to each pixel value is found through the image registration method, and the pixel coordinates with depth values ​​can be converted into world coordinates according to the imaging principle.

[0112] The depth map and RGB map registration method is as follows:

[0113] A. Use Zhang Zhengyou's calibration method to obtain the internal and external parameter matrices of the RBG camera and IR camera (the monocular structured light camera model used in this study is Astra pro, which receives speckles reflected by objects at different distances through the IR module to obtain a depth map). (where f x , f y Respectively represent the length of the focal length on the x-axis and y-axis, in pixels; u o With v o represents the coordinates of the center point of the camera photosensitive plate in the pixel coordinate system), the external parameter matrix (where R is the rotation matrix and T is the translation vector), the pixel coordinates in the RBG camera and the IR camera are converted to world coordinates to obtain the scale factor of the camera. The specific formula is as follows:

[0114]

[0115] Z: scale factor X W , Y W ,Z W : World coordinates

[0116] B. According to the external parameter matrix and internal parameter matrix of the RBG camera and the IR camera (the parameters of the camera and the depth camera are the same, and this study uses the camera parameters of the IR camera as the parameters of the depth camera for registration), the pixel coordinates in the RGB image are aligned with the pixel coordinates of the IR image (depth image), so that each pixel in the RBG image has a corresponding depth value in the IR image; the specific implementation formula is as follows:

[0117]

[0118] Z d : scale factor of the IR camera;

[0119] The inverse matrix of the IR camera external parameters;

[0120] The inverse matrix of the IR camera intrinsic parameters;

[0121] Z c : RBG camera scale factor;

[0122] K c : RGB camera external parameters;

[0123] M c : RGB camera internal parameters;

[0124] By registering the IR image with the RGB image, the depth value of each pixel in the RGB image can be obtained. According to the imaging principle, each pixel and the depth value can be converted into world coordinates. The specific method of converting the pixel coordinates into space coordinates according to the imaging principle in step S11 is:

[0125] Assume the depth value of pixel (i, j) is D(i, j), the camera's intrinsic parameter (f x ,f y ,u0,v0) has been obtained through camera calibration, then the calculation formula of the pixel point in the camera coordinate system is as follows:

[0126]

[0127] f x : Use pixels to describe the length of the focal length in the x-axis direction;

[0128] f y : Use pixels to describe the length of the focal length in the y-axis direction;

[0129] (u o , v o ): represents the coordinates of the center point of the camera's photosensitive plate in the pixel coordinate system;

[0130] (i,j): pixel coordinates;

[0131] (X, Y, Z): World coordinates corresponding to pixel coordinate (i, j).

[0132] The depth value corresponding to each pixel coordinate is obtained according to the registered IR image, and the world coordinates of each key point can be obtained according to the imaging principle calculation formula; finally, the real body length, shoulder width and hip width of the pig are obtained by calculating the real distance between the neck and the base of the tail, the left shoulder and the right shoulder, and the left hip and the right hip. The shoulder height, hip height and body height of the pig can be obtained by subtracting the depth value from the camera height.

Claims

1. A single-stage rapid detection method for pig body size information based on key point regression, Features The steps include: ① Data collection: A pig limiting fence device is built, and an RGB camera is installed on the top of the device. When the pig completely enters the limiting fence device, an unobstructed RGB image of the pig's back is collected (S1); ② Dataset creation: The collected pig back images were divided into natural standing posture and unnatural standing posture, and the key points of the pig back were annotated using the labeling software labelme (S2); ③ Create a configuration file for the data set: Write the pig’s standing posture and key point information into the configuration file as the basic condition for simultaneously training the model for key point detection and target classification (S3); ④Add key point regression model: Increase the accuracy of key point prediction by performing linear regression on the key point coordinates extracted by the feature extraction network (S4); ⑤ YOLOv8-Pose model training: Use the prepared data set to train the improved YOLOv8-Pose model to obtain a real-time detection model with high accuracy in pig posture classification and key point detection (S5); ⑥ Model evaluation: Use the model to infer the test set images, calculate the Euclidean distance error between the predicted key point coordinates on the test set and the real key point coordinates on the test set to evaluate the model accuracy (S6); ⑦Model deployment: Deploy the model to the Jetson Orin NX development board to achieve real-time inference of the model on the embedded device (S7); ⑧ Image registration: the depth image is registered with the RGB image, and the hip height, shoulder height and body height of the pig are obtained by comparing the depth values ​​of the key point pixels detected with the corresponding pixel coordinates in the depth image (S8); ⑨Coordinate conversion: According to the imaging principle, the pixel coordinates are converted into world coordinates, and the body length, hip width and shoulder width data of the pig are obtained by calculating the distance between two points of the world coordinates (S9).

2. According to claim 1, the single-stage rapid detection method for pig body size information based on key point regression, Features The step ④ is: After the image passes through the backbone feature extraction network and the feature fusion layer, the position coordinates of the key points extracted according to the image features will be obtained. The obtained key point coordinates will be input into the MLP model, and linear regression operations will be performed on each key point to learn the linear relationship between the key points and improve the model accuracy. By introducing the nonlinear activation function SiLU activation function and multi-level regression operations in the MLP model, the neural network can more flexibly learn to model complex nonlinear relationships, adapt to information of different scales, and realize end-to-end training, which helps to effectively capture and represent the key point positions of the target, thereby improving the accuracy of accurate prediction of the key point positions.

3. The single-stage rapid detection method for pig body size information based on key point regression according to claim 1, Features The step ⑥ is: Use the trained single-stage pig key point prediction model based on key point regression to infer the pictures in the test set, obtain the key point prediction label file in text format, and save the name of the picture as the corresponding label name; use the python program to read the predicted key point coordinates and the real key point coordinates of each picture at the same time, and calculate the Euclidean distance error of the key point. The smaller the error, the higher the accuracy of the model. The key point Euclidean distance error calculation formula is as follows: L: Euclidean distance between the true point and the predicted point (x 1 ,y 1 ): real point pixel coordinates (x 2 ,y 2 ): Pixel coordinates of the predicted point.

4. The single-stage rapid detection method for pig body size information based on key point regression according to claim 1, Features The step ⑦ is: A. Install Ubuntu 20.04 system in the Jetson Orin NX development board as the underlying basic environment; B. Install the python3.8 interpreter in the Ubuntu20.04 system, and configure torch2.0.0+nv23.05, torchvision0.15.1, python3.8.10 and Ultralytics environment in the python3.8 interpreter to ensure that the key point prediction model trained in the Windows system can infer the real-time detection image of the camera in the Ubuntu20.04 system; C. Use the program to infer the RGB image detected by the depth camera in real time to obtain the pixel coordinates of the key points on the pig's back, and obtain the pixel coordinates of the center point of the pig's buttocks, shoulder center point, and abdomen center point by calculating the center coordinates of the buttocks, shoulders, and head and tail key points.

5. The single-stage rapid detection method for pig body size information based on key point regression according to claim 1, Features The step ⑧ is: a. Use Zhang Zhengyou's calibration method to obtain the internal and external parameter matrices of the RBG camera and IR camera. This study uses a monocular structured light camera model Astra pro. The camera receives speckles reflected by objects at different distances through the IR module to obtain a depth map. where f x Indicates the use of pixels to describe the length of the focal length in the x-axis direction, f y Indicates the use of pixels to describe the length of the focal length in the y-axis direction, u o With ν o Represents the coordinates of the center point of the camera photosensitive plate in the pixel coordinate system, the external parameter matrix Where R is the rotation matrix, T is the translation vector, and the conversion formula between world coordinates and pixel coordinates is used to obtain the scale factor Z of the depth camera and RGB camera; the calculation formula of world coordinates and pixel coordinates is as follows: Z: scale factor; X W , Y W ,Z W : world coordinates; b. Align the pixel coordinates in the RGB image with the pixel coordinates in the IR image according to the external parameter matrix and the internal parameter matrix of the RBG camera and the IR camera, so that each pixel coordinate in the RGB image has a unique depth value corresponding to it; the specific formula for converting the pixel coordinates in the RGB image to the pixel coordinates in the IR image is as follows: Z d : scale factor of the IR camera; The inverse matrix of the IR camera extrinsic parameters; The inverse matrix of the IR camera intrinsic parameters; Z c : RBG camera scale factor; K c : RGB camera external parameters; M c : RGB camera intrinsic parameters.

Citation Information

Cited By

  • Height measuring method and system based on industrial camera and readable storage medium

    CN119732674A

  • Height measurement method, system and readable storage medium based on industrial camera

    CN119732674B

  • 3D target detection method based on YOLOv7-pose

    CN119888441A

  • Welding guide system based on key point detection

    CN121236103A