Pig grade real-time judgment method and device based on data collaboration

By combining depth cameras and RGB cameras with an improved convolutional neural network, automated and contactless pig grading is achieved, solving the problems of high subjectivity and low efficiency in manual grading and improving the accuracy and efficiency of pig grading.

CN121962846APending Publication Date: 2026-05-01BEIJING FOCUSED LOONG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING FOCUSED LOONG TECH CO LTD
Filing Date
2025-12-29
Publication Date
2026-05-01

Smart Images

  • Figure CN121962846A_ABST
    Figure CN121962846A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a pig grade real-time judgment method and device based on data collaboration, and the method comprises the steps: synchronously collecting a depth image and a color image through a coaxial depth camera and an RGB camera which are installed above a channel when a pig passes through, inputting the preprocessed depth image into an improved PointNet + + network for weight feature extraction and reasoning to obtain a weight estimation value; meanwhile, inputting the preprocessed RGB image area into an improved ResNet50 network into which an attention mechanism is introduced, performing body shape grade classification, outputting body shape probability distribution, performing linear calibration on a body weight estimation value based on historical actual measurement data, and determining a final body shape category in combination with a body shape grade probability; and mapping the calibrated body weight and the determined body type grade to a preset pig grade table, generating a comprehensive pig grade, and performing pig column division control, so that the pig grade determination efficiency and accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing, specifically to a method and apparatus for real-time determination of pig grades based on data collaboration. Background Technology

[0002] In the livestock slaughtering industry, accurate pig grading is crucial for ensuring product quality, meeting market demands, and improving economic efficiency. However, current pig grading relies mainly on manual visual inspection and estimation, a traditional method with numerous drawbacks.

[0003] First, human assessment is highly subjective. Different assessors, due to differences in experience, skill level, and visual judgment, may arrive at vastly different grading conclusions for the same pig, leading to a lack of consistency and impartiality in the results. This subjectivity not only affects the quality of product grading but may also lead to customer questioning of the grading results, thereby damaging the company's reputation.

[0004] Secondly, manual assessment is inefficient and cannot meet the rapid screening needs of large-scale slaughterhouses. Under high-intensity working conditions, assessors are prone to fatigue, leading to decreased assessment speed and accuracy, further extending the screening time for pigs and reducing overall production efficiency.

[0005] Furthermore, manual assessment carries the risk of economic loss. Assessment errors may result in pigs that do not meet customer requirements being incorrectly classified as high-grade, leading to product discounts or breach of contract; or pigs that meet requirements may be overlooked, resulting in wasted resources and potential revenue loss. These economic losses not only affect the company's profitability but may also adversely impact its long-term development.

[0006] Therefore, there is an urgent need for a real-time pig grading method based on data collaboration, which can be combined with automated industrial processes to improve the efficiency and accuracy of pig grading. Summary of the Invention

[0007] To address the problems in the existing technology, this application provides a method and apparatus for real-time pig grading based on data collaboration, which can improve the efficiency and accuracy of pig grading.

[0008] To solve at least one of the above problems, this application provides the following technical solution: Firstly, this application provides a method for real-time pig grading based on data collaboration, including: A gantry-type adjustable bracket is installed directly above the pig passage. A depth camera and an RGB camera are coaxially fixed on the bracket. An inlet flow-limiting gate and an outlet anti-backflow gate are respectively set at both ends of the pig passage to control the orderly passage of pigs one by one. The depth camera collects three-dimensional point cloud data of the pigs based on time-of-flight technology. When a pig enters the channel and triggers the photoelectric sensor, the depth camera and RGB camera are simultaneously activated to determine the corresponding depth image and RGB image, respectively. After the depth image and RGB image are transmitted synchronously through a preset dual transmission channel, image preprocessing is performed on the depth image and RGB image to determine the corresponding preprocessed depth image data and preprocessed RGB image data, respectively. The depth image data is input into a weight inference convolutional neural network, which outputs a predicted weight value for pigs. The RGB image data is input into a body shape inference convolutional neural network, which outputs a probability distribution of pig body shape levels. The weight inference convolutional neural network is a network structure improved based on a 3D point cloud neural network, including a sampling layer, a grouping layer, and a feature aggregation layer. The body shape inference convolutional neural network is an improved deep convolutional neural network that introduces an attention mechanism. The predicted weight of the pigs and the probability distribution of the pig body size grades are post-processed, and the post-processed pig weight values ​​and pig body size grades are mapped to a preset grade comparison table to determine the corresponding comprehensive pig grade. The comprehensive pig grade is compared with the current customer order requirements to determine the corresponding pig grade judgment result. The grade judgment result is displayed through a display device, and pig pen control is performed based on the grade judgment result.

[0009] Furthermore, a gantry-type adjustable bracket is installed directly above the pig passage, with a depth camera and an RGB camera coaxially fixed on the bracket, including: The adjustable gantry frame is 2.5-3.0m above the ground to ensure that the entire live pig is within the field of view for collection. The depth camera uses time-of-flight technology, has a resolution of no less than 640×480 pixels, a depth measurement range of 0.5-5 meters, a depth error of no more than ±2%, and a frame rate of no less than 90fps, and is used to collect three-dimensional point cloud data of live pigs. The RGB camera has a resolution of no less than 1920×1080 pixels, a color reproduction rate of no less than 95%, a frame rate of no less than 30fps, and a lens focal length of 16-25mm. It is used to capture RGB color images of live pigs.

[0010] Furthermore, the step of transmitting the depth image and the RGB image in time synchronization via a preset dual transmission channel includes: A dual transmission channel is constructed based on Ethernet and USB interfaces, with a transmission delay of ≤50ms, to ensure time synchronization of data between the two modes. The depth image is transmitted via Gigabit Ethernet, the RGB image is transmitted via USB 3.0 interface, and the acquisition and transmission time are synchronized through hardware timestamps.

[0011] Further, the step of performing image preprocessing on the depth image and the RGB image to determine the corresponding preprocessed depth image data and preprocessed RGB image data respectively includes: The depth image is subjected to median filtering and background subtraction to determine the corresponding pig area depth mask, and the pixels within the depth mask are converted into a 3D point cloud according to the camera intrinsic parameters to determine the corresponding preprocessed depth image data. The RGB image is color-corrected, and the coordinate alignment relationship between the RGB image and the depth image is used to extract the RGB sub-image corresponding to the depth mask region, thereby determining the corresponding preprocessed RGB image data.

[0012] Further, before inputting the depth image data into the weight inference convolutional neural network, the following steps are included: A weighted inference convolutional neural network is constructed based on the improved PointNet++ network. The improved PointNet++ network includes 3 sampling layers, 3 grouping layers, and 3 feature aggregation layers. Each sampling layer uses the farthest point sampling algorithm, and the three sampling layers sample 1024, 256, and 64 core points respectively to preserve the key point features of the three-dimensional contour of the live pig; Each of the three grouping layers adopts the ball query algorithm. The three grouping layers determine the corresponding local neighborhood point set with the core point as the center. The search radii of the three grouping layers are 0.3m, 0.2m and 0.1m respectively. Each of the feature aggregation layers includes two 1×1 convolutional kernels, a BatchNorm layer, and a ReLU activation function, used to extract local three-dimensional features based on the local neighborhood point set and aggregate them into a global feature vector, the global feature vector representing the overall three-dimensional morphology of the pig; The weight inference convolutional neural network further includes a deep image inference output layer, which contains two fully connected layers that receive the global feature vector according to the Sigmoid activation function and output the corresponding predicted weight value of the pig.

[0013] Further, before inputting the RGB image data into the set body shape inference convolutional neural network, the following steps are included: Construct a body shape inference convolutional neural network based on the input layer, feature extraction network, convolutional layer, and RGB image inference output layer; The feature extraction network adopts an improved ResNet50 network, which is obtained by replacing the first 3 convolutional kernels of the original ResNet50 network structure with preset 3×3 small convolutional kernels. The convolutional layer includes 5 convolutional blocks. After the 4th convolutional block of the convolutional layer, a CBAM attention module is embedded. The CBAM attention module includes a channel attention submodule and a spatial attention submodule, which are used to weight the channel dimension and spatial dimension of the pig feature map to determine the corresponding key features of pig body shape. The RGB image inference output layer includes a fully connected layer that receives the key features of the pig's body size according to the Softmax activation function and outputs the corresponding probability distribution of the pig's body size level.

[0014] Further, the post-processing of the predicted pig weight and the probability distribution of pig body size grades includes: Based on historical measured weight data, the predicted weight of the pigs is calibrated using a linear regression model to determine the corresponding pig weight value. Select the grade with the highest probability from the probability distribution of pig size grades to determine the corresponding pig size grade.

[0015] Secondly, this application provides a real-time pig grading device based on data collaboration, comprising: The pig passage layout module is used to install a gantry-type adjustable bracket directly above the pig passage. A depth camera and an RGB camera are coaxially fixed on the bracket. An inlet flow-limiting gate and an outlet anti-backflow gate are respectively provided at both ends of the pig passage to control the orderly passage of pigs one by one. The depth camera collects three-dimensional point cloud data of pigs based on time-of-flight technology. The dual-modal acquisition module is used to simultaneously start the depth camera and RGB camera when a pig enters the channel and triggers the photoelectric sensor, and determine the corresponding depth image and RGB image respectively. After transmitting the depth image and the RGB image in time synchronization through a preset dual transmission channel, the depth image and the RGB image are preprocessed to determine the corresponding preprocessed depth image data and preprocessed RGB image data respectively. The pig weight and body shape prediction module is used to input the depth image data into a set weight inference convolutional neural network and output the predicted weight of the pig; and to input the RGB image data into a set body shape inference convolutional neural network and output the probability distribution of the pig body shape level. The weight inference convolutional neural network is a network structure improved based on a three-dimensional point cloud neural network, including a sampling layer, a grouping layer and a feature aggregation layer. The body shape inference convolutional neural network is an improved deep convolutional neural network that introduces an attention mechanism. The pig grading module is used to post-process the predicted pig weight and the probability distribution of pig body size grades, map the post-processed pig weight and body size grades to a preset grading comparison table, determine the corresponding comprehensive pig grade, compare the comprehensive pig grade with the current customer order requirements, determine the corresponding pig grading result, display the grading result through a display device, and control pig pensing based on the grading result.

[0016] Thirdly, this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the data-coordinated real-time pig grading method.

[0017] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the aforementioned data-cooperative real-time pig grading method.

[0018] Fifthly, this application provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the data-cooperative real-time pig grade determination method described above.

[0019] As can be seen from the above technical solution, this application provides a method and device for real-time pig grading based on data collaboration. Using a coaxial depth camera and an RGB camera installed above the passageway, depth and color images are simultaneously acquired as pigs pass by. The preprocessed depth image is input into an improved PointNet++ network for weight feature extraction and inference to obtain a weight estimate. Simultaneously, the preprocessed RGB image region is input into an improved ResNet50 network with an attention mechanism for body shape classification, outputting a body shape probability distribution. The weight estimate is linearly calibrated based on historical measured data, and the final body shape category is determined by combining the body shape probability. The calibrated weight and the determined body shape level are mapped to a preset pig grading table to generate a comprehensive pig grading level and control pig penning. This improves the efficiency and accuracy of pig grading. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1This is one of the flowcharts illustrating the real-time pig grade determination method based on data collaboration in the embodiments of this application; Figure 2 This is a structural diagram of the real-time pig grade determination device based on data collaboration in the embodiments of this application; Figure 3 This is a schematic diagram of the structure of the electronic device in the embodiments of this application.

[0022] Figure label: Electronic device 9600, central processing unit 9100, memory 9140, communication module 9110, input unit 9120, audio processor 9130, display 9160, power supply 9170, buffer memory 9141, application / function storage unit 9142, data storage unit 9143, driver storage unit 9144, antenna 9111, speaker 9131, microphone 9132. Detailed Implementation

[0023] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0024] The acquisition, storage, use, and processing of data in this application comply with relevant laws and regulations.

[0025] In the livestock slaughtering industry, accurate pig grading faces challenges due to the subjective nature and low efficiency of manual judgment. This application provides a data-driven, collaborative, real-time pig grading method and apparatus. Using a coaxial depth camera and an RGB camera mounted above a passageway, depth and color images are simultaneously acquired as pigs pass by. The preprocessed depth image is input into an improved PointNet++ network for weight feature extraction and inference to obtain a weight estimate. Simultaneously, the preprocessed RGB image region is input into an improved ResNet50 network incorporating an attention mechanism for body shape classification, outputting a body shape probability distribution. The weight estimate is linearly calibrated based on historical measured data, and the final body shape category is determined by combining the body shape probability. The calibrated weight and the determined body shape level are mapped to a preset pig grading table to generate a comprehensive pig grading level, enabling pen control for pigs. This improves the efficiency and accuracy of pig grading.

[0026] To improve the efficiency and accuracy of pig grading, this application provides an embodiment of a real-time pig grading method based on data collaboration, see [link to embodiment]. Figure 1 The real-time pig level determination method based on data collaboration specifically includes the following: Step S101: Install a gantry-type adjustable bracket directly above the pig passage. A depth camera and an RGB camera are coaxially fixed on the bracket. An inlet flow-limiting gate and an outlet anti-backflow gate are respectively set at both ends of the pig passage to control the orderly passage of pigs one by one. The depth camera collects three-dimensional point cloud data of pigs based on time-of-flight technology. Optionally, in this embodiment, in order to better collect pig image data, a three-dimensional acquisition device is constructed in conjunction with the pig farming industrial scenario.

[0027] Mounting Bracket: A gantry-style adjustable bracket is erected directly above the pig passageway. This bracket carries the image acquisition equipment, and its height adjustment mechanism allows for fine adjustments within a range of 2.5 meters to 3.0 meters to accommodate the full-body imaging needs of pigs of different sizes. On this bracket, the depth camera and RGB camera are coaxially mounted, ensuring that their optical center axes coincide as much as possible in three-dimensional space, thus providing a geometrically consistent basis for subsequent data registration and fusion.

[0028] Depth Camera: A depth camera based on Time-of-Flight (ToF) technology with a resolution of ≥640×480, a depth measurement range of 0.5-5m, a depth error of ≤±2%, and a frame rate of ≥90fps is used to acquire three-dimensional depth images (point cloud data) of live pigs. The depth cameras are arranged in parallel on both sides of the double gate, one on each side.

[0029] RGB Camera: Employs a high-definition camera with a resolution ≥1920×1080, color reproduction ≥95%, frame rate ≥30fps, and a lens focal length of 16-25mm (adjustable). It is coaxially mounted with the depth camera to ensure consistent acquisition range. It is used to acquire RGB color images of live pigs. The RGB camera is positioned in the middle of the dual depth cameras, with three cameras arranged vertically side by side.

[0030] Entrance flow control gate: The function of the entrance flow control gate (such as a swing gate or lifting gate) is to physically isolate and prevent multiple pigs from rushing into the collection area at the same time, ensuring that only one pig enters the center of the camera's field of view at a time.

[0031] The exit anti-backflow gate is designed as a one-way gate (such as a spring hinge gate), allowing pigs to move forward into the next stage, but preventing them from retreating back to the acquisition area due to fright or habitual behavior. This ensures that pigs pass through the passage in a one-way, orderly, and continuous manner, providing a standardized working environment for image acquisition.

[0032] Step S102: When a pig enters the channel and triggers the photoelectric sensor, the depth camera and RGB camera are started simultaneously to determine the corresponding depth image and RGB image respectively. After the depth image and RGB image are transmitted synchronously in time through a preset dual transmission channel, the depth image and RGB image are preprocessed to determine the corresponding preprocessed depth image data and preprocessed RGB image data respectively. Optionally, in this embodiment, when a pig enters a specially designed passage area, a photoelectric sensor installed at the passage entrance is triggered. This sensor sends a start signal, simultaneously triggering the depth camera and RGB camera to begin acquiring images. The depth camera uses Time-of-Flight (ToF) technology to acquire depth images reflecting the pig's three-dimensional contours and distance information in real time; the RGB camera simultaneously acquires color images containing the pig's surface color, texture, and morphological details. To achieve complete temporal synchronization of the two image data, the system employs a hardware triggering mechanism to ensure that the two image acquisitions are strictly aligned at the same moment, avoiding subsequent image fusion or alignment errors caused by time differences.

[0033] Specifically, the data transmission module hardware is configured to use a dual transmission channel of Gigabit Ethernet + USB 3.0. Depth images (point cloud data) are transmitted via Ethernet, and RGB images are transmitted via USB 3.0, with a transmission latency of ≤50ms, ensuring the time synchronization of dual-modal data.

[0034] After the data transmission is completed, the system preprocesses the received depth image and RGB image respectively to improve image quality and extract effective features.

[0035] Depth image preprocessing includes median filtering to remove noise from the acquired depth map D, and extracting the depth mask M_depth of the pig region through background subtraction. The pig pixels in D are then converted into a 3D point cloud P using camera intrinsics.

[0036] The RGB image preprocessing includes color correction of the acquired RGB image I and extraction of the corresponding RGB region I_roi for the pig using alignment with the depth map. Normalization is then performed. This region extraction process effectively eliminates background interference, focusing on the pig's own visual characteristics and providing structured input data for subsequent body shape analysis.

[0037] This step triggers synchronous acquisition, dual-channel transmission, and structured preprocessing, realizing the conversion from physical scenes to high-quality and aligned dual-modal image data. This is the core guarantee for achieving contactless and automated judgment of pig levels to adapt to industrialized assembly line operation environments.

[0038] Step S103: Input the depth image data into a set weight inference convolutional neural network and output the predicted weight of the pig; input the RGB image data into a set body shape inference convolutional neural network and output the probability distribution of the pig body shape level. The weight inference convolutional neural network is a network structure improved based on a three-dimensional point cloud neural network, including a sampling layer, a grouping layer and a feature aggregation layer; the body shape inference convolutional neural network is an improved deep convolutional neural network that introduces an attention mechanism. Optionally, in this embodiment, this step achieves synchronous prediction of pig weight and body size through core network model design, including weight inference CNN and body size inference CNN.

[0039] Specifically, the weight inference CNN architecture design includes an input layer, a feature extraction network, and an output layer, wherein: 1.1 Input layer: Preprocessed depth image data (converting point cloud data into 16-bit depth maps, adjusting the size to 512×512 pixels, and normalizing to the [0,1] interval); 1.2 Feature Extraction Network: An improved PointNet++ network (3D point cloud neural network) is adopted, including 3 sampling layers, 3 grouping layers, and 3 feature aggregation layers: - Sampling layer: The FPS (Farthest Point Sampling) algorithm is used to sample 1024, 256 and 64 core points respectively to preserve the key features of the three-dimensional outline of the live pig; - Grouping layer: For each core point, the Ball Query algorithm is used with search radii of 0.3m, 0.2m, and 0.1m respectively to generate a local neighborhood point set; - Feature aggregation layer: Each aggregation layer contains two 1×1 convolutional kernels (64, 128, and 256 channels respectively), a BatchNorm layer, and a ReLU activation function to extract local 3D features and aggregate them into a global feature vector (512 dimensions). 1.3 Inference Output Layer: Contains two fully connected layers (512→256→1), using the Sigmoid activation function, and outputs the predicted weight of live pigs (unit: kg).

[0040] Specifically, the body shape inference CNN architecture design includes an input layer, a feature extraction network, convolutional layers, and an inference output layer, wherein: 2.1 Input layer: RGB image preprocessed data (size adjusted to 640×480 pixels, normalized to the [0,1] range, and data augmentation performed using random horizontal flipping and brightness adjustment); 2.2 Feature Extraction Network: An improved ResNet50 network is adopted, replacing the first 3 convolutional kernels of the original network with 3×3 small convolutional kernels, and adding one attention mechanism module (CBAM): 2.3 Convolutional layers: 5 convolutional blocks with 64, 128, 256, 512 and 1024 channels respectively. Each convolutional block contains residual connections and BatchNorm layers. CBAM Attention Module: Inserted after the 4th convolutional block, it enhances the extraction of key body features (such as trunk proportion, limb thickness, and back flatness) through channel attention and spatial attention weighting. 2.4 Inference Output Layer: Contains one fully connected layer (1024→3) and a Softmax activation function, outputting the probability distribution of body shape levels (3 levels: A-lean, B-balanced fat and fat, C-fat).

[0041] Optionally, in this embodiment, the training scheme for the two networks is as follows: Training dataset: Collect bimodal images of 10,000 live pigs of different breeds, weights (80-150kg), and body types, and simultaneously record the actual weight (measured by electronic scale) and body type grade (determined jointly by 3 senior employees) to build a labeled dataset; Loss function: Mean squared error loss (MSE) is used, as shown in the following formula:

[0042] Where N is the number of training samples. Let i be the actual weight of the i-th sample. This represents the weight predicted by the model.

[0043] Optimizer: Adam optimizer is used, with an initial learning rate of 0.001, a learning rate decay strategy (decaying to 0.9 every 10 epochs), 50 training epochs, and a batch size of 32. Model evaluation: When the ratio of training set to test set is 8:2, the weight inference error rate is ≤3%, and the body shape inference accuracy is ≥92%, the model training is completed and the model is embedded into the edge computing module.

[0044] The preprocessed D (or the top-view depth projection map generated from the point cloud P) and I_roi from step S102 are input into the two streams of the trained network for neural inference. The network performs forward propagation to obtain the weight estimate W_est and the body size probability P.

[0045] This step involves designing a module for synchronous reasoning of pig weight and body size, enabling synchronous reasoning of pig weight and body size, and obtaining weight and body size data simultaneously, laying the foundation for subsequent pig grading assessment.

[0046] Step S104: Post-process the predicted pig weight and the probability distribution of pig body size grades, and map the post-processed pig weight and pig body size grades to a preset grade comparison table to determine the corresponding comprehensive pig grade. Compare the comprehensive pig grade with the current customer order requirements to determine the corresponding pig grade judgment result. Display the grade judgment result through a display device, and control the pig pensing based on the grade judgment result.

[0047] Optionally, in this embodiment, the weight and body shape data predicted by the model are post-processed.

[0048] Weight calibration: A linear calibration model is introduced, and the W_est obtained in step S103 above is fine-tuned using historical slaughter weight data. W_final = a W_est + b (where a and b are calibration coefficients obtained through linear regression).

[0049] Body type determination: For the probability distribution P obtained in step S103 above, take the level with the highest probability as the final body type level T_final = argmax(P).

[0050] Comprehensive grade calculation: Map W_final and T_final to a preset business grade table (for example, divide weight into S / M / L grades, body type into 1 / 2 / 3 grades, and combine them into a grade such as "M2"), and output the final grade.

[0051] The W_final, T_final, and overall ratings are displayed in real time and uploaded to the management system.

[0052] The system can automatically compare the data with current customer orders (e.g., requirements: weight 100-110kg, body type "standard") and provide a "match" or "does not match" judgment to guide the column classification.

[0053] The results output includes an industrial-grade touchscreen (displaying weight, body type, and screening results) and signal indicator lights (green = meets requirements, red = does not meet requirements). It also supports data integration with the slaughterhouse ERP system to achieve automatic storage of screening records.

[0054] This example demonstrates how this embodiment uses a depth camera and an RGB camera to acquire images and then performs fusion analysis using a convolutional neural network (CNN) model to achieve automatic, contactless grading of live pig weight and body size.

[0055] As described above, the real-time pig grading method based on data collaboration provided in this application can simultaneously acquire depth and color images as pigs pass by using a coaxial depth camera and an RGB camera installed above the passage. The preprocessed depth image is input into an improved PointNet++ network for weight feature extraction and inference to obtain a weight estimate. Simultaneously, the preprocessed RGB image region is input into an improved ResNet50 network with an attention mechanism for body shape classification, outputting a body shape probability distribution. The weight estimate is linearly calibrated based on historical measured data, and the final body shape category is determined by combining the body shape probability. The calibrated weight and the determined body shape level are mapped to a preset pig grading table to generate a comprehensive pig grading level and control pig penning. This improves the efficiency and accuracy of pig grading.

[0056] In one embodiment of the real-time pig grading method based on data collaboration in this application, it may further include the following: Step S201: The gantry-type adjustable support is 2.5-3.0m above the ground to ensure that the entire live pig is within the field of view for collection; Step S202: The depth camera uses time-of-flight technology, has a resolution of not less than 640×480 pixels, a depth measurement range of 0.5-5 meters, a depth error of not more than ±2%, and a frame rate of not less than 90fps, and is used to collect three-dimensional point cloud data of live pigs. Step S203: The RGB camera has a resolution of not less than 1920×1080 pixels, a color reproduction rate of not less than 95%, a frame rate of not less than 30fps, and a lens focal length of 16-25mm, and is used to acquire RGB color images of live pigs.

[0057] Optionally, in this embodiment, the height of the gantry frame above the ground is strictly controlled between 2.5 meters and 3.0 meters. This height takes into account the average height of adult commercial pigs, the range of back curvature changes when the pig passes through, and the imaging field of view of the camera lens. When the live pig passes through the lower passage normally, from this height, the camera's field of view can completely cover the pig's snout to the base of its tail, including the outline of its body on both sides, avoiding the obstruction of the torso edges or image distortion caused by an excessive downward angle, and achieving imaging of the pig's entire body without blind spots or omissions.

[0058] Optionally, in this embodiment, the technical performance quantification indicators of the depth camera are specified.

[0059] An industrial-grade depth camera based on the Time-of-Flight (ToF) principle was selected. During operation, the camera's internal infrared laser emitter emits modulated near-infrared light pulses, which are reflected off the surface of the pig and received by a highly sensitive sensor. The camera chip calculates the time of flight of the light pulses to determine the distance from the emission point to each imaging pixel on the pig's surface.

[0060] Performance parameter settings: resolution no less than 640×480 pixels to ensure that the generated point cloud has sufficient spatial density to describe the pig's body details, such as rib indentations and rump curves; depth measurement range set to 0.5-5 meters, with the lower limit ensuring clear imaging at the closest distance and the upper limit fully covering distance changes that may occur due to the pig jumping or accidentally approaching; depth error no greater than ±2%, the absolute error of the depth value is a direct guarantee for the accuracy of subsequent volume and weight calculations; high-speed sampling capability with a frame rate of no less than 90fps, so that even when the pig runs through quickly, the system can capture its continuous posture, avoiding point cloud distortion due to motion blur, and providing the possibility for stable measurement in dynamic scenes.

[0061] Optionally, in this embodiment, the technical performance quantification indicators of the RGB camera are specified.

[0062] A high-resolution, high-color-fidelity industrial color camera was selected.

[0063] Performance parameters are set as follows: resolution no less than 1920×1080 (Full HD) to ensure that the acquired 2D images have rich details and can clearly distinguish visual cues such as skin color, texture, backfat thickness, and key anatomical landmarks of the pig; color reproduction no less than 95% to ensure highly realistic and reliable image color information and avoid color distortion caused by changes in lighting conditions or the camera's own color difference; frame rate no less than 30fps to ensure smooth image acquisition and to keep it synchronized with the depth image in time; a 16-25mm zoom lens is selected, which is a moderate short focal length to standard focal length range. It can obtain a sufficiently wide field of view at a height of 2.5-3 meters to cover the whole body of the pig. At the same time, by fine-tuning the focal length, the image sharpness and perspective relationship can be optimized so that the proportion of the 2D image of the pig is as close as possible to its real shape, which is convenient for pixel-level precise alignment with the depth information.

[0064] Through step S203, this embodiment defines the boundary conditions under which the system can work reliably, and enhances the stability and adaptability of the system in actual complex production environments by combining it with industrial production scenarios.

[0065] In one embodiment of the real-time pig grading method based on data collaboration in this application, it may further include the following: Step S301: Construct a dual transmission channel based on the Ethernet and USB interfaces, wherein the transmission delay of the dual transmission channel is ≤50ms to ensure time synchronization of the dual-mode data; Step S302: The depth image is transmitted via Gigabit Ethernet, the RGB image is transmitted via USB 3.0 interface, and the acquisition and transmission time are synchronized through hardware timestamps.

[0066] Optionally, in this embodiment, two high-bandwidth physical data transmission channels are established.

[0067] The 3D point cloud or depth map data generated by the depth camera is transmitted via a gigabit Ethernet line; the high-resolution color images generated by the RGB camera are transmitted via a USB 3.0 interface. The two channels work in parallel without interference, forming the physical basis for data transmission.

[0068] At the hardware level, when the depth camera and RGB camera acquire each frame of image data, they use the same hardware clock source or synchronization trigger to timestamp each frame. The timestamp information is encapsulated along with the image data and transmitted to the edge computing unit through their respective data channels. The receiving end uses the timestamps to precisely pair the nearly simultaneously arriving depth and RGB frames, thereby eliminating timing misalignments caused by asynchronous transmission paths or processing delays. The overall design goal of the transmission system is to control the total latency of "acquisition → transmission → reception pairing" to within ≤50 milliseconds.

[0069] Through step S302, this embodiment ensures that information from different physical sensors maintains temporal consistency when entering the computing unit, providing a reliable data foundation for subsequent collaborative analysis and fusion inference of depth features and RGB features of the same pig's posture.

[0070] In one embodiment of the real-time pig grading method based on data collaboration in this application, it may further include the following: Step S401: Perform median filtering and background subtraction on the depth image to determine the corresponding pig area depth mask, and convert the pixels within the depth mask into a 3D point cloud according to the camera intrinsic parameters to determine the corresponding preprocessed depth image data. Step S402: Perform color correction on the RGB image, and use the coordinate alignment relationship between the RGB image and the depth image to extract the RGB sub-image corresponding to the depth mask region, and determine the corresponding preprocessed RGB image data.

[0071] Optionally, in this embodiment, median filtering is used to denoise common impulse noise and local outliers in depth images. The system employs a sliding window method, taking the median of the depth values ​​of all pixels within its neighborhood window as the new depth value for each pixel in the depth image. This approach effectively suppresses noise while preserving the edge information of the pig's outline in the depth image, laying the foundation for subsequent accurate segmentation.

[0072] Background subtraction separates the foreground region of the pig from the current depth image using a pre-established channel background model. The system employs a dynamic background modeling method, combined with a Gaussian mixture model to statistically analyze the depth changes of each pixel, generating a depth mask for the pig region. This mask is a binary image, where white pixels represent the pig region and black pixels represent the background region, thus achieving accurate segmentation of the pig from its environment.

[0073] Next, the system uses the camera intrinsic parameter matrix to transform the pixels within the depth mask from two-dimensional image coordinates to three-dimensional spatial coordinates. Using the camera intrinsic parameters obtained through depth camera calibration (including focal length, principal point coordinates, etc.), combined with the depth value of each pixel, the three-dimensional spatial coordinates corresponding to each pixel can be calculated, generating complete three-dimensional point cloud data of the pig. This transformation process preserves the spatial geometric information of the pig, providing a direct three-dimensional data foundation for subsequent weight estimation.

[0074] Optionally, in this embodiment, color correction is an adjustment made to address color deviations in RGB images under different lighting conditions. The system employs an automatic white balance algorithm, which analyzes the overall tonal distribution of the image and adjusts the gain of the three RGB channels to make the image colors more realistic and consistent. This ensures the comparability of RGB images acquired at different times and under different lighting conditions, providing a stable color foundation for subsequent body feature extraction.

[0075] Region extraction utilizes a pig depth mask obtained from depth image processing. By leveraging the coordinate transformation relationship between the calibrated depth camera and the RGB camera, the depth mask is precisely mapped onto the RGB image, thereby extracting the RGB sub-image that perfectly corresponds to the pig region. This process relies on the joint calibration results of the two cameras, including rotation matrices and translation vectors, ensuring pixel-level alignment of the pig region in the two images.

[0076] Through step S402, this embodiment successfully obtained high-quality, aligned dual-modal data, which is a key data preparation stage for achieving high-precision judgment of the entire system.

[0077] In one embodiment of the real-time pig grading method based on data collaboration in this application, it may further include the following: Step S501: Construct a weight inference convolutional neural network based on the improved PointNet++ network, wherein the improved PointNet++ network includes 3 sampling layers, 3 grouping layers and 3 feature aggregation layers; Step S502: Each sampling layer adopts the farthest point sampling algorithm, and the three sampling layers sample 1024, 256 and 64 core points respectively to preserve the key point features of the three-dimensional contour of the live pig; Step S503: Each of the three grouping layers adopts the ball query algorithm. The three grouping layers determine the corresponding local neighborhood point set with the core point as the center. The search radii of the three grouping layers are 0.3m, 0.2m and 0.1m respectively. Step S504: Each of the feature aggregation layers includes two 1×1 convolutional kernels, a BatchNorm layer, and a ReLU activation function, used to extract local three-dimensional features based on the local neighborhood point set and aggregate them into a global feature vector, wherein the global feature vector represents the overall three-dimensional morphology of the pig. Step S505: The weight inference convolutional neural network further includes a deep image inference output layer, which contains two fully connected layers, receives the global feature vector according to the Sigmoid activation function, and outputs the corresponding predicted weight value of the pig.

[0078] Optionally, in this embodiment, this step describes the specific structure and implementation of constructing a convolutional neural network for pig weight inference based on the improved PointNet++ network.

[0079] First, the weight inference convolutional neural network consists of an input layer, a weight inference layer, and an output layer.

[0080] The weight inference layer employs an improved PointNet++ network. It consists of three sequentially connected sampling layers, three grouping layers, and three feature aggregation layers, forming a progressively layered 3D feature extraction pipeline. This hierarchical structure enables the network to gradually abstract coarse-to-fine feature representations from raw point cloud data, adapting to the complex and irregular 3D morphological feature extraction requirements of pigs.

[0081] Each sampling layer employs the farthest point sampling (FPS) algorithm. By iteratively selecting the point furthest from the existing point set as the new core point, it ensures that the sampling points uniformly cover the entire spatial distribution of the pig point cloud. The three sampling layers sequentially sample 1024, 256, and 64 core points, forming a progressively simplified core point sequence. This process, while preserving key geometric features of the pig's overall 3D contour (such as body length, height, and chest circumference), significantly reduces the amount of data and complexity of subsequent calculations, achieving a balance between feature focusing and computational efficiency.

[0082] Each group layer uses the core points sampled from the previous layer as the center and employs the Ball Query algorithm to search for neighboring points within a specified radius, forming a local neighborhood point set. The search radii for the three group layers are set to 0.3 meters, 0.2 meters, and 0.1 meters, respectively, forming a local receptive field that decreases in size. This design allows the network to gradually transition from capturing large-scale structural features such as the pig's torso to capturing fine details of local curved surfaces (such as the curvature of the back and the shape of the abdomen) over a smaller area, achieving a multi-scale understanding of the pig's three-dimensional morphology.

[0083] Each feature aggregation layer contains two 1×1 convolutional kernels, a batch normalization (BatchNorm) layer, and a ReLU activation function. The 1×1 convolutions are responsible for fusing and transforming features of points within the local neighborhood; the batch normalization layer accelerates training convergence and improves model stability; and the ReLU activation function introduces non-linear expressive power. Through the stacking of these three feature aggregation layers, the network gradually aggregates the feature information of the local neighborhood into higher-level semantic features, ultimately outputting a 512-dimensional global feature vector. This vector comprehensively encodes the overall three-dimensional morphology, volume distribution, and structural characteristics of the pig, serving as a direct basis for weight prediction.

[0084] In addition, the convolutional neural network for pig weight inference also includes an output layer, which consists of two fully connected layers. This output layer receives the previously generated 512-dimensional global feature vector and outputs the final predicted pig weight (in kilograms) through a sigmoid activation function. The fully connected layers are responsible for mapping the high-dimensional features to specific weight values, and the sigmoid function ensures that the output value falls within a reasonable range (e.g., 80-150 kg). This design enables the network to establish a complex nonlinear mapping relationship from the pig's three-dimensional morphological features to its weight.

[0085] Through step S505, this embodiment successfully extracts hierarchical features from point clouds using an improved PointNet++ network. This fully captures key geometric and structural features related to weight in the three-dimensional morphology of pigs. At the same time, the multi-scale sampling and grouping mechanism takes into account both the overall outline and local details, improving the richness and robustness of feature representation and enabling inference of pig weight prediction values.

[0086] In one embodiment of the real-time pig grading method based on data collaboration in this application, it may further include the following: Step S601: Construct a convolutional neural network for body shape inference based on the input layer, feature extraction network, convolutional layer, and RGB image inference output layer; Step S602: The feature extraction network adopts an improved ResNet50 network. The improved ResNet50 network is obtained by replacing the first 3 convolutional kernels of the original ResNet50 network structure with preset 3×3 small convolutional kernels. Step S603: The convolutional layer includes 5 convolutional blocks. A CBAM attention module is embedded after the 4th convolutional block of the convolutional layer. The CBAM attention module includes a channel attention submodule and a spatial attention submodule, which are used to weight the channel dimension and spatial dimension of the pig feature map to determine the corresponding key features of pig body shape. Step S604: The RGB image inference output layer includes one fully connected layer, which receives the key features of the pig's body size according to the Softmax activation function and outputs the corresponding probability distribution of the pig's body size level.

[0087] Optionally, in this embodiment, this step describes the construction and implementation of the body-size inference convolutional neural network.

[0088] First, the body shape inference convolutional neural network consists of an input layer, a feature extraction network, convolutional layers, and an RGB image inference output layer. The input layer is responsible for receiving and standardizing the preprocessed RGB image data; the feature extraction network, as the core module, is responsible for extracting high-level semantic features from the image; the convolutional layers further deepen feature representation and fusion; and the output layer is responsible for mapping the extracted features to specific body shape classification probabilities.

[0089] Specifically, ResNet50 was chosen as the base network for feature extraction, primarily because its residual connection structure effectively alleviates the gradient vanishing problem in deep networks, ensuring training stability and feature extraction capabilities. The improvement involves replacing the larger convolutional kernels (e.g., 7x7) in the first three layers of the original ResNet50 network with pre-defined 3x3 smaller convolutional kernels. This improvement aims to: firstly, reduce the number of model parameters while maintaining a similar receptive field, lowering computational complexity and improving model efficiency, thus better meeting the real-time requirements of edge computing deployments (pig body size data computation can be completed on edge computing nodes); secondly, replacing a single large convolutional kernel with multiple layers of small convolutional kernels allows for the introduction of more non-linear activation functions, enhancing the model's non-linear expressive ability and facilitating the learning of more complex and subtle pig body size features; and thirdly, this replacement typically enables the network to converge faster in the early stages of training, improving model training efficiency.

[0090] Specifically, the convolutional layer consists of five stacked convolutional blocks. Each block contains convolution, batch normalization, activation functions, and residual connections, progressively abstracting low-level features (such as edges and textures) into high-level semantic features (such as the overall shape of the torso and backfat thickness). Notably, after the fourth convolutional block, a CBAM (Convolutional Block Attention Module) is embedded. This module is composed of a channel attention submodule and a spatial attention submodule connected in series. The channel attention submodule analyzes the importance of each channel in the feature map and assigns different weights to different channels, thereby strengthening feature channels that are highly relevant to body shape discrimination (such as channels that may correspond to specific body part shapes) and suppressing irrelevant or noisy channels. The spatial attention submodule focuses on the spatial location of the feature map. By calculating the importance weight map of each location in the feature map, it guides the network to pay more attention to the spatial regions in the image that are most relevant to body shape discrimination (such as the back and sides of a pig). The synergistic effect of the two enables the network to adaptively and accurately "focus" on the most discriminative features in the input image that distinguish body types such as lean, balanced fat, and fatty, thus improving the targeting and effectiveness of feature extraction.

[0091] Specifically, the RGB image inference output layer receives the "key features of pig body shape" that have been processed by the preceding network depth and weighted by an attention mechanism. This layer contains a fully connected layer, which linearly combines and transforms the high-dimensional feature vectors whose spatial structure has been flattened. Subsequently, the output of this fully connected layer is processed by the Softmax activation function. This function outputs a probability vector whose dimension corresponds to the number of preset body shape grades (e.g., three categories: A - lean, B - balanced fat, and C - fatty). Each element in the vector represents the predicted probability that the input pig image belongs to the corresponding body shape grade. This probabilistic output not only provides the most likely body shape category (obtained by taking the maximum probability) but also provides classification confidence information, facilitating subsequent decision fusion or uncertainty handling.

[0092] Through step S604, this embodiment ensures the depth and stability of feature extraction by adopting and improving the mature ResNet50 base network; by introducing the CBAM attention mechanism, it significantly improves the model's ability to automatically focus on discriminative features, achieving high-accuracy automatic body size classification, while also taking into account the efficiency and practicality requirements of the model in an industrial deployment environment.

[0093] In one embodiment of the real-time pig grading method based on data collaboration in this application, it may further include the following: Step S701: Based on historical measured weight data, the predicted weight of the pigs is calibrated using a linear regression model to determine the corresponding pig weight value; Step S702: Select the grade corresponding to the highest probability from the probability distribution of pig body size grades to determine the corresponding pig body size grade.

[0094] Optionally, in this embodiment, a linear regression model based on historical slaughter measurement data is constructed.

[0095] A batch of slaughtered pigs' predicted weights and actual weighings are pre-collected using neural networks. A linear mapping relationship between the two is established, and calibration coefficients a (slope) and b (intercept) are fitted. In practical applications, the predicted weight of each pig is substituted into the linear equation W_final = a × W_est + b to calculate the calibrated weight value W_final. This step can correct systematic biases in the model caused by factors such as breed, feeding environment, and image acquisition conditions, ensuring that the weight estimation results are closer to the actual weighing values, thereby improving the stability and industrial usability of weight determination.

[0096] Next, based on the probability values ​​corresponding to each body type level (such as lean type A, balanced fat type B, and fatty type C) output by the body type network, the system selects the level with the highest probability as the final body type level T_final for the pig.

[0097] Through step S702, this embodiment successfully post-processes the weight and body shape data, corrects deviations caused by environmental and data collection conditions, and further improves the accuracy of grade determination.

[0098] To improve the efficiency and accuracy of pig grading, this application provides an embodiment of a data-collaboration-based real-time pig grading device for implementing all or part of the aforementioned data-collaboration-based real-time pig grading method. See [link to embodiment]. Figure 2 The real-time pig grading device based on data collaboration specifically includes the following components: The pig passage layout module 10 is used to install a gantry-type adjustable bracket directly above the pig passage. A depth camera and an RGB camera are coaxially fixed on the bracket. An inlet flow-limiting gate and an outlet anti-backflow gate are respectively provided at both ends of the pig passage to control the orderly passage of pigs one by one. The depth camera collects three-dimensional point cloud data of pigs based on time-of-flight technology. The dual-modal acquisition module 20 is used to simultaneously start the depth camera and RGB camera when the photoelectric sensor is triggered by the pig entering the channel, and determine the corresponding depth image and RGB image respectively. After transmitting the depth image and the RGB image in time synchronization through the preset dual transmission channel, the depth image and the RGB image are preprocessed to determine the corresponding preprocessed depth image data and preprocessed RGB image data respectively. The pig weight and body shape prediction module 30 is used to input the depth image data into a set weight inference convolutional neural network and output the predicted weight of the pig; and to input the RGB image data into a set body shape inference convolutional neural network and output the probability distribution of the pig body shape level. The weight inference convolutional neural network is a network structure improved based on a three-dimensional point cloud neural network, including a sampling layer, a grouping layer and a feature aggregation layer. The body shape inference convolutional neural network is an improved deep convolutional neural network that introduces an attention mechanism. The pig grading module 40 is used to post-process the predicted pig weight value and the probability distribution of the pig body shape grade, and map the post-processed pig weight value and pig body shape grade to a preset grade comparison table to determine the corresponding comprehensive pig grade. The comprehensive pig grade is compared with the current customer order requirements to determine the corresponding pig grading result. The grading result is displayed through a display device, and pig pensing control is performed based on the grading result.

[0099] As described above, the real-time pig grading device based on data collaboration provided in this application can simultaneously acquire depth and color images as pigs pass by using a coaxial depth camera and an RGB camera installed above the passage. The preprocessed depth image is input into an improved PointNet++ network for weight feature extraction and inference to obtain a weight estimate. Simultaneously, the preprocessed RGB image region is input into an improved ResNet50 network with an attention mechanism for body shape classification, outputting a body shape probability distribution. The weight estimate is linearly calibrated based on historical measured data, and the final body shape category is determined by combining the body shape probability. The calibrated weight and the determined body shape level are mapped to a preset pig grading table to generate a comprehensive pig grading level and control pig penning. This improves the efficiency and accuracy of pig grading.

[0100] From a hardware perspective, in order to improve the efficiency and accuracy of pig grading, this application provides an embodiment of an electronic device for implementing all or part of the data-collaboration-based real-time pig grading method, wherein the electronic device specifically includes the following: The system comprises a processor, memory, a communications interface, and a bus; wherein the processor, memory, and communications interface communicate with each other via the bus; the communications interface is used to transmit information between the data-collaboration-based real-time pig grading method and core business systems, user terminals, and related databases and other related devices; the logic controller can be a desktop computer, tablet computer, or mobile terminal, etc., and this embodiment is not limited to these. In this embodiment, the logic controller can be implemented with reference to the embodiments of the data-collaboration-based real-time pig grading method in the previous embodiments, and the contents of these embodiments are incorporated herein, with repeated details not repeated.

[0101] It is understood that the user terminal may include smartphones, tablet computers, network set-top boxes, portable computers, desktop computers, personal digital assistants (PDAs), in-vehicle devices, smart wearable devices, etc. Among these, the smart wearable devices may include smart glasses, smartwatches, smart bracelets, etc.

[0102] In practical applications, parts of the data-collaboration-based real-time pig grading method can be executed on the electronic device side as described above, or all operations can be completed in the client device. The choice can be made based on the processing power of the client device and the limitations of the user's usage scenario. This application does not impose any limitations on this. If all operations are completed in the client device, the client device may further include a processor.

[0103] The aforementioned client device may have a communication module (i.e., a communication unit) that can communicate with a remote server to achieve data transmission with the server. The server may include a server on the task scheduling center side; in other implementation scenarios, it may also include a server on an intermediate platform, such as a server on a third-party server platform that has a communication link with the task scheduling center server. The server may include a single computer device, a server cluster consisting of multiple servers, or a distributed server structure.

[0104] Figure 3 This is a schematic block diagram illustrating the system configuration of the electronic device 9600 according to an embodiment of this application. Figure 3 As shown, the electronic device 9600 may include a central processing unit 9100 and a memory 9140; the memory 9140 is coupled to the central processing unit 9100. It is worth noting that... Figure 3 This is an example; other types of structures can also be used to supplement or replace this structure to achieve telecommunications functions or other functions.

[0105] In one embodiment, the real-time pig grading method based on data collaboration can be integrated into the central processing unit 9100. The central processing unit 9100 can be configured to perform the following control: Step S101: Install a gantry-type adjustable bracket directly above the pig passage. A depth camera and an RGB camera are coaxially fixed on the bracket. An inlet flow-limiting gate and an outlet anti-backflow gate are respectively set at both ends of the pig passage to control the orderly passage of pigs one by one. The depth camera collects three-dimensional point cloud data of pigs based on time-of-flight technology. Step S102: When a pig enters the channel and triggers the photoelectric sensor, the depth camera and RGB camera are started simultaneously to determine the corresponding depth image and RGB image respectively. After the depth image and RGB image are transmitted synchronously in time through a preset dual transmission channel, the depth image and RGB image are preprocessed to determine the corresponding preprocessed depth image data and preprocessed RGB image data respectively. Step S103: Input the depth image data into a set weight inference convolutional neural network and output the predicted weight of the pig; input the RGB image data into a set body shape inference convolutional neural network and output the probability distribution of the pig body shape level. The weight inference convolutional neural network is a network structure improved based on a three-dimensional point cloud neural network, including a sampling layer, a grouping layer and a feature aggregation layer; the body shape inference convolutional neural network is an improved deep convolutional neural network that introduces an attention mechanism. Step S104: Post-process the predicted pig weight and the probability distribution of pig body size grades, and map the post-processed pig weight and pig body size grades to a preset grade comparison table to determine the corresponding comprehensive pig grade. Compare the comprehensive pig grade with the current customer order requirements to determine the corresponding pig grade judgment result. Display the grade judgment result through a display device, and control the pig pensing based on the grade judgment result.

[0106] As described above, the electronic device provided in this application embodiment, through a coaxial depth camera and an RGB camera installed above the passage, simultaneously acquires depth and color images as pigs pass by. The preprocessed depth image is input into an improved PointNet++ network for weight feature extraction and inference to obtain a weight estimate. Simultaneously, the preprocessed RGB image region is input into an improved ResNet50 network with an attention mechanism for body size classification, outputting a body size probability distribution. The weight estimate is linearly calibrated based on historical measured data, and the final body size category is determined by combining the body size probability. The calibrated weight and the determined body size level are mapped to a preset pig level table to generate a comprehensive pig level and control pig penning. This improves the efficiency and accuracy of pig level determination.

[0107] In another embodiment, the real-time pig grading method based on data collaboration can be configured separately from the central processing unit 9100. For example, the real-time pig grading method based on data collaboration can be configured as a chip connected to the central processing unit 9100, and the function of the real-time pig grading method based on data collaboration can be realized through the control of the central processing unit.

[0108] like Figure 3 As shown, the electronic device 9600 may further include: a communication module 9110, an input unit 9120, an audio processor 9130, a display 9160, and a power supply 9170. It is worth noting that the electronic device 9600 does not necessarily need to include these components. Figure 3 All components shown; in addition, the electronic device 9600 may also include Figure 3 For components not shown, please refer to existing technologies.

[0109] like Figure 3 As shown, the central processing unit 9100, sometimes also referred to as a controller or operating control, may include a microprocessor or other processor device and / or logic device, which receives inputs and controls the operation of various components of the electronic device 9600.

[0110] The memory 9140 may be, for example, one or more of a cache, flash memory, hard drive, removable media, volatile memory, non-volatile memory, or other suitable devices. It may store the aforementioned failure-related information, and also store a program for executing that information. The central processing unit 9100 may execute the program stored in the memory 9140 to perform information storage or processing, etc.

[0111] Input unit 9120 provides input to central processing unit 9100. Input unit 9120 may be, for example, a keypad or touch input device. Power supply 9170 provides power to electronic device 9600. Display 9160 displays images and text. Display may be, for example, an LCD display, but is not limited thereto.

[0112] The memory 9140 can be a solid-state memory, such as a read-only memory (ROM), random access memory (RAM), a SIM card, etc. It can also be a memory that retains information even when power is off, can be selectively erased, and contains more data; examples of this type of memory are sometimes referred to as EPROMs. The memory 9140 can also be some other type of device. The memory 9140 includes a buffer memory 9141 (sometimes referred to as a buffer). The memory 9140 may include an application / function storage unit 9142 for storing application programs and function programs or processes for executing the operation of the electronic device 9600 via the central processing unit 9100.

[0113] The memory 9140 may also include a data storage unit 9143 for storing data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit 9144 of the memory 9140 may include various drivers for the electronic device for communication functions and / or for performing other functions of the electronic device (such as messaging applications, address book applications, etc.).

[0114] The communication module 9110 is a transmitter / receiver that sends and receives signals via the antenna 9111. The communication module 9110 is coupled to the central processing unit 9100 to provide input signals and receive output signals, which is the same as in a conventional mobile communication terminal.

[0115] Based on different communication technologies, multiple communication modules 9110 can be configured in the same electronic device, such as cellular network modules, Bluetooth modules, and / or wireless LAN modules. The communication module 9110 is also coupled to a speaker 9131 and a microphone 9132 via an audio processor 9130 to provide audio output via the speaker 9131 and receive audio input from the microphone 9132, thereby realizing typical telecommunications functions. The audio processor 9130 may include any suitable buffer, decoder, amplifier, etc. Furthermore, the audio processor 9130 is also coupled to a central processing unit 9100, enabling on-device recording via the microphone 9132 and on-device playback of stored sound via the speaker 9131.

[0116] Embodiments of this application also provide a computer-readable storage medium capable of implementing all steps of the data-collaborative real-time pig grading method with a server or client as the execution subject in the above embodiments. The computer-readable storage medium stores a computer program that, when executed by a processor, implements all steps of the data-collaborative real-time pig grading method with a server or client as the execution subject in the above embodiments. For example, when the processor executes the computer program, it implements the following steps: Step S101: Install a gantry-type adjustable bracket directly above the pig passage. A depth camera and an RGB camera are coaxially fixed on the bracket. An inlet flow-limiting gate and an outlet anti-backflow gate are respectively set at both ends of the pig passage to control the orderly passage of pigs one by one. The depth camera collects three-dimensional point cloud data of pigs based on time-of-flight technology. Step S102: When a pig enters the channel and triggers the photoelectric sensor, the depth camera and RGB camera are started simultaneously to determine the corresponding depth image and RGB image respectively. After the depth image and RGB image are transmitted synchronously in time through a preset dual transmission channel, the depth image and RGB image are preprocessed to determine the corresponding preprocessed depth image data and preprocessed RGB image data respectively. Step S103: Input the depth image data into a set weight inference convolutional neural network and output the predicted weight of the pig; input the RGB image data into a set body shape inference convolutional neural network and output the probability distribution of the pig body shape level. The weight inference convolutional neural network is a network structure improved based on a three-dimensional point cloud neural network, including a sampling layer, a grouping layer and a feature aggregation layer; the body shape inference convolutional neural network is an improved deep convolutional neural network that introduces an attention mechanism. Step S104: Post-process the predicted pig weight and the probability distribution of pig body size grades, and map the post-processed pig weight and pig body size grades to a preset grade comparison table to determine the corresponding comprehensive pig grade. Compare the comprehensive pig grade with the current customer order requirements to determine the corresponding pig grade judgment result. Display the grade judgment result through a display device, and control the pig pensing based on the grade judgment result.

[0117] As described above, the computer-readable storage medium provided in this application embodiment, through a coaxial depth camera and an RGB camera installed above the channel, simultaneously acquires depth and color images as pigs pass by. The preprocessed depth image is input into an improved PointNet++ network for weight feature extraction and inference to obtain a weight estimate. Simultaneously, the preprocessed RGB image region is input into an improved ResNet50 network with an attention mechanism for body size classification, outputting a body size probability distribution. The weight estimate is linearly calibrated based on historical measured data, and the final body size category is determined by combining the body size probability. The calibrated weight and the determined body size level are mapped to a preset pig level table to generate a comprehensive pig level and control pig penning. This improves the efficiency and accuracy of pig level determination.

[0118] Embodiments of this application also provide a computer program product capable of implementing all steps in the data-cooperative real-time pig grading method with the execution subject being a server or client in the above embodiments. When executed by a processor, this computer program / instruction implements the steps of the data-cooperative real-time pig grading method. For example, the computer program / instruction implements the following steps: Step S101: Install a gantry-type adjustable bracket directly above the pig passage. A depth camera and an RGB camera are coaxially fixed on the bracket. An inlet flow-limiting gate and an outlet anti-backflow gate are respectively set at both ends of the pig passage to control the orderly passage of pigs one by one. The depth camera collects three-dimensional point cloud data of pigs based on time-of-flight technology. Step S102: When a pig enters the channel and triggers the photoelectric sensor, the depth camera and RGB camera are started simultaneously to determine the corresponding depth image and RGB image respectively. After the depth image and RGB image are transmitted synchronously in time through a preset dual transmission channel, the depth image and RGB image are preprocessed to determine the corresponding preprocessed depth image data and preprocessed RGB image data respectively. Step S103: Input the depth image data into a set weight inference convolutional neural network and output the predicted weight of the pig; input the RGB image data into a set body shape inference convolutional neural network and output the probability distribution of the pig body shape level. The weight inference convolutional neural network is a network structure improved based on a three-dimensional point cloud neural network, including a sampling layer, a grouping layer and a feature aggregation layer; the body shape inference convolutional neural network is an improved deep convolutional neural network that introduces an attention mechanism. Step S104: Post-process the predicted pig weight and the probability distribution of pig body size grades, and map the post-processed pig weight and pig body size grades to a preset grade comparison table to determine the corresponding comprehensive pig grade. Compare the comprehensive pig grade with the current customer order requirements to determine the corresponding pig grade judgment result. Display the grade judgment result through a display device, and control the pig pensing based on the grade judgment result.

[0119] As described above, the computer program product provided in this application embodiment uses a coaxial depth camera and an RGB camera installed above the passage to simultaneously acquire depth and color images as pigs pass by. The preprocessed depth image is input into an improved PointNet++ network for weight feature extraction and inference to obtain a weight estimate. Simultaneously, the preprocessed RGB image region is input into an improved ResNet50 network with an attention mechanism to perform body size classification, output body size probability distribution, linearly calibrate the weight estimate based on historical measured data, and determine the final body size category by combining the body size probability. The calibrated weight and the determined body size level are mapped to a preset pig level table to generate a comprehensive pig level and control pig penning, thereby improving the efficiency and accuracy of pig level determination.

[0120] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0121] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (devices), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0122] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0123] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0124] Specific embodiments have been used to illustrate the principles and implementation methods of this invention. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of this invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this invention. Therefore, the content of this specification should not be construed as a limitation of this invention.

Claims

1. A method for real-time determination of pig grades based on data collaboration, characterized in that, The method includes: A gantry-type adjustable bracket is installed directly above the pig passage. A depth camera and an RGB camera are coaxially fixed on the bracket. An inlet flow-limiting gate and an outlet anti-backflow gate are respectively set at both ends of the pig passage to control the orderly passage of pigs one by one. The depth camera collects three-dimensional point cloud data of the pigs based on time-of-flight technology. When a pig enters the channel and triggers the photoelectric sensor, the depth camera and RGB camera are simultaneously activated to determine the corresponding depth image and RGB image, respectively. After the depth image and RGB image are transmitted synchronously through a preset dual transmission channel, image preprocessing is performed on the depth image and RGB image to determine the corresponding preprocessed depth image data and preprocessed RGB image data, respectively. The depth image data is input into a weight inference convolutional neural network, which outputs a predicted weight value for pigs. The RGB image data is input into a body shape inference convolutional neural network, which outputs a probability distribution of pig body shape levels. The weight inference convolutional neural network is a network structure improved based on a 3D point cloud neural network, including a sampling layer, a grouping layer, and a feature aggregation layer. The body shape inference convolutional neural network is an improved deep convolutional neural network that introduces an attention mechanism. The predicted weight of the pigs and the probability distribution of the pig body size grades are post-processed, and the post-processed pig weight values ​​and pig body size grades are mapped to a preset grade comparison table to determine the corresponding comprehensive pig grade. The comprehensive pig grade is compared with the current customer order requirements to determine the corresponding pig grade judgment result. The grade judgment result is displayed through a display device, and pig pen control is performed based on the grade judgment result.

2. The method for real-time pig grade determination based on data collaboration according to claim 1, characterized in that, The method of installing a gantry-type adjustable bracket directly above the pig passage, with a depth camera and an RGB camera coaxially fixed on the bracket, includes: The adjustable gantry frame is 2.5-3.0m above the ground to ensure that the entire live pig is within the field of view for collection. The depth camera uses time-of-flight technology, has a resolution of no less than 640×480 pixels, a depth measurement range of 0.5-5 meters, a depth error of no more than ±2%, and a frame rate of no less than 90fps, and is used to collect three-dimensional point cloud data of live pigs. The RGB camera has a resolution of no less than 1920×1080 pixels, a color reproduction rate of no less than 95%, a frame rate of no less than 30fps, and a lens focal length of 16-25mm. It is used to capture RGB color images of live pigs.

3. The method for real-time pig grade determination based on data collaboration according to claim 1, characterized in that, The step of transmitting the depth image and the RGB image in time synchronization via a preset dual transmission channel includes: A dual transmission channel is constructed based on Ethernet and USB interfaces, with a transmission delay of ≤50ms, to ensure time synchronization of data between the two modes. The depth image is transmitted via Gigabit Ethernet, the RGB image is transmitted via USB 3.0 interface, and the acquisition and transmission time are synchronized through hardware timestamps.

4. The method for real-time pig grade determination based on data collaboration according to claim 1, characterized in that, The step of performing image preprocessing on the depth image and the RGB image to determine the corresponding preprocessed depth image data and preprocessed RGB image data includes: The depth image is subjected to median filtering and background subtraction to determine the corresponding pig area depth mask, and the pixels within the depth mask are converted into a 3D point cloud according to the camera intrinsic parameters to determine the corresponding preprocessed depth image data. The RGB image is color-corrected, and the coordinate alignment relationship between the RGB image and the depth image is used to extract the RGB sub-image corresponding to the depth mask region, thereby determining the corresponding preprocessed RGB image data.

5. The method for real-time pig grade determination based on data collaboration according to claim 1, characterized in that, Before inputting the depth image data into the weighted inference convolutional neural network, the process includes: A weighted inference convolutional neural network is constructed based on the improved PointNet++ network. The improved PointNet++ network includes 3 sampling layers, 3 grouping layers, and 3 feature aggregation layers. Each sampling layer uses the farthest point sampling algorithm, and the three sampling layers sample 1024, 256, and 64 core points respectively to preserve the key point features of the three-dimensional contour of the live pig; Each of the three grouping layers adopts the ball query algorithm. The three grouping layers determine the corresponding local neighborhood point set with the core point as the center. The search radii of the three grouping layers are 0.3m, 0.2m and 0.1m respectively. Each of the feature aggregation layers includes two 1×1 convolutional kernels, a BatchNorm layer, and a ReLU activation function, used to extract local three-dimensional features based on the local neighborhood point set and aggregate them into a global feature vector, the global feature vector representing the overall three-dimensional morphology of the pig; The weight inference convolutional neural network further includes a deep image inference output layer, which contains two fully connected layers that receive the global feature vector according to the Sigmoid activation function and output the corresponding predicted weight value of the pig.

6. The method for real-time pig grade determination based on data collaboration according to claim 1, characterized in that, Before inputting the RGB image data into the set body shape inference convolutional neural network, the following steps are included: Construct a body shape inference convolutional neural network based on the input layer, feature extraction network, convolutional layer, and RGB image inference output layer; The feature extraction network adopts an improved ResNet50 network, which is obtained by replacing the first 3 convolutional kernels of the original ResNet50 network structure with preset 3×3 small convolutional kernels. The convolutional layer includes 5 convolutional blocks. After the 4th convolutional block of the convolutional layer, a CBAM attention module is embedded. The CBAM attention module includes a channel attention submodule and a spatial attention submodule, which are used to weight the channel dimension and spatial dimension of the pig feature map to determine the corresponding key features of pig body shape. The RGB image inference output layer includes a fully connected layer that receives the key features of the pig's body size according to the Softmax activation function and outputs the corresponding probability distribution of the pig's body size level.

7. The method for real-time pig grade determination based on data collaboration according to claim 1, characterized in that, The post-processing of the predicted pig weight and the probability distribution of pig body size grades includes: Based on historical measured weight data, the predicted weight of the pigs is calibrated using a linear regression model to determine the corresponding pig weight value. Select the grade with the highest probability from the probability distribution of pig size grades to determine the corresponding pig size grade.

8. A real-time pig grading device based on data collaboration, characterized in that, The device includes: The pig passage layout module is used to install a gantry-type adjustable bracket directly above the pig passage. A depth camera and an RGB camera are coaxially fixed on the bracket. An inlet flow-limiting gate and an outlet anti-backflow gate are respectively provided at both ends of the pig passage to control the orderly passage of pigs one by one. The depth camera collects three-dimensional point cloud data of pigs based on time-of-flight technology. The dual-modal acquisition module is used to simultaneously start the depth camera and RGB camera when a pig enters the channel and triggers the photoelectric sensor, and determine the corresponding depth image and RGB image respectively. After transmitting the depth image and the RGB image in time synchronization through a preset dual transmission channel, the depth image and the RGB image are preprocessed to determine the corresponding preprocessed depth image data and preprocessed RGB image data respectively. The pig weight and body shape prediction module is used to input the depth image data into a set weight inference convolutional neural network and output the predicted weight of the pig; and to input the RGB image data into a set body shape inference convolutional neural network and output the probability distribution of the pig body shape level. The weight inference convolutional neural network is a network structure improved based on a three-dimensional point cloud neural network, including a sampling layer, a grouping layer and a feature aggregation layer. The body shape inference convolutional neural network is an improved deep convolutional neural network that introduces an attention mechanism. The pig grading module is used to post-process the predicted pig weight and the probability distribution of pig body size grades, map the post-processed pig weight and body size grades to a preset grading comparison table, determine the corresponding comprehensive pig grade, compare the comprehensive pig grade with the current customer order requirements, determine the corresponding pig grading result, display the grading result through a display device, and control pig pensing based on the grading result.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the real-time pig grade determination method based on data collaboration as described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the real-time pig grading method based on data collaboration as described in any one of claims 1 to 7.