A method and device for counting the number of eggs laid in a whole laying hen house and accurately measuring the weight of eggs
The video preprocessing model and egg weight measurement counting model are used to preprocess and count and weigh the egg video data, which solves the problem of inefficient egg counting and weight measurement in the prior art, and achieves high accuracy and low cost contactless egg counting and weight measurement.
Patent Information
- Application Number
- CN202411765081.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-04
AI Technical Summary
The prior art is inefficient, time-consuming and labor-intensive in egg counting and weight measurement, and has low accuracy, especially in large chicken farms, where the system has poor adaptability, high cost and troublesome maintenance.
The video preprocessing model is used to preprocess the egg video data on the conveyor belt, generate a segmented data set, and build an egg weight measurement and counting model. The egg video data is counted and weighed through this model, and the recognition accuracy is improved using technologies such as the video super-resolution reconstruction algorithm EGVSR and dynamic serpentine convolution layer DSCNet.
It realizes contactless egg counting and weight measurement, improves the accuracy and efficiency of counting and weight measurement, reduces hardware equipment requirements and purchase costs, and is suitable for factory-based egg picking machine conveyor belts.
Smart Images

Figure CN119251594B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of animal husbandry, and in particular relates to a method and a device for counting the number of eggs laid in a whole laying hen house and accurately measuring the weight of eggs. Background Art
[0002] my country's egg-laying chicken farming industry has developed rapidly, and the output of poultry eggs has been at a high level in the world for many years. According to statistics from the National Bureau of Statistics in 2022, the output of poultry eggs was 34.56 million tons, an increase of 1.4%. With the increase in people's demand for high quality and high consumption of eggs, the egg-laying chicken farming industry is moving towards standardization, scale and intensive development. The demand for refined digital management of farming is also increasing, and the egg production and quality of laying hens have become important indicators of concern for breeding companies. Improving the digitalization of egg production and quality of laying hens can transmit the grading data and quality distribution data of laying hens in farms in real time, which will help improve the efficiency and market competitiveness of breeding production companies.
[0003] In order to accurately obtain the egg production and quality of laying hens in the entire farm, the commonly used methods are manual detection and machine detection (infrared counting and sensor weight measurement). Traditional infrared counting generally uses infrared beam technology, which is installed on both sides of the egg belt. Once an egg passes by, the infrared will be blocked and the count will be automatically counted. Sensor weight measurement is to install a load sensor on the conveyor belt or pipeline to measure the weight of the egg. The load sensor measures the weight based on the deformation of the elastic plate or strain gauge and converts it into an electrical signal. These electrical signals are amplified, filtered and converted before being read and recorded.
[0004] However, under the requirement of counting and weighing multiple eggs in a factory, the existing methods have poor adaptability. Due to interference from the target environment, sensor errors, noise pollution, background interference, etc., not only is the accuracy poor, but it will also increase the cost investment, which is unacceptable for the low-profit egg-laying chicken industry. In the prior art, for large chicken farms, multiple monitoring systems need to be deployed, the positioning of the chicken cages is not intuitive enough and the system construction is time-consuming and labor-intensive. It is troublesome to install equipment for multi-layer and multi-row chicken cages and the on-site chicken cage positioning is not intuitive. In the breeding scenario, the initial investment is large and the daily maintenance is troublesome in the later stage. Summary of the invention
[0005] In order to solve the problems existing in the background technology, the purpose of the present invention is to provide a method and device for counting the number of eggs laid in an entire laying hen house and accurately weighing the eggs, so as to solve the problems of low efficiency, time-consuming and labor-intensive, and low accuracy in egg counting and weighing in existing farms.
[0006] The technical solution adopted by the present invention is as follows, comprising the following steps:
[0007] Step S1, collecting video data of eggs on a conveyor belt through a camera with a fixed position and height, preprocessing the video data of eggs using a video preprocessing model, and generating a segmentation data set containing labels;
[0008] Step S2, constructing an egg weight counting model for egg counting and weight measurement, training the egg weight counting model using the segmented data set, and obtaining a trained egg weight counting model after the training is completed;
[0009] Step S3, input each frame of egg image in the egg video data to be tested into the trained egg weight measurement and counting model, and obtain the mass of each egg in the egg video data and the total number of eggs. After the egg weight measurement and counting model training is completed, the video preprocessing model can be connected to the input end of the trained egg weight measurement and counting model to preprocess the input egg video data so that the egg video data is first converted into each frame of egg image, and then input into the egg weight measurement and counting model.
[0010] In step S1, the egg video data is preprocessed using the video preprocessing model to generate a segmented data set in the following manner:
[0011] Step S1.1, preprocessing the egg video data:
[0012] First, the egg video data is input into the video preprocessing model, which extracts the egg images in the egg video data frame by frame, and then performs image enhancement on each frame of the egg image to obtain the label information of each frame of the egg image;
[0013] Step S1.2: Then construct each frame of egg image and the corresponding label information into a segmentation data set, wherein the label information includes confidence, outline information of the egg in the egg image and egg identification code ID.
[0014] Image enhancement is a digital image processing technology that purposefully emphasizes the overall or local characteristics of an image, improves the color, brightness, and contrast of the image, and thus makes an originally unclear image clear, or emphasizes certain features of interest, enlarges the differences between features of different objects in the image, and suppresses features of no interest. This process not only improves the visual effect of the image, but also enlarges the differences between features of different objects in the image. In specific implementation, image enhancement makes it possible to clearly distinguish between the egg area and the non-egg area in the egg image, which is conducive to obtaining the outer contour information of the egg.
[0015] In the video preprocessing model, the video super-resolution reconstruction algorithm EGVSR is used to enhance the input video data. The video super-resolution reconstruction algorithm EGVSR is mainly composed of a dedicated optical flow estimation network FNet and a deep residual network SRNet. After the dedicated optical flow estimation network FNet completes the optical flow estimation, the deep residual network SRNet completes the video frame super-resolution operation, thereby making the acquired blurry video picture clear. The dedicated optical flow estimation network FNet uses batch normalization fusion to increase the computing speed. The dedicated optical flow estimation network FNet uses matrix multiplication MatMul to replace the traditional naive convolution to improve the computing efficiency, thereby achieving the purpose of real-time performance.
[0016] The egg weight measurement and counting model in step S2 is mainly composed of an egg tracking model and an egg prediction model. Step S2 is specifically as follows:
[0017] Step S2.1, first, construct an egg tracking model for obtaining egg morphological features, and use the segmented data set to train the egg tracking model. After the training, a trained egg tracking model for identifying eggs and tracking trajectories is obtained;
[0018] Step S2.2, obtaining the true mass of each egg as a label, and then constructing the egg morphological features output by the egg tracking model and the label corresponding to each egg into a prediction data set;
[0019] Step S2.3, constructing an egg prediction model for predicting egg quantity and quality;
[0020] Step S2.4, using the prediction data set of step S2.2 to train the egg prediction model, and after the training is completed, a trained egg prediction model is obtained;
[0021] Step S2.5, connecting the output end of the trained egg tracking model and the input end of the trained egg prediction model to obtain the trained egg weight measurement and counting model.
[0022] In the step S2.1, the egg tracking model includes a segmentation module, a tracking module and a data post-processing module connected in sequence; the segmentation module is used to screen out egg images with a confidence greater than a preset threshold, and then perform image segmentation on the screened egg images according to the contour information of the eggs to obtain a mask image containing only eggs and corresponding mask contour information; the tracking module is used to track the identification code ID of each egg in the input egg image frame by frame to generate a tracking track of the corresponding egg; the data post-processing module outputs the morphological features of each egg in the egg image according to the tracking track of the egg, the mask image and the corresponding mask contour information, and the morphological features of the egg include the coordinates, longitudinal axis length, horizontal axis length, area and egg shape index of the egg.
[0023] The egg shape index refers to the ratio of the egg's longitudinal and transverse axes (long diameter to short diameter).
[0024] The tracking module uses the target tracking algorithm Bytetrack to complete the generation of predicted iterative trajectories and virtual trajectories. The virtual trajectory generation uses an observation-centered online smoothing method to generate virtual trajectories for targets whose iterative trajectories cannot be predicted, thereby solving the problem of obstacle occlusion in actual scenes. The data post-processing module analyzes the input mask image based on the cross-platform computer vision library OpenCV algorithm to output the morphological feature information of the target in the mask image.
[0025] In step S2.3, the egg weight measurement and counting model includes a data processing module, a counting module and a weighing module which are connected in sequence; the data processing module is used to sort the identification code IDs of the eggs in the input prediction data set in ascending order to eliminate erroneous or missing data; the counting module is used to perform cross-line detection on the eggs in the prediction data set and count the number of eggs that pass the cross-line detection; the weighing module performs quality regression prediction on the egg quality according to the morphological characteristics of the eggs to obtain the predicted quality of the eggs at different positions on the conveyor belt, and then averages the predicted quality of the eggs at various positions on the conveyor belt to obtain the mean egg quality; the number of eggs obtained by the counting module and the mean egg quality obtained by the weighing module are respectively used as the prediction results of the total number of eggs and the egg quality and output.
[0026] The cross-line detection of the counting module is set to the right side of the video stream to avoid the problem of overexposure of the image in the center, which leads to a decrease in the confidence of the detected target. The weighing module uses the lightweight gradient boosting machine learning LightGBM model to achieve regression prediction of quality. The lightweight gradient boosting machine learning LightGBM model uses Bayesian optimization to select hyperparameters for tuning to obtain the optimal model parameters, reduce the number of calculation iterations, and thus improve the calculation efficiency of the model.
[0027] In the segmentation module of the egg tracking model, an improved YOLOv8-seg model is used to identify and segment the egg image. The improved YOLOv8-seg model is obtained by replacing all conventional convolution modules in the bottleneck structure Bottleneck in the backbone feature extraction network of the conventional YOLOv8-seg model with a dynamic snake convolution module DSCNet. The improved YOLOv8-seg model can improve the accuracy and continuity of the segmentation module for the target egg edge segmentation task, avoid the problem that the segmentation model makes large errors at the edge, thereby affecting the accurate acquisition of the target egg area and resulting in low quality prediction accuracy.
[0028] The device of the present invention comprises a storage box, a lighting device, a video acquisition device, a data processing device and a video display device. The storage box is installed on a conveyor belt. A darkroom for placing the data processing device is arranged above the storage box. The data processing device is loaded with an egg weight counting model. An openable and closable box cover is arranged on the top of the storage box. A placement table for placing the video display device is arranged on the side wall of the upper part of the storage box. The data processing device and the video display device are both connected to the video acquisition device. The video acquisition device is used to collect egg video data on the conveyor belt. The data processing device is used to process the egg video data and output the mass of each egg in the egg video data and the total number of eggs. The video display device is used to display the collected egg video data. The lighting device is located above the conveyor belt and installed on the storage box. The lighting device is used to provide a light source for video acquisition of eggs.
[0029] The storage box is 3D printed by a light-curing device, and the material is white photosensitive resin. The lighting equipment is a 220V cold light source, and the light is white light. The side wall of the storage box is also equipped with a connection port reserved for data processing equipment and video display equipment, as well as a wire port reserved for data processing equipment. The camera in the video acquisition device is fixed on the storage box, and the distance between the lower end of the camera and the conveyor belt of the egg picking machine is 40cm, with an error of ±2cm.
[0030] The present invention uses the video super-resolution reconstruction algorithm EGVSR to perform super-resolution reconstruction on the video to improve the recognition effect of eggs, and uses the dynamic snake convolution layer DSCNet module to optimize and improve the YOLOv8-seg model, thereby improving the accuracy and continuity of the segmentation module for the target egg edge segmentation task; the segmentation detection model YOLOv8-seg and the Bayesian optimized lightweight gradient boosting machine learning LightGBM model regression prediction scheme are used in conjunction, which can run on a low-computing power development board, reducing the demand for hardware equipment and the purchase cost.
[0031] Compared with the prior art, the present invention has the following beneficial effects:
[0032] 1. The present invention achieves contactless egg counting and weighing tasks by acquiring video images on a conveyor belt, and uses an egg weighing and counting model and a weighing and counting device to count and weigh eggs, and the device has a simple structure.
[0033] 2. The method of the present invention can effectively track multiple eggs in real time and complete the counting and weighing tasks, thereby improving the integration level of animal husbandry.
[0034] 3. On the conveyor belt of the factory egg picking machine, the solution of the present invention can realize the two tasks of tracking, counting and weighing eggs. The whole process is contactless, low-cost and helpful for food safety. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A flow chart of the method of the present invention provided for this embodiment;
[0036] Figure 2 A network structure diagram of a segmentation module provided in this embodiment;
[0037] Figure 3 The prediction effect diagram provided for this embodiment;
[0038] Figure 4 A flowchart for constructing a data set provided in this embodiment;
[0039] Figure 5 This is a schematic diagram of the structure of the egg weighing and counting device provided in this embodiment.
[0040] In the picture: 1. Box cover; 2. Wiring port; 3. Placement table; 4. Lighting equipment; 5. Video acquisition equipment; 6. Darkroom; 7. Wire port. DETAILED DESCRIPTION
[0041] The present invention is described in detail below in conjunction with specific implementation cases. The following implementation cases will help those skilled in the art to further understand the present invention, but will not limit the present invention in any form.
[0042] The method for counting the number of eggs laid in a laying hen house and accurately measuring the weight of eggs provided in this embodiment specifically includes the following steps: Figure 1 As shown:
[0043] Step S1, collecting video data of eggs on a conveyor belt through a camera with a fixed position and height, preprocessing the video data of eggs using a video preprocessing model, and generating a segmentation data set containing labels;
[0044] In step S1, the egg video data is preprocessed using the video preprocessing model to generate a segmented data set in the following manner:
[0045] Step S1.1, preprocessing the egg video data: first, input the egg video data into the video preprocessing model, the video preprocessing model extracts the egg image in the egg video data frame by frame, and then performs image enhancement on each frame of the egg image to obtain the label information of each frame of the egg image;
[0046] Step S1.2: Then construct each frame of egg image and the corresponding label information into a segmentation data set, where the label information includes confidence, outline information of the egg in the egg image and the identification code ID of the egg.
[0047] Step S2, constructing an egg weight counting model for egg counting and weight measurement, training the egg weight counting model using the prediction data set, and obtaining a trained egg weight counting model after the training is completed;
[0048] The video preprocessing model acquires the input video data frame by frame and performs image enhancement and image recognition to output the target identified as an egg. The video preprocessing model uses data enhancement algorithms such as Mosaic, Copypaste, Random affine, MixUp, and Cutout in the training stage to enhance the robustness of the algorithm. In the real-time inference stage, the video super-resolution reconstruction algorithm EGVSR is used to perform optical flow estimation on the video image data and perform video frame super-resolution operations to complete image enhancement. The video super-resolution reconstruction algorithm EGVSR includes a dedicated optical flow estimation network FNet and a deep residual network SRNet. After the dedicated optical flow estimation network FNet is used to complete the optical flow estimation, the deep residual network SRNet is used to complete the video frame super-resolution operation to make the acquired blurred video images clear. In the dedicated optical flow estimation network FNet, batch normalization fusion is used to improve the operation speed. At the same time, the traditional naive convolution is replaced by matrix multiplication MatMul, which greatly improves the operation efficiency, thereby achieving the purpose of real-time performance.
[0049] The egg weight measurement and counting model in step S2 is mainly composed of an egg tracking model and an egg prediction model. Specifically, step S2 is as follows:
[0050] Step S2.1, constructing an egg tracking model for obtaining egg morphological features, training the egg tracking model using the segmented data set, and obtaining a trained egg tracking model for identifying eggs and tracking trajectories after the training is completed;
[0051] Step S2.2, obtaining the true mass of each egg as a label, and then constructing the egg morphological features output by the egg tracking model and the label corresponding to each egg into a prediction data set;
[0052] Step S2.3, constructing an egg prediction model for predicting egg quantity and quality;
[0053] Step S2.4, using the prediction data set of step S2.2 to train the egg prediction model, and after the training is completed, a trained egg prediction model is obtained;
[0054] Step S2.5, connecting the output end of the trained egg tracking model and the input end of the trained egg prediction model to obtain the trained egg weight measurement and counting model.
[0055] In step S2.1, the egg tracking model includes a segmentation module, a tracking module and a data post-processing module connected in sequence; the segmentation module is used to screen out egg images with a confidence level greater than a preset threshold, and then perform image segmentation on the screened egg images according to the contour information of the eggs to obtain a mask image containing only eggs and corresponding mask contour information; the tracking module is used to track the identification code ID of each egg in the input egg image frame by frame to generate a tracking trajectory of the corresponding egg; the data post-processing module outputs the morphological features of each egg in the egg image according to the tracking trajectory of the egg, the mask image and the corresponding mask contour information, and the morphological features of the egg include the coordinates of the egg, the length of the longitudinal axis, the length of the horizontal axis, the area and the egg shape index.
[0056] The segmentation module screens the results of the video preprocessing module based on the preset confidence, performs image segmentation on each target that meets the screening conditions, and obtains the segmented mask image and contour information. Among them, the segmentation module uses the segmentation model YOLOv8-seg model to complete image recognition and segmentation. The network backbone of the YOLOv8-seg model uses dynamic snake convolution DSCNet to optimize, thereby improving the model's accuracy and continuity for the target egg edge segmentation task, avoiding the problem that the segmentation model makes large errors at the edge, thereby affecting the accurate acquisition of the target egg area and resulting in low quality prediction accuracy.
[0057] like Figure 2 The figure shows the modified network structure of the segmentation module YOLOv8-seg. The deep learning YOLO model structure built under the framework of the open source machine learning library Pytorch includes three parts: the backbone network Backbone, the neck module Neck, and the prediction head module Head. The dynamic snake convolution DSCNet structure is used to improve the backbone network Backbone on the basis of the YOLOv8-seg model, thereby improving the accuracy and continuity of the segmentation model for the target egg edge segmentation task, avoiding the problem that the segmentation model makes large errors at the edge, thus affecting the accurate acquisition of the target egg area and resulting in low quality prediction accuracy. The improved YOLOv8-seg model is trained, and the images on the test set are processed to obtain the coordinates, vertical and horizontal axes, area, and the angle between the vertical axis and the vertical direction of the conveyor belt of each egg in each frame. The egg group number and identification code ID are combined for sorting, and the quality prediction data set is constructed with the actual quality of the egg. The prediction data set is divided into training set, validation set, and test set according to the ratio of 7:2:1, and the quality of all eggs is predicted using cross-validation.
[0058] The tracking module continuously analyzes the calculation results of the segmentation module frame by frame, identifies the new target with an identification code ID, and tracks it frame by frame. Among them, the target tracking algorithm Bytetrack adopts the Hungarian algorithm and Kalman filter optimization, including predictive iterative trajectory generation and virtual trajectory generation, so as to ensure the accuracy of motion trajectory generation and the uniqueness of the identification code ID in complex environments. Virtual trajectory generation adopts an observation-centered online smoothing method to generate virtual trajectories for targets whose iterative trajectories cannot be predicted, thereby solving the problem of obstacle occlusion in actual scenes. The predicted iterative trajectory generation uses Kalman filtering to predict and update the position of the trajectory at the next moment, and based on the momentum information corresponding to the position information and the intersection-over-union (IoU) calculation value, the predicted tracking box tracks are associated with the detection box detections in the current frame through the Hungarian algorithm to obtain the corresponding motion trajectory.
[0059] The data post-processing module calculates the mask image obtained in the segmentation module based on the cross-platform computer vision library OpenCV, and obtains relevant feature information of the target egg in the mask image including the egg shape index for weight prediction.
[0060] The data processing module of the egg weight counting model is used to analyze the data in the prediction data set one by one, sort and organize the data according to the identification code ID and group number, and eliminate erroneous data and missing data. The group number is the training group number of the prediction data set distribution, with a total of 12 groups, and an average of 3,000 data in each group.
[0061] The counting module is based on the supervised learning supervision algorithm, which performs cross-line detection on targets that meet the confidence requirements and obtains their tracked identification code ID. The cross-line detection is set to the right side of the video stream to avoid the problem of image overexposure in the center, which leads to a decrease in the confidence of the detected target. All targets that meet the preset confidence are counted to output the total number of targets as the number of eggs. The cross-line detection of the supervised learning supervision algorithm is specifically as follows: a detection line is arranged along the conveying direction of the conveyor belt. When the labeled eggs enter and leave the detection line, the total number of eggs is updated by 1. By entering and leaving the single line twice to identify the detection line count, the misidentification of eggs in the video frame can be reduced.
[0062] like Figure 3 As shown in the figure, the white vertical line (i.e. the line where the sum = 0) is the position set for the cross-line detection. The cross-line detection is set to the right side of the video stream to avoid the problem of image overexposure in the center position, which leads to a decrease in the confidence of the detection target. At the same time, the obtained egg identification code ID and the measured quality are output in the form of a label above the detection target for real-time visualization.
[0063] The weighing module uses the lightweight gradient boosting machine learning LightGBM model to perform quality regression prediction on the preprocessed data, obtain the predicted quality of the target eggs at different positions on the conveyor belt, and select the average value as the prediction result output. The lightweight gradient boosting machine learning LightGBM model uses Bayesian optimization to select hyperparameter tuning, obtain the optimal parameters of the model, reduce the number of operation iterations, and thus improve the model's operational efficiency. In addition, the lightweight gradient boosting machine learning LightGBM model uses L2 regularization to reduce the correlation between features and improve the stability of the model.
[0064] The formation process of the two data sets in this embodiment is as follows: Figure 4 As shown in the figure, the entire dataset is based on 360 eggs shot in the field, with 30 eggs in a group, a total of 12 groups, and an average of 13 seconds per group on the conveyor belt. Among them, the segmentation dataset randomly selects 6 groups from the shooting video, and captures a picture every 3 frames, for a total of 475 pictures. Each egg is measured separately by three different electronic balances, and the median is taken as the true mass, accurate to two decimal places. The eggs in the image data are annotated using relevant annotation software, and the image data and annotation information corresponding to the video data form a dataset. The annotation information includes the egg label and the corresponding contour information. The dataset uses the image data annotation tool labelme to create an egg segmentation dataset. On average, each egg border is annotated with more than 50 points, and the training set and validation set are divided according to the ratio of 8:2.
[0065] Step S3, finally, input each frame of egg image in the egg video data to be tested into the trained egg weight measurement and counting model to obtain the mass of each egg in the egg video data and the total number of eggs. In a specific implementation, after the egg weight measurement and counting model is trained, a video preprocessing model can be connected to the input end of the trained egg weight measurement and counting model to preprocess the input egg video data so that the egg video data is first converted into each frame of egg image, and then input into the egg weight measurement and counting model.
[0066] like Figure 5As shown, the device includes a storage box, a lighting device 4, a video acquisition device 5, a data processing device and a video display device. The storage box is installed on the conveyor belt. A darkroom 6 for placing the data processing device is arranged above the storage box. The data processing device is loaded with an egg weight counting model. An openable and closable box cover 1 is installed on the top of the storage box. A placement table 3 for placing the video display device is arranged on the side wall of the upper part of the storage box. The data processing device and the video display device are both connected to the video acquisition device. The video acquisition device 5 is used to collect egg video data on the conveyor belt. The data processing device is used to process the egg video data and output the mass of each egg in the egg video data and the total number of eggs. The video display device is used to display the collected egg video data. The lighting device 4 is located above the conveyor belt and installed on the storage box. The lighting device 4 is used to provide a light source for video acquisition of eggs.
[0067] The storage box is 3D printed by a light-curing device, and the material is white photosensitive resin. The lighting equipment is a 220V cold light source, and the light is white light. The side wall of the storage box is also provided with a connection port 2 reserved for data processing equipment and video display equipment, and a wire port 7 reserved for data processing equipment. The camera in the video acquisition device 5 is fixed on the storage box, and the distance between the lower end of the camera and the conveyor belt of the egg picking machine is 40cm, with an error of ±2cm.
[0068] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. However, these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for counting the number of eggs laid in a laying hen house and accurately measuring the weight of eggs, characterized in that: The following steps are involved: Step S1, collecting video data of eggs on a conveyor belt, preprocessing the video data of eggs using a video preprocessing model, and generating a segmentation data set containing labels; Step S2, constructing an egg weight counting model for egg counting and weight measurement, training the egg weight counting model using the segmented data set, and obtaining a trained egg weight counting model after the training is completed; Step S3, inputting the egg video data to be tested into the trained egg weight measurement and counting model to obtain the weight of each egg in the egg video data and the total number of eggs; The egg weight measurement and counting model in step S2 is mainly composed of an egg tracking model and an egg prediction model. Step S2 is specifically as follows: Step S2.1, first, construct an egg tracking model for obtaining egg morphological features, use the segmented data set to train the egg tracking model, and obtain a trained egg tracking model after the training is completed; Step S2.2, obtaining the true mass of each egg as a label, and then constructing the egg morphological features output by the egg tracking model and the label corresponding to each egg into a prediction data set; Step S2.3, constructing an egg prediction model for predicting egg quantity and quality; Step S2.4, using the prediction data set of step S2.2 to train the egg prediction model, and after the training is completed, a trained egg prediction model is obtained; Step S2.5, connecting the output end of the egg tracking model and the input end of the egg prediction model, thereby obtaining a trained egg weight measurement and counting model; In the step S2.1, the egg tracking model includes a segmentation module, a tracking module and a data post-processing module connected in sequence; the segmentation module is used to screen out egg images with a confidence level greater than a preset threshold, and then perform image segmentation on the screened egg images according to the contour information of the eggs to obtain a mask image containing only the eggs and the corresponding mask contour information; The tracking module is used to track the identification code ID of each egg in the input egg image frame by frame to generate a tracking track of the corresponding egg; The data post-processing module outputs the morphological features of each egg in the egg image according to the egg tracking trajectory, the mask map and the corresponding mask contour information, wherein the morphological features of the egg include the coordinates, the longitudinal axis length, the transverse axis length, the area and the egg shape index of the egg; In the step S2.3, the egg weight measurement and counting model includes a data processing module, a counting module and a weighing module which are connected in sequence; the data processing module is used to sort the identification code IDs of the eggs in the input prediction data set in ascending order; the counting module is used to perform cross-line detection on the eggs in the prediction data set, and count the number of eggs that pass the cross-line detection; the weighing module performs quality regression prediction on the egg quality according to the morphological characteristics of the eggs to obtain the predicted quality of the eggs at different positions on the conveyor belt, and then averages the predicted quality of the eggs at various positions on the conveyor belt to obtain the mean egg quality; the number of eggs obtained by the counting module and the mean egg quality obtained by the weighing module are respectively used as the prediction results of the total number of eggs and the egg quality and output.
2. A method for counting the number of eggs laid and accurately weighing eggs in a laying hen house according to claim 1, characterized in that: In step S1, the egg video data is preprocessed using the video preprocessing model to generate a segmented data set in the following manner: Step S1.1, preprocessing the egg video data: First, the egg video data is input into the video preprocessing model, which extracts the egg images in the egg video data frame by frame, and then performs image enhancement on each frame of the egg image to obtain the label information of each frame of the egg image; Step S1.2: Then construct each frame of egg image and the corresponding label information into a segmentation data set, wherein the label information includes confidence, egg contour information and egg identification code ID.
3. A method for counting the number of eggs laid and accurately weighing eggs in a laying hen house according to claim 2, characterized in that: In the segmentation module of the egg tracking model, an improved YOLOv8-seg model is used to identify and segment the egg image. The improved YOLOv8-seg model is obtained by replacing all convolution modules in the bottleneck structure Bottleneck in the backbone feature extraction network of the YOLOv8-seg model with a dynamic snake convolution module DSCNet.
4. A device for implementing the method according to any one of claims 1 to 3, characterized in that: The device comprises a storage box, a lighting device (4), a video acquisition device (5), a data processing device and a video display device. The storage box is installed on a conveyor belt. A darkroom (6) for placing the data processing device is arranged above the storage box. An openable and closable box cover (1) is installed on the top of the storage box. A placement table (3) for placing the video display device is arranged on the side wall of the upper part of the storage box. The data processing device and the video display device are both connected to the video acquisition device. The video acquisition device (5) is used to collect video data of eggs on the conveyor belt. The data processing device is used to process the video data of eggs and output the mass of each egg in the video data of eggs and the total number of eggs. The video display device is used to display the collected video data of eggs. The lighting device (4) is located above the conveyor belt and installed on the storage box. The lighting device (4) is used to provide a light source for video acquisition of eggs.
5. 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 method according to any one of claims 1 to 3 are implemented.
6. 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 method according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Egg weight detection method and device based on deep learning
CN115731236A
Multi-channel location fine egg laying performance monitoring method and system for laying hen house
CN116091473A