Abstract:For contactless measurement of pig body dimension andimprovement of pig welfare in the real farm, a pig body dimension detection system was developed based on machine vision technology. An algorithm based on depth image was initiated to obtain pig’s contour, because color or gray image are easily affected by various light and dirty on pig body. Firstly, two top view images were captured for each pig by using a stereo vision system. Depth image was obtained through stereo image matching. Depth background subtraction algorithm was used to get pig height data, and pig contour was calculated through binary height image. Then a corner extraction algorithm based on concave structure was optimized and simplified to extract four pig head and tail cut points. Then eight pig body dimension measurement key points were calculated, finally five body dimensions including body length, body width, body height, hip width and hip height were detected. Automatic software was developed which combines the algorithm above based on LabVIEW development environment. Threedimensional detection accuracy of the system was verified by using calibration board in lab, the relative error of detection were less than 1% within 2m object distance and view center region has the minimum error. Then the system was installed in a commercial farm for verification. 32 Landrace pigs’ body dimensions were measured three times manually and then the system snapped pig`s image for estimation. Each pig`s five body dimensions were detected three times. The result showed the detected values of body dimension had relative error of 2%, and absolute error of less than 2cm. The pig body detection system based on depth image overcomes the problem of light and dirty on pig, and it can be used to detect pig body dimension contactless in the real pig farm.