Chicken body size identification method, system and device and storage medium
By combining the target detection and image key point detection models, the key parts of the chicken's whole body are automatically identified, which solves the problem of low automation in the existing technology and achieves high-precision and stable body ruler measurement.
Patent Information
- Application Number
- CN202510340176.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-21
- Publication Date
- 2025-08-15
AI Technical Summary
The prior art has low degree of automation in chicken body ruler recognition, requires manual intervention, low detection efficiency, and insufficient accuracy and stability of existing methods.
The target detection model and the image key point detection model are combined. By labeling photos of key parts of the chicken's whole body, a target bounding box and key point detection model are established, and the pixel size is calculated using the ruler detection model to automatically identify the coordinates and ruler parameters of key parts of the chicken's whole body.
It realizes higher accuracy and more stable automated mass measurement, reduces measurement errors caused by environmental interference and individual differences, and improves the standardization and repeatability of measurements.
Smart Images

Figure CN120495380A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image detection, and in particular to a method, system, device and storage medium for identifying the body size of a chicken. Background Art
[0002] Various chicken body parameters (such as body oblique length and keel length) are important for measuring the development and health of poultry. For example, body oblique length is often used to assess the overall size and growth potential of chickens, as well as their skeletal structure and growth. Therefore, studying chicken body parameters is crucial for poultry farming. Currently, most parameters are collected and estimated manually using calipers, which requires significant labor and time costs and results in low accuracy in actual measurements. Existing measurement software requires manual labeling of the location of various parts, and cannot automatically identify various head parts.
[0003] The methods of using computers to automatically process graphic images mainly include the following:
[0004] 1. Threshold segmentation method: This method uses one or several thresholds to divide the image into several classes, and assumes that pixels in the same class belong to the same object. This method does not consider the spatial characteristics of the image and has problems such as low recall rate, poor noise resistance, and high requirements for image quality.
[0005] 2. Edge detection-based method: This method performs segmentation based on the discontinuity of the image, including methods based on local image functions, image filtering, multi-scale methods, etc. This method has difficulty in detecting edges when processing images with rich details and is greatly affected by noise interference.
[0006] 3. Region-based method: This method extracts connected regions in the image according to pre-defined criteria. Each region to be extracted must be manually given a seed point and is also very sensitive to noise.
[0007] Deep learning-based methods: This method uses neural networks to process images and adjust the weights between nodes to learn. It is commonly used in fields such as image classification and object detection, but the model is a black box and difficult to interpret.
[0008] There are few methods that can be directly applied to chicken body size identification, and the existing methods have a low degree of automation, require manual intervention, and have low detection efficiency. Summary of the Invention
[0009] To solve the above technical problems, a chicken body size recognition method is proposed, which includes collecting a full-body side view photo of the chicken, marking the key parts of the chicken in the photo, and generating a label file;
[0010] Build a target detection model, input the photo into the target detection model, and optimize the training parameters of the target detection model using the first loss function composed of classification loss, confidence loss, and positioning loss. Output the target bounding box position of the complete side view of the chicken.
[0011] Based on the target bounding box position, the image area of the complete side of the chicken is extracted from the photo. An image key point detection model is established. A second loss function consisting of a key point similarity loss function and a confidence loss function is used to optimize the training parameters of the key point detection model to identify the coordinate positions of the key parts of the chicken.
[0012] Build a ruler detection model, use it to identify the ruler area in the photo, calculate the pixel size of the ruler, and calculate the actual physical length corresponding to each pixel based on the actual size of the ruler;
[0013] Some body size data measurements can be converted based on the distance between key points.
[0014] As a preferred embodiment of the method for identifying the body size of a chicken according to the present invention, the key parts of the chicken body include the beak, head, shoulders, back, tail, legs, claws, and chest;
[0015] The generated label file includes target bounding box information and key part information.
[0016] As a preferred embodiment of the chicken body size recognition method of the present invention, the target bounding box information includes a label name of the target bounding box, the horizontal coordinate and vertical coordinate of the upper left corner point of the target bounding box, the horizontal coordinate and vertical coordinate of the lower right corner point of the target bounding box, and the width and height of the image file;
[0017] The key part information includes the tag number of the key part, the horizontal coordinate and the vertical coordinate of the center position of the key part, and the width and height of the image file.
[0018] As a preferred embodiment of the chicken body size identification method of the present invention, the first loss function is expressed as:
[0019]
[0020] in, Represents the first loss function, λ1, λ2, and λ3 are the weights of the three losses respectively, and L cls is the classification loss, L obj is the confidence loss, L CIoU represents the positioning loss;
[0021] The classification loss and the confidence loss are calculated using a binary cross entropy function;
[0022] The binary cross entropy function is expressed as,
[0023]
[0024] Among them, BCELoss represents the binary cross entropy function, y is the true label, and p is the predicted label.
[0025] As a preferred embodiment of the chicken body size identification method of the present invention, the positioning loss is expressed as:
[0026]
[0027]
[0028] Among them, IoU represents the intersection-over-union ratio, Overlap(x,y) represents the intersection area of the real rectangular bounding box and the predicted rectangular bounding box, Union(x,y) represents the union area of the real rectangular bounding box and the predicted rectangular bounding box, v is the correction factor, and w g ,h g is the width and height of the real rectangular bounding box, w p ,h p To predict the width and height of the rectangular bounding box, α is the weight parameter, b g is the center point of the true rectangular bounding box, b p is the center point of the predicted rectangular bounding box, ρ is the Euclidean distance between the center points of the true rectangular bounding box and the predicted rectangular bounding box, and c is the diagonal distance between the minimum circumscribed rectangle of the true rectangular bounding box and the predicted rectangular bounding box.
[0029] As a preferred embodiment of the chicken body size recognition method of the present invention, the key point similarity loss function is expressed as:
[0030]
[0031] in, represents the key point similarity loss function, N kpts represents the number of key points, OKS represents the key point similarity, s represents the scale of the target, d n represents the Euclidean distance between the actual position and the predicted position coordinates of the nth key point, k n represents the specific weight of the nth key point, δ(v n ) is an indicator function indicating whether each key point is visible;
[0032] If the nth key point is visible, that is, v n >0, then δ(v n >0)=1, otherwise δ(v n >0)=0;
[0033] The confidence loss function is expressed as,
[0034]
[0035] in, represents the confidence loss function, represents the prediction confidence of the nth key point, and BCE represents the confidence loss;
[0036] The second loss function is expressed as,
[0037]
[0038] in, Represents the second loss function, λ3 and λ4 are the weights of the two losses respectively.
[0039] As a preferred embodiment of the chicken body size identification method described in the present invention, the method of calculating the actual physical length corresponding to each pixel based on the actual size of the ruler includes identifying the ruler in the image, calculating the pixel width and height of the ruler, converting the pixel length into the real length based on the actual length, obtaining the real distance represented by each pixel, obtaining the outline of the ruler, calculating the pixel width W and pixel height H of the ruler outline, setting the ruler to a square with an actual area of Area, and obtaining the area of each pixel.
[0040] Another object of the present invention is to provide a chicken body size recognition system, which solves the problem that the boundaries of some parts of the chicken's body organs are not clear and the existing detection methods cannot accurately identify the positions of various parts. The system automatically identifies various parts and estimates body size data such as keel length, solving the problem of manual labeling required in existing detection methods. The combination of target detection and image key point recognition algorithms makes the identification of various parts more accurate. Compared with the existing technology, this method compares multiple algorithms and solves the above-mentioned problems in various aspects. Finally, it adopts a combination of multiple algorithms to achieve 100% target recognition in a test environment, and the output parameters meet production needs.
[0041] As a preferred embodiment of the chicken body size recognition system of the present invention, it is characterized by comprising: an image annotation module for collecting a side view photo of the whole body of the chicken, annotating key parts of the whole body of the chicken in the photo, and generating a label file;
[0042] The boundary analysis module is used to build a target detection model. The photo is input into the target detection model. The first loss function composed of classification loss, confidence loss, and localization loss is used to optimize the training parameters of the target detection model and output the target bounding box position of the complete side view of the chicken.
[0043] A coordinate analysis module is used to extract the image area of the chicken's complete side from the photo based on the target bounding box position, establish an image key point detection model, and optimize the training parameters of the key point detection model using a second loss function consisting of a key point similarity loss function and a confidence loss function to identify the coordinate positions of key parts of the chicken's body.
[0044] A length analysis module is used to establish a ruler detection model, use the ruler detection model to identify the ruler area in the photo, calculate the pixel size of the ruler, and calculate the actual physical length corresponding to each pixel based on the actual size of the ruler; and
[0045] The size recognition module is used to use the output of the image key point detection model to segment the key parts of the chicken using a mask method, obtain the pixel area and pixel perimeter of each key part, calculate the true area and true perimeter of each key part based on the true physical length corresponding to each pixel, and output the true area and true perimeter of each key part as the body size parameters of the chicken.
[0046] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of a chicken body size identification method when executing the computer program.
[0047] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a chicken body size identification method.
[0048] The present invention achieves higher-precision and more stable automated body measurement. This method uses a target detection model to automatically identify the complete side area of the chicken. Compared to traditional methods that rely on manual labeling or simple edge detection, this method improves the accuracy of target area extraction and reduces the impact of environmental interference on measurement results.
[0049] In terms of keypoint detection, this paper combines the OKS loss function with a keypoint confidence loss optimization model to achieve more accurate keypoint prediction. Compared to existing methods based on Euclidean distance or simple regression, it can more effectively correct keypoint positions and reduce measurement errors caused by individual differences or posture changes. Furthermore, by introducing the CIoU loss to optimize object detection, the bounding box fitting accuracy is improved, ensuring a more precise input area for keypoint detection and enhancing overall detection stability.
[0050] Furthermore, this invention uses a scale detection model to automatically convert pixel size to actual physical dimensions, eliminating measurement errors caused by variations in shooting distance and angle, making body measurement calculations more robust. Compared to traditional methods based on calibration plates or manual conversion, this invention eliminates the need for additional human intervention, significantly improving measurement standardization and repeatability. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0052] Figure 1 This is an overall flow chart of a chicken body size identification method provided by one embodiment of the present invention.
[0053] Figure 2 A schematic diagram of key point information of a chicken body size identification method provided by one embodiment of the present invention.
[0054] Figure 3 A model architecture diagram of a chicken body size identification method provided by one embodiment of the present invention.
[0055] Figure 4 This is a diagram showing the detection results of key points on the whole body of a chicken according to a method for identifying the body size of a chicken provided by one embodiment of the present invention. DETAILED DESCRIPTION
[0056] To make the above-mentioned objects, features, and advantages of the present invention more clearly understood, the following detailed description of the specific embodiments of the present invention is given in conjunction with the accompanying drawings. It is obvious that the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in this field without creative work should fall within the scope of protection of the present invention.
[0057] Example 1, reference Figure 1-Figure 2 , which is the first embodiment of the present invention, provides a method for identifying the body size of a chicken, comprising:
[0058] Step 1): Image preprocessing;
[0059] like Figure 2 As shown in the figure, using standard full-body side profile photos of various chicken breeds, we annotate the key locations of each part of the chicken in the image. The generated label file corresponds to the image file. Correspondence means that one image file corresponds to one label file, and the two files have the same file name. The label format of the label file has two parts. Images can be annotated manually.
[0060] The first part is:
[0061] (s,x1,y1,x2,y2,w,h) (1)
[0062] Where s is the label name of the target box, x1 is the x-coordinate of the upper-left corner of the target box, y1 is the y-coordinate of the upper-left corner of the target box, x2 is the x-coordinate of the lower-right corner of the target box, y2 is the y-coordinate of the lower-right corner of the target box, w is the width of the image file, and h is the height of the image file.
[0063] The second part is:
[0064] (s,x,y,w,h) (2)
[0065] Where s is the label number, x is the x-coordinate of the target center, y is the y-coordinate of the target center, w is the width of the image file, and h is the height of the image file.
[0066] The first part of the label is used to train the object detection model, and the second part is used to train the image key point recognition model.
[0067] Step 2): Build and train the target detection model;
[0068] This step builds an object detection algorithm model to detect and identify the complete side profile of a chicken in an image. The model receives an input image, computes features, and generates a predicted object position through the output layer. The model is trained by comparing the predicted position with the first part of the label prepared in step 1), calculating the loss function, using the backpropagation algorithm to calculate the gradient, and updating the model parameters using the AdamW optimizer.
[0069] The loss function consists of classification loss, confidence loss, and positioning loss, and its calculation formula is:
[0070]
[0071] Among them, λ1, λ2, and λ3 are the weights of the three losses respectively. is the classification loss, For confidence loss, both use the binary cross entropy function, and the binary cross entropy function BCELoss formula is:
[0072]
[0073] Among them, y is the true label and p is the predicted label.
[0074] To calculate the positioning loss, we need to first calculate the intersection over union (IoU):
[0075]
[0076] Among them, Overlap(x,y) represents the intersection area where the real rectangular bounding box overlaps with the predicted rectangular bounding box, and Union(x,y) represents the union area of the real rectangular bounding box and the predicted rectangular bounding box.
[0077] The positioning loss formula is:
[0078]
[0079] Among them, (w g ,h g ) is the width and height of the real rectangular bounding box, (w p ,h p ) are the width and height of the predicted rectangular bounding box. v is the correction factor, which is the consistency parameter of the predicted annotation box aspect ratio and is used for further adjustment. α is the weight parameter, which represents the proportion of the predicted annotation box aspect ratio in the loss. b g is the center point of the true rectangular bounding box, b p is the center point of the predicted rectangular bounding box, ρ is the Euclidean distance between the center points of the true rectangular bounding box and the predicted rectangular bounding box, and c is the diagonal distance between the minimum circumscribed rectangle of the true rectangular bounding box and the predicted rectangular bounding box.
[0080] After calculating the loss, backpropagation is performed to update the model parameters so that the predicted bounding box position is close to the actual bounding box position.
[0081] Step 3): Image key point recognition;
[0082] This step detects key points of various parts in the chicken profile image. Based on the target detection results from the previous step, the target is extracted from the rectangular frame. Within this extracted portion, key points of the chicken's body, including the beak, head, shoulders, back, tail, legs, claws, and chest, are manually labeled. An image key point detection model is then built to label each part of the chicken in the image.
[0083] The model input is an image of a chicken's whole body from the side, and the model output is the position and category of the key points of each part of the image after key point identification. The model is trained by comparing the predicted category with the second part of the label category prepared in step 1), calculating the deviation between the predicted key point position and the label key point position, calculating the loss function, performing backpropagation to calculate the gradient, and updating the model parameters through the optimizer AdamW.
[0084] The loss function of image key point recognition consists of the key point similarity loss function and the confidence loss function, and its formula is:
[0085]
[0086] Among them, λ3 and λ4 are the weights of the two losses, L kpts is the key point similarity loss function, which is used to measure the similarity between the predicted key points and the real key points; L kpts_conf The confidence loss function for key points can be used to quantitatively evaluate and optimize the confidence of key points. The combination of the two provides a more accurate training signal for the model.
[0087] The key point similarity loss function formula is:
[0088]
[0089] Among them, s represents the scale of the target (the area of the bounding box), d n represents the Euclidean distance between the actual position and the predicted position coordinates of the nth key point, k n represents the specific weight of the nth key point, δ(v n ) indicates whether each key point is visible. If the i-th key point is visible (i.e., v n >0), then δ(v n >0)=1, otherwise δ(v n >0)=0.
[0090] The key point confidence loss function formula is as follows:
[0091]
[0092] in, Represents the prediction confidence of the nth key point.
[0093] It should be noted that the method of this embodiment realizes body size recognition through key point recognition technology, while the existing technology usually realizes it through image segmentation.
[0094] Image segmentation technology can indeed provide classification information for each pixel in an image, but pixel-level segmentation is too complex for body measurement. Segmentation does not directly provide specific metric information, but rather focuses on the contours and shapes of each body part. Obtaining detailed segmentation information typically requires more training and inference time, making it less useful for body measurement, as the location of key points is sufficient for measurement purposes.
[0095] For the application scenario of measuring chicken body size data, key point recognition technology can accurately identify and locate the key points of the main parts of the chicken body, thereby calculating physical indicators. Both in data labeling and real-time application, it is faster and requires less computation than image segmentation technology.
[0096] Step 4): scale calculation;
[0097] This step is used to read the ruler information. Build an object recognition model to identify the ruler in the image, calculate the ruler's pixel width and height, and convert the pixel length to real length based on the actual length to obtain the true distance represented by each pixel. Obtain the ruler outline and calculate its pixel width W and pixel height H.
[0098] Set the ruler to a square with the actual area of Area, and get the area of each pixel as:
[0099]
[0100] The side length of each pixel is:
[0101]
[0102] Step 5): Parameter calculation
[0103] According to step 3), the various parts of the chicken's body can be classified and marked with key points. Using the true value represented by each pixel calculated in step 4), the distance between each key point can be used to convert some body size data measurement values.
[0104] The oblique length of a chicken is the distance from the shoulder joint to the ischial tuberosity. Assuming the coordinates of the shoulder keypoint obtained in step 3) are (w1, h1), and the coordinates of the tail keypoint are (w2, h2), the pixel distance between the two keypoints is:
[0105]
[0106] The true value of each pixel calculated in step 4) is pixel len , we can convert the actual data of the chicken's body oblique length to be roughly:
[0107] D1=d1·pixel len (15)
[0108] Similarly, the chicken's shin length is the straight-line distance between the upper shin joint and the third and fourth toes. The keypoint coordinates of the chicken's leg obtained in step 3) are (w3, h3), and the keypoint coordinates of the claw are (w4, h4). The pixel distance d2 between the two keypoints and the actual chicken shin length data D2 are:
[0109]
[0110] D2=d2·pixel len (17)
[0111] The chicken's neck length is the distance from the first cervical vertebra to the base of the neck. Given the coordinates of the head keypoint in the chicken's side view (w5, h5) and the shoulder keypoint (w1, h1), the pixel distance d3 between the two keypoints and the actual chicken neck length data D3 are:
[0112]
[0113] D3=d3·pixel len (19)
[0114] The breast depth of a chicken is the distance from the first thoracic vertebra to the front edge of the keel. Given the coordinates of the breast keypoint in the chicken's side view (w6, h6) and the shoulder keypoint (w1, h1), the pixel distance d4 between the two keypoints and the actual breast depth data D4 are:
[0115]
[0116] D4 = d4 pixel len (twenty one)
[0117] The semi-submerged length of a chicken is the distance from the tip of the beak to the midpoint of the line connecting the hip bones. Given the coordinates of the key points of the chicken's beak (w7, h7), the head (w5, h5), and the tail (w2, h2), the pixel distance d5 of the semi-submerged length and the ground truth D5 are:
[0118]
[0119] D5 = d5 pixel len (twenty three)
[0120] And so on, calculate all key parts.
[0121] It should be noted that the body size calculation method of this embodiment improves measurement efficiency in application, and has a more stable, universal and robust general solution in the complex application scenario of large-scale poultry farming.
[0122] Furthermore, key points are not simply randomly selected geometric centers or edges, but rather are designed to accurately reflect the chicken's anatomy. While calculating the distances between key points may seem simple, they correspond to specific body measurements (such as hemi-submerged length and shank length), and require a complete side-on view to measure these parameters.
[0123] Furthermore, in step 1) image preprocessing, we need to annotate a complete side view of the chicken for training two models (the object detection model and the image keypoint recognition model). The label file contains two parts, while the previous application document, similar to the one in the previous application, only annotated the chicken's head image to build the image segmentation model. The scope of the target is completely different.
[0124] In steps 2) and 3), we built two models to recognize the full-body side view of a chicken and identify key points, respectively. These models were built and trained using a deep convolutional neural network (CNN). While the image segmentation model used in the previous application also utilized deep convolutional neural network technology, it focused more on pixel-level segmentation, generating per-pixel category information. The head network and theoretical formulas were completely different from our two models.
[0125] Steps 4) and 5) are about application, which involves identifying the entire body size of the chicken. Previous applications only targeted the head organs, and measured the color, area, and circumference of the head organs.
[0126] Example 2, reference Figure 3-Figure 4 , which is the second embodiment of the present invention, provides a method for identifying the body size of a chicken. In order to verify the beneficial effects of the present invention, scientific demonstration is carried out through experiments.
[0127] The Labelme software package was used to annotate the images. Automatic labeling generally has errors, so the best method is to use manual labeling methods to generate high-quality label files. Compared with automatic labeling, manual labeling can greatly improve the accuracy of the model. Therefore, the examples use manual labeling, which requires dividing the dataset. Generally, the images are divided into training sets, validation sets, and test sets. In this method, there are 650 pictures of chickens of different breeds, of which 500 are used for training, 100 are used as validation sets, and 50 are used as test sets. Due to the limited data, the training set is enhanced and rotated and flipped.
[0128] The target detection and key point recognition model structure is as shown in the attached Figure 3 The model parameters are epoch training rounds, batchsize training batch size, imgsize training image size, and patience to control the number of rounds required for early stopping. The above parameters are set as follows:
[0129] epoch=500, batchsize=53, imgsize=640, patience=150
[0130] The model will calculate the loss according to formula (3) and formula (9), and use back propagation to update the parameters and weights of each layer of the model to gradually optimize the model.
[0131] The final model achieved a precision and recall rate of 1 on the validation set, and a mAP of 0.995, which can accurately detect all key points of the chicken body. Figure 4 shown.
[0132] For a recognized ruler, edge detection is used to detect its edges, identify its outline, and calculate the number of pixels in its width and height. The actual area and side length of each pixel are calculated using the ruler's true area. In this example, the ruler is set to a 2cm×2cm square to prepare for subsequent parameter calculations.
[0133] This method can accurately identify targets and key points, and will hardly cause classification errors or missed points, thus having the advantage of high accuracy.
[0134] This method uses automated calculations and only requires the input of manually captured images to identify the positions of key points on the chicken's entire body and calculate the corresponding parameters. It has low manual involvement and a high degree of automation.
[0135] Compared with existing methods, this method has a small error and high accuracy. Compared with existing technologies, this method can automatically identify images of various sizes with high accuracy. It can also solve the problem of manual labeling and direct measurement in existing technologies. It has a high degree of automation and significantly reduces labor and time costs.
[0136] Example 3 is the third embodiment of the present invention, which differs from the first two embodiments in that:
[0137] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0138] The logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device.
[0139] More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic devices), a portable computer disk cartridge (magnetic devices), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disc read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering, or processing in another suitable manner as necessary, and then stored in a computer memory.
[0140] It should be understood that various parts of the present invention can be implemented using hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application-specific integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0141] Example 4, a fourth embodiment of the present invention, provides a chicken body size recognition system, comprising: an image annotation module for collecting a full-body side view photo of a chicken, annotating key parts of the chicken in the photo, and generating a label file;
[0142] The boundary analysis module is used to build a target detection model. The photo is input into the target detection model. The first loss function composed of classification loss, confidence loss, and localization loss is used to optimize the training parameters of the target detection model and output the target bounding box position of the complete side view of the chicken.
[0143] A coordinate analysis module is used to extract the image area of the chicken's complete side from the photo based on the target bounding box position, establish an image key point detection model, and optimize the training parameters of the key point detection model using a second loss function consisting of a key point similarity loss function and a confidence loss function to identify the coordinate positions of key parts of the chicken's body.
[0144] A length analysis module is used to establish a ruler detection model, use the ruler detection model to identify the ruler area in the photo, calculate the pixel size of the ruler, and calculate the actual physical length corresponding to each pixel based on the actual size of the ruler; and
[0145] The size recognition module is used to use the output of the image key point detection model to segment the key parts of the chicken using a mask method, obtain the pixel area and pixel perimeter of each key part, calculate the true area and true perimeter of each key part based on the true physical length corresponding to each pixel, and output the true area and true perimeter of each key part as the body size parameters of the chicken.
[0146] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A method for identifying the body size of a chicken, characterized by: include, Collect full-body side profile photos of the chicken, annotate the key parts of the chicken in the photos, and generate a label file; Build a target detection model, input the photo into the target detection model, and optimize the training parameters of the target detection model using the first loss function composed of classification loss, confidence loss, and positioning loss. Output the target bounding box position of the complete side view of the chicken. Based on the target bounding box position, the image area of the complete side of the chicken is extracted from the photo. An image key point detection model is established. A second loss function consisting of a key point similarity loss function and a confidence loss function is used to optimize the training parameters of the key point detection model to identify the coordinate positions of the key parts of the chicken. Build a ruler detection model, use it to identify the ruler area in the photo, calculate the pixel size of the ruler, and calculate the actual physical length corresponding to each pixel based on the actual size of the ruler; Some body size data measurements can be converted based on the distance between key points.
2. The method for identifying the body size of a chicken according to claim 1, wherein: The key parts of the chicken body include the beak, head, shoulders, back, tail, legs, claws, and chest; The generated label file includes target bounding box information and key part information.
3. The method for identifying the body size of a chicken according to claim 2, wherein: The target bounding box information includes a label name of the target bounding box, a horizontal coordinate and a vertical coordinate of the upper left corner of the target bounding box, a horizontal coordinate and a vertical coordinate of the lower right corner of the target bounding box, and a width and a height of the image file; The key part information includes the tag number of the key part, the horizontal coordinate and the vertical coordinate of the center position of the key part, and the width and height of the image file.
4. A chicken body size identification method according to claim 3, characterized in that: The first loss function is expressed as, in, Represents the first loss function, λ1, λ2, and λ3 are the weights of the three losses respectively, and L cls is the classification loss, L obj is the confidence loss, L CIoU represents the positioning loss; The classification loss and the confidence loss are calculated using a binary cross entropy function; The binary cross entropy function is expressed as, Among them, BCELoss represents the binary cross entropy function, y is the true label, and p is the predicted label.
5. The method for identifying the body size of a chicken according to claim 4, wherein: The positioning loss is expressed as, Among them, IoU represents the intersection-over-union ratio, Overlap(x,y) represents the intersection area of the real rectangular bounding box and the predicted rectangular bounding box, Union(x,y) represents the union area of the real rectangular bounding box and the predicted rectangular bounding box, v is the correction factor, and w g ,h g is the width and height of the real rectangular bounding box, w p ,h p To predict the width and height of the rectangular bounding box, α is the weight parameter, b g is the center point of the true rectangular bounding box, b p is the center point of the predicted rectangular bounding box, ρ is the Euclidean distance between the center points of the true rectangular bounding box and the predicted rectangular bounding box, and c is the diagonal distance between the minimum circumscribed rectangle of the true rectangular bounding box and the predicted rectangular bounding box.
6. A chicken body size identification method according to claim 5, characterized in that: The key point similarity loss function is expressed as, in, represents the key point similarity loss function, N kpts represents the number of key points, OKS represents the key point similarity, s represents the scale of the target, d n represents the Euclidean distance between the actual position and the predicted position coordinates of the nth key point, k n represents the specific weight of the nth key point, δ(v n ) is an indicator function indicating whether each key point is visible; If the nth key point is visible, that is, v n >0, then δ(v n >0)=1, otherwise δ(v n >0)=0; The confidence loss function is expressed as, in, represents the confidence loss function, represents the prediction confidence of the nth key point, and BCE represents the confidence loss; The second loss function is expressed as, in, Represents the second loss function, λ3 and λ4 are the weights of the two losses respectively.
7. A chicken body size identification method according to claim 6, characterized in that: The method of calculating the actual physical length corresponding to each pixel based on the actual size of the ruler includes identifying the ruler in the image, calculating the pixel width and height of the ruler, converting the pixel length into the real length based on the actual length, obtaining the real distance represented by each pixel, obtaining the outline of the ruler, calculating the pixel width W and pixel height H of the ruler outline, setting the ruler to a square with an actual area of Area, and obtaining the area of each pixel.
8. A chicken body size identification system, using a chicken body size identification method according to any one of claims 1 to 7, characterized in that: include: The image annotation module is used to collect full-body side profile photos of chickens, annotate key parts of the chickens in the photos, and generate label files; The boundary analysis module is used to build a target detection model. The photo is input into the target detection model. The first loss function composed of classification loss, confidence loss, and localization loss is used to optimize the training parameters of the target detection model and output the target bounding box position of the complete side view of the chicken. A coordinate analysis module is used to extract the image area of the chicken's complete side from the photo based on the target bounding box position, establish an image key point detection model, and optimize the training parameters of the key point detection model using a second loss function consisting of a key point similarity loss function and a confidence loss function to identify the coordinate positions of key parts of the chicken's body. The length analysis module is used to establish a ruler detection model, use the ruler detection model to identify the ruler area in the photo, calculate the pixel size of the ruler, and calculate the actual physical length corresponding to each pixel based on the actual size of the ruler; as well as, The size recognition module is used to use the output of the image key point detection model to segment the key parts of the chicken using a mask method, obtain the pixel area and pixel perimeter of each key part, calculate the true area and true perimeter of each key part based on the true physical length corresponding to each pixel, and output the true area and true perimeter of each key part as the body size parameters of the chicken.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the chicken body size identification method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the chicken body size identification method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Vehicle overall dimension measurement method and device, electronic device and storage medium
CN120720996A
Vehicle outer dimension measurement method, device, electronic device and storage medium
CN120720996B