Pig weighing and abnormal data detection device and method
By integrating camera and image algorithms on the pig weighing device, combining weighing sensors and LORA modules, the interference problem in pig weight measurement is solved, high-precision automated weight measurement is achieved, reducing manpower investment and providing reliable data support.
Patent Information
- Application Number
- CN202411970567.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-18
AI Technical Summary
When pigs are automatically measured in semi-open measurement equipment, other pigs may enter the measurement area, interfering with the pigs being weighed and affecting the accuracy and consistency of the data.
A pig weighing and abnormal data detection device is designed, including a pig weighing device and a camera. Using a combination of weighing sensors and image algorithms, automated data acquisition and abnormal detection are realized through MCU and LORA modules.
It realizes high-precision and high-stability contactless automated weight measurement in a semi-open environment, reduces manpower investment, ensures high frequency and stable progress of weighing operations, and provides reliable data support for breeding management.
Smart Images

Figure CN119845393A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a pig weighing and abnormal data detection device and method. Background Art
[0002] The weight information of pigs is a key feature that reflects their nutrition and growth and development level, feeding management, health status and even genetic traits. In semi-open pig measurement equipment, since the environment is not completely closed, other pigs may enter the measurement area when the pig weight is automatically measured, interfering with the pigs being weighed, thus affecting the accuracy and consistency of the data. If pigs are manually driven into the equipment, the investment in manpower and management will also increase accordingly. Summary of the invention
[0003] The purpose of the present invention is to provide a pig weighing and abnormal data detection device and method, which is used to solve the problem that when the pig weight is automatically measured, other pigs may enter the measurement area and interfere with the pigs being weighed, thereby affecting the accuracy and consistency of the data.
[0004] In order to solve the above problems, the technical solution of the present invention is: A pig weighing and abnormal data detection device comprises a pig weighing device, a camera is arranged above the pig weighing device, the camera is connected to a computer, the pig weighing device has a weighing sensor and a control box, an ADC acquisition circuit, an MCU and a communication module are arranged in the control box, the ADC acquisition circuit acquires the signal transmitted by the weighing sensor, the ADC acquisition circuit transmits the signal to the MCU, the MCU processes the signal and transmits it to the computer through the communication module.
[0005] The communication module is a LORA module.
[0006] The pig weighing device is a semi-open pig performance measurement station, which has an RFID antenna. The RFID antenna reads the pig's ear tag information and sends it to the MCU.
[0007] A method for a pig weighing and abnormal data detection device comprises the following steps: S1: The weighing sensor continuously detects the weight on the weighing fence of the measuring station. When the weighing sensor detects that the weight of the weighing fence is greater than the preset threshold value for multiple consecutive times, it is determined that the pig has entered the station; S2: If it is determined that the sow has entered the station, the weighing operation is started, and at the same time, the MCU sends a signal to the computer through the communication module to start automatic collection. After the camera receives the signal, it records the video of the pig and starts real-time calculation and processing of image data; S3: During the data collection process, when the computer detects an abnormality, it transmits a signal to the MCU through the communication module. The MCU determines whether the intruding object has interfered with the measurement based on the range of the collected data. If it is greater than the set threshold, the weighing value is marked as abnormal, and the data after the abnormality is discarded according to the time when the abnormality occurs and the sampling rate. If the range does not exceed the threshold, it is a misjudgment or the intruding pig has not entered the measuring station to interfere with the weighing; S4: After weighing, a stop detection signal is sent to the camera, and the RFID antenna of the measuring station identifies the pig and saves the corresponding pig's weight data. After the pig leaves the station, its feed intake is calculated and the weighing sensor is cleared.
[0008] In step S2, the method for computer processing image data includes the following steps: the camera acquires the image and extracts the target area, the background subtractor is applied to extract the foreground and the image is converted into the HSV color space, and then the color mask is extracted based on the specified color range, the color mask is compared with the foreground for difference, and a set threshold is used to determine whether there is foreign matter intrusion. If the set threshold is exceeded, it is determined that there may be an abnormality, and an abnormality signal is sent to the measurement station.
[0009] The beneficial effects of the present invention are: 1. In terms of reducing manpower and management costs, the present invention, which is deeply integrated into the feeding equipment, cleverly uses the daily feeding behavior of pigs to achieve automatic weighing, and completely abandons the cumbersome process of manually driving pigs into the weighing equipment. This innovative design greatly reduces manpower input, ensures the high frequency and stability of weighing operations, lays a solid data foundation for the analysis of breeding big data, and effectively promotes the intelligent and efficient breeding management.
[0010] 2. The present invention integrates image algorithm detection with the range analysis technology of sensor weighing sampling data. In the image algorithm, the camera accurately extracts the target area after acquiring the image, and uses advanced background subtraction and HSV color space conversion technology, combined with a specific color range to extract the color mask, and contrasts it with the foreground to keenly capture signs of foreign body invasion; the range analysis of sensor data strictly judges the interference situation from the level of numerical change characteristics. The two work closely together and confirm each other, successfully overcoming the problem that pigs are easily disturbed and cause data anomalies when weighed in a semi-open environment, and realizing high-precision, high-stability non-contact automatic weight measurement, providing reliable data support for precise breeding decisions.
[0011] 3. The advantages of using LORA modules as a wireless communication method are obvious. On the one hand, it effectively avoids the risk of equipment failure caused by long-line connection to computers (such as USB connection, which is easily loosened by pigs); on the other hand, with its excellent networking capabilities, it can easily achieve multi-machine communication, greatly enhancing the scalability of the system. A computer can efficiently connect to multiple measurement stations / cameras, provide powerful computing power support for multiple measurement stations, significantly reduce equipment costs and management complexity, and improve the scale benefits of breeding management. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The present invention will be further described below in conjunction with the accompanying drawings: Figure 1 is a schematic diagram of the three-dimensional structure of the present invention, Figure 2 It is the weighing flow chart of the present invention, Figure 3 This is a flowchart of the image algorithm of the present invention. Figure 4 This is a data diagram of the abnormal weighing result process of the present invention. Figure 5 This is a data diagram of the normal weighing result process of the present invention. Figure 6 It is a schematic diagram of the connection between the modules of the present invention.
[0013] In the figure: camera 1, pig weighing device 2, weighing sensor 3, RFID antenna 4, control box 5. DETAILED DESCRIPTION
[0014] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0015] A pig weighing and abnormal data detection device comprises a pig weighing device 2, wherein the pig weighing device 2 selects a semi-open pig performance measurement station, a camera 1 is arranged above the pig weighing device 2, the camera 1 is 1.97m away from the ground, and its field of view can accommodate inbound breeding pigs to record their behaviors in the station, the camera 1 is connected to a computer, the pig weighing device 2 comprises an RFID antenna 4, a weighing sensor 3 and a control box 5, wherein an ADC acquisition circuit, an MCU and a communication module are arranged in the control box 5, the ADC acquisition circuit acquires signals transmitted from the weighing sensor 3, and the ADC acquisition circuit transmits the signals to the MCU, the RFID antenna 4 reads the pig's ear tag information and sends it to the MCU, and the MCU processes the signals and transmits them to the computer through the communication module, the MCU is an STM32 single-chip microcomputer, and the camera 1 selects an Intel Realsense D435 camera 1.
[0016] The ADC acquisition circuit includes a filter circuit, an amplifier circuit, and an ADC measurement circuit of the weighing sensor 3. The working process is as follows: the output signal of the weighing sensor 3 is first low-pass filtered to eliminate high-frequency interference, and then amplified and collected by the ADC. The MCU obtains the voltage value collected by the ADC through the IIC communication protocol and performs software filtering and conversion to obtain the weighing data, i.e., the weight of the pig.
[0017] The computer acquires and processes the image data of camera 1 in real time. If it is determined that there are other pigs around, it will send information to the corresponding measurement station through the LORA module. The information contains a timestamp, which is convenient for the measurement station to filter data according to time and eliminate data from the interference period. Here, setting the communication module to the LORA module has the following two advantages: first, it can avoid long-line connection. If the computer needs to use USB, the long-line connection is easy to loosen and be knocked loose by the pig. Second, it can form a LORA network to avoid too many connections. One computer can connect to multiple measurement stations / cameras 1. The LORA module connected to the computer is used as the main node. In this way, one computer can obtain data from multiple cameras 1 and provide calculations for multiple measurement stations.
[0018] RFID identification: When the weight measurement is completed, the MCU will open the trough of the pig performance measurement station. When the pig approaches the RFID antenna 4 installed on the upper end of the trough, the RFID antenna 4 will automatically read the pig's ear tag and send it to the MCU through serial communication to determine the pig's identity information.
[0019] A method for a pig weighing and abnormal data detection device comprises the following steps: S1: The sow entry signal is an electrical signal transmitted by the weight sensor at the weighing end, and its threshold is set to 15kg. When the weighing sensor 3 detects that the weight on the weighing fence is greater than the threshold for three consecutive times, it is determined that the sow has entered the station, and then it is determined that the pig has entered the station; S2: If it is determined that the sow has entered the station, the weighing operation is started, and at the same time, the MCU sends a signal to the computer through the communication module to start automatic collection. After the camera 1 receives the signal, it records the video of the pig at a speed of 15 frames per second and starts real-time calculation and processing of image data; S3: During the data collection process, when the computer detects an abnormality, it transmits a signal to the MCU of the measuring station through the LORA module. The MCU determines whether the intruding object has interfered with the measurement based on the range of the collected data. If it is greater than the set threshold, the weighing value is marked as abnormal, and the data after the abnormality is discarded according to the time when the abnormality occurs and the sampling rate. If the range does not exceed the threshold, it is a misjudgment or the intruding pig has not entered the measuring station to interfere with the weighing; S4: After weighing is completed, a signal to stop detection is sent to the camera 1, and the RFID antenna 4 of the measuring station identifies the pig and saves the corresponding pig's weight data. After the pig leaves the station, its feed intake is calculated and the weighing sensor 3 is cleared.
[0020] In step S2, the method for computer processing image data includes camera 1 acquiring an image and extracting a target area, applying a background subtractor to extract a foreground and converting the image into an HSV color space, and then extracting a color mask based on a specified color range, subtracting the color mask from the foreground, and judging whether there is foreign matter intrusion based on a set threshold. If the set threshold is exceeded, it is judged that there may be an abnormality, and an abnormality signal is sent to the measurement station.
[0021] The present invention uses the MOG2 Gaussian mixture model in OpenCV for background modeling and foreground extraction. MOG2 uses pixel historical data to establish multiple Gaussian distribution probability models, automatically updates the background and extracts the foreground. By adjusting the historical frame number and threshold parameters, MOG2 enhances the adaptability of background modeling and the sensitivity of foreground extraction, and improves the detection accuracy. The formula is as follows: For a given pixel x t , its probability distribution can be expressed as a multi-peak Gaussian mixture model:
[0022] Where K represents the number of Gaussian distributions used, w i,t is the weight of the i-th Gaussian distribution, satisfying N(x t |μ i,t ,∑ i,t ) is the normal distribution function with mean μ i,t and the covariance matrix ∑ i,t .
[0023] When the camera shakes slightly, MOG2 can adaptively update the background model. To further extract the foreground area, the model calculates the grayscale histogram of the foreground mask, estimates the foreground pixel distribution based on the maximum value, and dynamically adjusts the threshold. Through the binarization operation, the foreground mask is converted into a binary image to prepare for subsequent processing.
[0024] Changes in ambient light sources and the activities of surrounding pigs can easily cause shadows in the ROI area to move, which is often misjudged as the foreground. In the RGB color space, changes in the brightness of the shadows cause fluctuations in the grayscale values of the three channels, making it difficult to accurately detect by grayscale differences. Based on the principle of color constancy, the HSV color space can effectively reduce the interference of brightness changes on shadow detection by separating hue, saturation, and brightness. Its separation characteristics have significant advantages in target recognition in complex scenes. The conversion model of the HSV space is as follows: V = max (R, G, B)
[0025]
[0026]
[0027] In the formula, R, G, B are the original red, green, and blue values, respectively; H, S, and V are the converted images of hue, saturation, and brightness components, respectively. The model converts the ROI frame from RGB to HSV color space, uses its brightness-sensitive characteristics to generate a color mask, and combines it with the foreground mask to enhance target area detection.
[0028] During the test, in order to analyze the interference signal, the original process data of each weighing data before taking the average is stored in the SD card. By comparing the weighing data under normal and abnormal conditions, it can be found that under normal circumstances, the signal collected by the weighing sensor 3 is relatively stable. Although there is transient noise, it has limited impact on the weighing result. However, when there is interference, the movement frequency of the pigs in the measuring station increases significantly, resulting in large fluctuations in the sensor signal, significant differences in the extreme values of the process data, and continuous high-frequency changes within a specific time window. The range statistics of the weighing result process data under normal conditions and the process data under abnormal conditions are respectively performed, and the results are shown in the following table.
[0029] Process data range statistics results
[0030] The average range of normal weighing process data in pig house No. 1 is 7.45, and the average range of abnormal weighing process data is 37.76; the average range of normal weighing process data in pig house No. 2 is 9.62, and the average range of abnormal weighing process data is 37.24. It can be judged that the range of abnormal value process data is significantly different from the normal result, so the range of the data in the weighing process can be used as a criterion for judging whether there is interference in weighing, and the threshold is selected as twice the average range of the normal weighing process data.
[0031] The contents described in the embodiments of this specification are merely an enumeration of the implementation forms of the inventive concept. The protection scope of the present invention should not be regarded as limited to the specific forms described in the embodiments. The protection scope of the present invention also extends to equivalent technical means that can be conceived by those skilled in the art based on the inventive concept.
Claims
1. A pig weighing and abnormal data detection device, characterized in that: The invention comprises a pig weighing device (2), wherein a camera (1) is arranged above the pig weighing device (2), and the camera (1) is connected to a computer. The pig weighing device (2) comprises a weighing sensor (3) and a control box (5), and an ADC acquisition circuit, an MCU and a communication module are arranged in the control box (5). The ADC acquisition circuit acquires a signal transmitted from the weighing sensor (3), and the ADC acquisition circuit transmits the signal to the MCU. The MCU processes the signal and transmits the signal to the computer through the communication module.
2. A pig weighing and abnormal data detection device according to claim 1, characterized in that: The communication module is a LORA module.
3. A pig weighing and abnormal data detection device according to claim 1 or 2, characterized in that: The pig weighing device (2) is a semi-open pig performance measurement station, which has an RFID antenna (4). The RFID antenna (4) reads the pig's ear tag information and sends it to the MCU.
4. A method for using the pig weighing and abnormal data detection device according to claim 3, characterized in that: The steps include: S1: The weighing sensor (3) continuously detects the weight on the weighing fence of the measuring station. When the weighing sensor detects that the weight of the weighing fence is greater than a preset threshold value for multiple consecutive times, it is determined that the pig has entered the station; S2: If it is determined that the sow has entered the station, the weighing operation is started, and at the same time, the MCU sends a signal to the computer through the communication module to start automatic collection. After the camera (1) receives the signal, it records the video of the pig and starts real-time calculation and processing of image data; S3: During the data collection process, when the computer detects an abnormality, it transmits a signal to the MCU through the communication module. The MCU determines whether the intruding object has interfered with the measurement based on the range of the collected data. If it is greater than the set threshold, the weighing value is marked as abnormal, and the data after the abnormality is discarded according to the time when the abnormality occurs and the sampling rate. If the range does not exceed the threshold, it is a misjudgment or the intruding pig has not entered the measuring station to interfere with the weighing; S4: After weighing is completed, a stop detection signal is sent to the camera (1), and the RFID antenna (4) of the measuring station identifies the pig and saves the corresponding pig's weight data. After the pig leaves the station, its feed intake is calculated and the weighing sensor (3) is reset.
5. A method for weighing pigs and detecting abnormal data according to claim 4, characterized in that: In step S2, the method for computer processing image data includes the following steps: the camera (1) acquires an image and extracts a target area, a background subtractor is applied to extract a foreground and the image is converted into an HSV color space, a color mask is then extracted based on a specified color range, the color mask is compared with the foreground for subtraction, and a predetermined threshold is used to determine whether there is foreign matter intrusion; if the threshold is exceeded, it is determined that an abnormality may exist, and an abnormality signal is sent to a measuring station.