Search

CN-115311546-B - Stock pig counting method and system

CN115311546BCN 115311546 BCN115311546 BCN 115311546BCN-115311546-B

Abstract

The invention discloses a method and a system for counting stock pigs, which belong to the technical field of pig breeding and comprise the following steps of S1, image acquisition, S2, image cutting, S3, algorithm processing and S4, information integration. According to the invention, the rotating target detection network and the semantic segmentation network are combined for use, so that the data volume of the stock pigs can be conveniently counted under the condition that the pigs are crowded, the calculation cost is reduced, the counting efficiency is improved, the user experience is improved, the problems that the counting accuracy is low under the condition that the pigs are crowded in the traditional target detection algorithm, the situation that the pigs are crowded can be better processed by the example segmentation algorithm, but the calculation cost is high, the time is long, and the data marking cost is extremely high are solved, and the method is worthy of popularization and use.

Inventors

  • LIU QINGYUAN
  • FANG YAMEI

Assignees

  • 青岛不愁网信息科技有限公司

Dates

Publication Date
20260505
Application Date
20220413

Claims (4)

  1. 1. The method for counting the stock pigs is characterized by comprising the following steps of: S1, acquiring an image Connecting a camera with a terminal, acquiring a video stream through the terminal, capturing data shot by the camera, and converting the data into RGB images, namely, images of pigs in stock, wherein the images comprise pigs and fences; S2, image clipping Cutting the RGB image into a set size, uploading the set size to an OSS server, and simultaneously transmitting an OSS address of the image to a cloud server; S3, algorithm processing The cloud server calls a rotation target detection algorithm and an image semantic segmentation algorithm service at the same time, the rotation target detection algorithm carries out rotation target detection processing on the images in the step S2 through a rotation target detection network to obtain the quantity and position information of pigs, and the image semantic segmentation algorithm carries out semantic segmentation processing on the images in the step S2 through a semantic segmentation network to obtain the boundary position information of a fence; s4, information integration Integrating the pig number and the position information obtained in the step S3 with the position information of the fence boundary, calculating the pig number in the fence area divided by the captured image, transmitting the result back to the terminal, and displaying the result to the user; In the step S3, the rotating target detection network includes a first backup module, a Neck module, and a head module, where the backup module is a Swin transform feature extraction frame for extracting features of an image, the Neck module is PANet for aggregating features of different layers, and the head module is a head module added with rotation angle information in a yolov model for making the target detection frame fit with a pig outline; in the rotating target detection network, the image is processed by a first backup module to obtain the characteristic information of the input image, and the characteristic information is processed by a Neck module to extract and fuse the characteristic obtained by the first backup module; after the rotation target detection network processing, performing soft-nms processing on an output result; in the step S3, the semantic segmentation network includes a second backup module, a semantic segmentation feature head module, and a semantic segmentation detection head module, where the second backup module is a Swin transform feature extraction framework, and is used for extracting features of an image, the semantic segmentation feature head module is Uperhead and is used for segmenting features of a pig fence area, the semantic segmentation detection head module is FCNHead and is used for performing pixel-by-pixel reduction on deep features extracted by the second backup module, so as to obtain a complete pig fence area; In the semantic segmentation network, the image is processed by a second background module to obtain a feature map of the input image, the obtained feature information is extracted and combined after being processed by a semantic segmentation feature head module, and the feature extracted by the semantic segmentation feature head module is used for obtaining the position information of a segmentation area of a prediction target after being processed by a semantic segmentation detection head module; After the semantic segmentation network processing, an envelope algorithm is used for the segmented pig fence area, so that a polygonal area with neat edges and position information thereof, namely fence and house boundaries and position information thereof, are obtained.
  2. 2. The method for counting pigs in stock according to claim 1, wherein in the step S1, the camera is an ultra-wide-angle external camera, the terminal is a mobile phone, the ultra-wide-angle external camera and the mobile phone are connected in a wireless or wired mode, and the camera lens data are captured through a UVC protocol and converted into RGB images.
  3. 3. The method of claim 1, wherein in step S3, the image after clipping is preprocessed before the rotation target detection and the semantic segmentation, so as to obtain image data required by the rotation target detection network and the semantic segmentation network, respectively, wherein the preprocessing method comprises resize, letterboxing, adaptive white balance and histogram equalization.
  4. 4. A stock pig counting system, characterized in that the stock pigs are counted by the counting method according to any one of claims 1-3, comprising: the image acquisition module is used for connecting the terminal by utilizing the camera, acquiring a video stream through the terminal, capturing data shot by the camera and converting the data into RGB images; The image clipping module is used for clipping the RGB image into a set size and uploading the set size to the OSS server, and simultaneously transmitting the OSS address of the image to the cloud server; The algorithm processing module is used for simultaneously calling a rotation target detection algorithm and an image semantic segmentation algorithm service through the cloud server, wherein the rotation target detection algorithm carries out rotation target detection processing on the images in the step S2 through a rotation target detection network to obtain the number and position information of pigs; The information integration module is used for integrating the pig quantity and the position information acquired in the step S3 with the position information of the fence boundary, calculating the pig quantity in the fence area divided by the captured image, transmitting the result back to the terminal and displaying the result to the user; the control processing module is used for sending instructions to other modules to complete corresponding actions; the image acquisition module, the image cutting module, the algorithm processing module and the information integration module are all in communication connection with the control processing module.

Description

Stock pig counting method and system Technical Field The invention relates to the technical field of pig breeding, in particular to a method and a system for counting stock pigs. Background The pig industry is an important industry in our agriculture. The method has an important effect on guaranteeing the safe supply of meat foods, the pig industry in China is changed from the traditional pig industry to the modern pig industry, and the cultivation mode, the regional layout, the production mode and the production capacity are all obviously changed. In the breeding process, pigs are often required to be counted, the existing counting mode mainly comprises manual counting, ear tag counting, photographing through a fixed camera and the like, and the manual counting mode has the problems that the pigs are easy to leak and most of the counting, the counting efficiency is low, the counting mode also has certain defects such as the need of a radio frequency ear tag, high cost and easy falling off due to the fact that the induction can be performed only in a very short distance (within half a meter), the counting equipment is required to be very close to each pig, the counting in a large column is extremely troublesome, and the problem of low counting repetition efficiency caused by the movement of the pigs is also difficult to solve. The problem of traditional counting by shooting through a fixed camera is mainly that the camera needs to be fixedly installed, the installation difficulty is high, the cost is high, at least 20-40 cameras need to be installed for one farmer, when a picture of a stock pig is acquired, a traditional target detection algorithm or an example segmentation algorithm is adopted for processing, the traditional target detection algorithm has low counting accuracy under the condition that the pig is crowded, the example segmentation algorithm can better process the crowded condition of the pig, but the calculation cost is high, the time is long, and the data marking cost is extremely high. The above problems need to be solved, and therefore, a method for counting pigs in stock is provided. Disclosure of Invention The invention aims to solve the technical problems that the counting accuracy is low under the condition that pigs are crowded in the traditional target detection algorithm, and the example segmentation algorithm can better treat the condition that the pigs are crowded, but has high calculation cost, long time and extremely high data marking cost. The invention solves the technical problems through the following technical proposal, and the invention comprises the following steps: S1, acquiring an image Connecting a camera with a terminal, acquiring a video stream through the terminal, capturing data shot by the camera, and converting the data into RGB images, namely, images of pigs in stock, wherein the images comprise pigs and fences; S2, image clipping Cutting the RGB image into a set size, uploading the set size to an OSS server, and simultaneously transmitting an OSS address of the image to a cloud server; S3, algorithm processing The cloud server calls a rotation target detection algorithm and an image semantic segmentation algorithm service at the same time, the rotation target detection algorithm carries out rotation target detection processing on the images in the step S2 through a rotation target detection network to obtain the quantity and position information of pigs, and the image semantic segmentation algorithm carries out semantic segmentation processing on the images in the step S2 through a semantic segmentation network to obtain the boundary position information of a fence; s4, information integration And (3) integrating the pig number and the position information obtained in the step (S3) with the position information of the fence boundary, calculating the pig number in the fence area divided by the captured image, transmitting the result back to the terminal, and displaying the result to the user. Further, in the step S1, the camera is an ultra-wide angle external camera, the terminal is a mobile phone, and the connection mode between the ultra-wide angle external camera and the mobile phone is wireless connection or wired connection. Still further, in the step S1, capturing the camera lens data by UVC protocol is converted into RGB image. Further, in the step S3, the cut image is preprocessed before the rotation target detection process and the semantic segmentation process, so as to obtain image data required by the rotation target detection network and the semantic segmentation network, wherein the preprocessing method includes resize, letterboxing, adaptive white balance and histogram balance. Still further, in the step S3, the rotating target detection network includes a first backup module, a Neck module, and a head module, where the backup module is a Swin Transformer feature extraction frame for extracting features of an image, the Neck module is PANet for a