基于头尾定位的群养猪运动轨迹追踪

2017-02-17 02:57郁厚安雷明刚刁亚萍
农业工程学报 2017年2期
关键词:猪体圆度轮廓

高 云,郁厚安,雷明刚,黎 煊,郭 旭,刁亚萍



基于头尾定位的群养猪运动轨迹追踪

高 云1,2,郁厚安1,雷明刚2,3,黎 煊1,2,郭 旭1,刁亚萍1

(1. 华中农业大学工学院,武汉 430070;2. 生猪健康养殖协同创新中心,武汉 430070;3. 华中农业大学动物科技学院动物医学院,武汉 430070)

猪的头/尾位置直观反映了猪的进食、饮水、争斗、追逐等日常活动。从群养猪俯视视频中有效分割粘连的猪个体,找出猪的头/尾部,并以头/尾坐标实现较精准的运动轨迹追踪有着较大的难度。该研究采用改进分水岭分割算法分割视频图像帧中的粘连猪个体;对分割后的猪体提取头/尾轮廓,分别用类Hough聚类和圆度识别算法识别每头猪的头/尾,用运动趋势算法修正头/尾识别的误差,生成以头/尾部为定位坐标的运动轨迹。运算结果和人工标记对比证明类Hough聚类和圆度识别算法的头尾识别正确率分别为71.79%和79.67%;经过运动趋势修正后,以头部为定位坐标生成的运动轨迹与人工标记生成运动轨迹吻合良好;对比头/尾轨迹和质心轨迹可以发现,头/尾轨迹能够更多获取猪个体和群体活动、运动信息。该研究对于实现自动记录和分析猪个体和群体的活动行为提供新的思路和方法。

算法;图像识别;图像分割;猪群;猪个体;头/尾识别;改进分水岭;运动轨迹

0 引 言

在高养殖密度的现代化猪场中,研究猪个体和群体的行为习性,可为评价猪福利、提高猪肉质量提供重要参考依据[1-3]。长期以来,采用人工方式观察和记录群养猪的行为活动[4-6],费时费力,且难以实现准确、长期的观察记录。机器视觉作为一种实现自动化跟踪监测重要的方法和手段,具有摄像头安装方便、图像直观准确等特点,有着较大的发展空间。

机器视觉技术推动了自动监测、追踪猪的运动轨迹的研究。Kashiha等[7-8]先后采用猪体标记的方式,及图像直方图匹配和椭圆近似分析的手段,监控群养猪的行为轨迹,猪的坐标位置取近似椭圆的中心。Lind等[9]研究了单头猪在不同剂量阿朴吗啡下的运动轨迹,猪的坐标位置取猪体的加权质心。在实际猪场中,一些重要个体或群体的活动、行为可以通过辨别猪的头/尾方位进行判断,如单头猪的进食、饮水、排泄,多头猪间的争斗、追逐等。Nasirahmadi等[10]2016年研究猪的爬跨行为时,用近似椭圆来定位猪只,用两只猪运动的方向来确定爬跨行为的不同方式。确定猪头部或尾部位置有助于猪行为姿态的判定,因此采用猪头/尾来追踪猪的运动轨迹,对于研究单头猪或猪群运动自动追踪、行为的自动识别有着重要的意义。

由于饲养密集,猪群喜欢聚集等客观存在的特点,在群养猪俯视视频中将猪个体从粘连的猪群中分割识别出来有着较大的难度。马丽等[11-20]采用自适应分区和多阈值分割,对猪舍内进食、饮水等不同区域的猪群进行背景去除和个体身份识别,获得猪体分割图像,分割效果及识别结果受到猪体粘连的影响。为了定位出猪的头/尾,在分割粘连猪体时需要保留足够的头尾轮廓信息,加大了分割的难度。分割粘连物体的研究多见于小颗粒粘连物体[21-24]及交通标志的分割[25],这些分割方法直接运用于大型粘连猪体的分割,易造成头/尾轮廓信息丢失严重。以分辩头/尾为目标的群养猪粘连猪体的分割方法还未见报道。

本研究运用机器视觉技术,以定位每头猪头/尾部坐标位置为目标,从群养猪俯视视频图像中准确分割粘连猪个体,保留较完整的头/尾轮廓。对头/尾进行分辨,确定出猪头/尾的位置坐标,并以猪头/尾坐标生成猪的运动轨迹。该研究可为更准确地实现猪的个体和群体行为的自动追踪、准确记录,为进一步实现猪个体或群体活动、行为的自动分析、理解和识别提供了参考。

1 材料与方法

1.1 视频采集

在湖北金林原种畜牧有限公司的商品保育舍中一个猪栏中拍摄群养猪俯视视频,栏内共有30 kg左右的大长白保育猪10头。拍摄时间为2016年1月12日上午,拍摄条件为自然采光。将高清摄像机(型号:CL03,深圳沃世达,分辨率为1 280 pixÍ720 pix)固定于猪栏上方天花板中央,距离猪栏地面3.2 m处,垂直俯拍。猪栏长4.7 mÍ宽2.6 m,拍摄面积比猪栏面积略小。猪栏内为半漏缝地板,漏缝地板材料为绿色PVC,无漏缝地面为混泥土。猪栏为半机械通风,装有风机、湿帘和玻璃窗。

1.2 粘连猪体分割方法

对视频进行分帧处理后的图像如图1a所示。人工分析猪体颜色范围,图像帧中10头猪RGB(red, green, blue)分量的总均值为[213.774 0,203.512 3,204.712 3]。采用欧式距离法对图像帧进行阈值分割去除背景。分割冗余范围值设为=100得到最优效果,获得如图1b所示二值化图像。RGB分量总均值与猪品种和颜色密切相关,当被拍摄猪群为其他品种或颜色时,需要重新计算RGB分量的总均值设置相应的分割冗余范围值。

a. 原始图像帧(编号为手工标记)a. Original image frame (with manual marks)b. 背景去除后的二值图像b. Binary image with background removed c. 剔除小面积后二值图像c. Binary image after small areas elimination

对图1b去除小区域。以正常猪体面积的20%为基准,去除掉图中面积小于20%猪体面积的连通域,剔除结果如图1c所示,只剩下大面积的猪体。但图1c中猪体多处粘连,为了在尽量保持猪体轮廓,且有效分开粘连猪体,使每个猪体成为单一的连通域,对图像进行形态学预处理。

采用不同形状的开运算结构元素[26-27]对图1c进行形态学开运算,图2所示是分别用30×30的圆形、方形、菱形和斜45°线型的结构元素进行开运算的结果。可以看出,图2a中圆形结构元素效果最好,可分割开各猪体,且保留了每个猪体的大概轮廓。而图2c菱形结构使粘连猪体分开,但是对比原图1猪体轮廓加入了一些尖角,不利于后期进行头部轮廓识别。图2b、2d中方形和线形元素结构没有彻底把粘连猪体分开。

传统的分水岭分割过程类似于寻找“山脊”的分割线[28]。对图2a取反,得到猪体部分为0,背景部分为1的二值图像。二值图像中猪体连通区域没有灰度梯度(全为0),难以找到“山谷”。采用距离变换法[29]计算猪体连通域的极小值区域。计算单个连通域中每个像素点到背景(值为1的像素点)间的最短距离,以该距离值取代原来的0作为该像素点的灰度值,形成该猪体的极小值区域。当找到图中所有连通域的极小值区域时,即得到距离变换灰度图像。图3为距离变换灰度图像取反后的结果,距离边界点远的像素点的灰度值大,距离近的灰度值小。

a. 圆形结构a. Circular structureb. 方形结构b. Square structure c. 菱形结构c. Diamond structured. 斜45°线形结构d. 45°oblique line structure

以每只猪体连通区域的极小值区域为“山谷”,寻找分水岭脊线,得到图3b和图4a中所示分割脊线。用图4a所示脊线分割图1c,即将图4a取反后(使脊线处像素对应值为0)与图1c进点乘计算。图1c中与图4a脊线对应像素被置0,其余像素保持不变,结果如图4b 所示,脊线恰好把粘连猪体用一根脊线分开,每头猪自成一个连通域,且各猪体轮廓保持较好。

a. 分割脊线a. Ridge lines for segmentationb. 分割结果b. Results of segmentation

1.3 头尾定位

1.3.1 头尾边缘轮廓的截取

以图4b中的#1猪为例。提取该猪体的连通域(连通域内像素点值为1,背景为0),遍历连通域中所有像素点,找到所有与背景八邻域相接的像素点,生成猪体边缘像素点集,得到如图5a所示轮廓曲线。对轮廓曲线计算最小外接矩形,如图5b所示,其中矩形交猪体两头/尾于两圆点,即矩形与猪体最远端交点。

猪体中部两圆形点为矩形短中轴与猪体轮廓交点,以这两交点为起点,分别沿猪体轮廓向左、向右移动1/6猪体轮廓总长距离,分别得到4个截取点,如图5b中三角点所示。分别取两交点之间且过矩形与猪体最远端交点的轮廓段,得到图5c、图5d所示的头/尾轮廓。依次对图4b中猪体连通域进行相同处理,直至得到每头猪的头/尾轮廓。

1.3.2 头尾识别算法

1)类Hough聚类识别

将头/尾轮廓坐标集合映射到圆参数空间后进行聚类分析,判断头尾,称类Hough聚类[30-31]。根据任意不共线三点可唯一确定一个圆,在猪体头尾轮廓曲线(坐标集合)上连续采样,具体为分5步:1)将轮廓上的像素点看作一个二维数列,在轮廓上任取一点端点,从端点起,用连续3个像素点的采样窗截取数列;2)判断该采样窗内三点是否共线;3)若共线则采样窗口向后平移一个像素的距离,执行2);4)若不共线,保存采样窗内三点为一组,采样窗向后平移一个像素点,执行2);5)直至所有轮廓点采集完毕,保存所有采样组。

三像素点坐标(1,1),(2,2),(3,3)确定一圆,见式(1)。图6a所示为三点确定的圆在平面坐标上的显示。以圆心坐标和半径为映射到参数参数空间,如图6b所示,其中(,)表示圆心坐标,表示半径。

注:(,)表示圆心坐标,表示圆半径。

Note: (,) is center coordinates of circle, andis radius.

图6 图像空间到参数空间的转换

Fig.6 Transformation from image-area to parameter space

取图6b中空间点在水平面上的投影,及圆心坐标点,生成图7的轮廓曲线的参数聚类点。图7a为头部轮廓曲线聚类,图7b为尾部轮廓曲线聚类,尾部轮廓聚类点明显较头尾轮廓点集中。计算两轮廓聚类点的聚集度,如式(2)所示,聚集度表征点集聚集程度,其中D为聚类点到点集的聚类中心的欧式距离,为圆心点的个数,聚类点越集中,聚集度的值越小,当曲线为正圆时,所有聚类点重合于聚类中心,=0。

由于完整的单只猪俯视轮廓中猪尾部轮廓更接近圆形,尾部轮廓曲线聚类点的聚集度比头部轮廓小,因此取聚集度值较小的曲线轮廓为尾部轮廓,另一轮廓即为头部轮廓。

2)圆度识别

对于任意封闭的曲线,圆度的计算公式见式(3)[32]。其中面积表示封闭曲线包围像素点的个数,周长为轮廓曲线边缘像素点个数。当曲线越趋近于圆时,越接近1,曲线为标准圆时,=1。

将如图5c、5d所示头/尾轮廓以端点连线为对称轴翻转得到新曲线,将新曲线与原轮廓线拼接,形成封闭轮廓,如图8所示,中间虚直线为轮廓端点连线。拼接轮廓曲线的方法在计算圆度时不易引入额外误差。计算封闭轮廓的圆度,通常情况下猪尾轮廓更接近圆,因此取圆度值更接近1的闭合轮廓为猪尾,另一轮廓即为猪头。

a. 头部封闭轮廓a. Head closed curveb. 尾部封闭轮廓b. Tail closed curve

图8 头尾封闭轮廓

Fig.8 Closed curves of head/tail

1.4 视频标记及运动轨迹识别

1.4.1 视频标记

对视频进行分帧处理,以时间Δ为间隔在视频中截取图像帧。每帧图像采用改进分水岭分割算法处理至每头猪分割成单一连通域,如图4b所示效果。手工标记首帧图像中的每头猪,编号如图9a所示。从第2帧图像起,找寻图像中与上一帧图像中同一头猪并标记。以#3猪为例,标记的过程分为4步:1)计算首帧中#3猪质心位置(手工标记后,机器算法计算质心);2)计算第2帧图像中所有猪体质心位置(每个连通域的质心);3)以首帧中#3猪的质心坐标为圆心,体长为半径,在第2帧图像中画圆,找到圆范围内所有的猪体质心;4)若圆范围内只有一个质心,则直接标记为#3,若范围内存在多个质心,则将距离圆心最近的质心标记为#3。用该方法可标记出第2帧图像中的每头猪。依次用同样方法标记第3帧图像、第4帧图像,直至标记完所有图像帧。

分帧时间Δ的选取与猪的移动速度密切相关。如果Δ取得过大,当某头猪在两帧之间移动范围较大时,有可能会造成上一帧中距离圆心最近的质心并非同一头猪,导致标记错误。与白鼠等速度较快的小动物不同,猪的运动速度相对较慢,合理选择分帧时间,即可保证两帧间同一头猪的移动范围不至过大,又可得到一定的移动距离,方便显示猪的移动轨迹。本研究中选择分帧时间为Δ=1 s。

图9中,图9a为起始帧10只猪标记;图9b为下一帧中10只猪质心位置(蓝色点);图9c为起始帧10只猪质心(红色点)在下一帧中的位置;图9d为在下一帧中标记的起始帧10只猪质心位置。

a. 起始图像帧标记a. Markers in first frameb. #3猪下一帧标记搜索b. Marking #3 pig in next frame c. 下一帧中搜素c. Searching all pigs in next framed. 下一帧标记d. Marking in next frame

1.4.2 运动趋势修正

由于头尾识别算法中存在识别误差,需要进行修正,确保准确的头部运动轨迹识别。运动趋势修正,即每识别出一帧图像中的头/尾坐标后,即对照前两帧中当前猪的头部位置计算偏差。当尾部坐标更接近前两帧头部坐标,进行修正,将当前头部和尾部位置标记进行互换;反之,则认为识别算法正确。对整个运动轨迹进行修正运算,得到准确的头部运动轨迹曲线。

2 试验与分析

采集到的猪群活动视频(15 mins)通过Matlab软件进行处理,处理硬件设备为华硕台式机,配置为IntelCore i7-4790cpu,3.60 GHz,内存8 G。

2.1 视频分帧及标记

连续等时间间隔(Δ=1s)截取视频中的图像帧共计750帧,进行背景去除和个体分割,用视频标记处理标记出每帧图像中各猪的编号。再通过人工视频对照验证标记和正确性,结果表明,每帧图像中的猪个体被正确标记。

2.2 头尾识别

为了较好地显示猪的运动路线,从750帧图像中提取等时间间距63帧图像进行头尾识别。分别用类Hough聚类算法和圆度识别算法进行头部识别,如图10所示,红色圆点为头部位置结果。图10中有两头猪超出拍摄范围导致2种识别算法均识别错误。除去这两头猪,圆度识别全部正确。

统计63帧图像,类Hough聚类识别平均正确率为71.79%,范围为33%~100%;圆度识别平均正确率为79.67%,范围为63%~100%。类Hough聚类中识别率为33.3%的一帧图像是由于猪运动速度过快造成了猪体严重拖尾,致使图像处理后边缘轮廓畸变严重其余图像中识别率均在56%以上。图像拖尾问题在后续研究中可通过换用高速摄像头拍摄解决。若排除成像不完全的猪个体(超出镜头拍摄范围),类Hough聚类识别和圆度识别算法的平均识别正确率分别为75.00%和85.70%。

a. 类Hough聚类识别a. Clustering recognition based on analogous Houghb. 圆度识别b. Roundness recognition

由于在粘连猪体分割过程中,猪体边缘轮廓经过腐蚀和膨胀后出现轮廓曲线畸变。类Hough聚类识别算法基于分割后头尾部轮廓曲线上的像素点,对轮廓畸变较为敏感,因此轮廓曲线畸变对类Hough聚类头尾识别正确率影响较大;圆度识别算法建立在整体目标像素基础上,在一定程度上平均了边缘轮廓畸变带来的不利影响。因此在识别正确率上圆度识别优于类Hough聚类算法。2种算法在计算时间上有所差异,类Hough聚类识别平均每帧计算耗时3.063 6 s,圆度平均每帧计算耗时7.105 9 s,类Hough聚类算法较快。

在相似的研究中,Nasirahmadi等[10]在识别猪相互间爬跨行为时,根据猪的运动趋势对头/尾进行判断,基于两猪头尾或头与体侧之间的距离来判断两猪之间的行为是否为爬跨。该算法监测两相互接近的猪只并基于运动趋势对其头/尾进行判断,不涉及猪群中其他无明显运动趋势的猪只。关于采用头尾识别算法对群养猪中猪个体的头尾进行判断的文献尚未见报道。

2.3 轨迹生成

计算头/尾轮廓以及头/尾轮廓的端点连线所围成区域的质心,以该质心作为头/尾的坐标位置。采用圆度算法识别头尾后,以头部坐标生成猪的运动轨迹,如图11a所示为#2号猪轨迹。红色上三角折线表示圆度识别后#2号猪的头部运动轨迹,蓝色下三角折线为其尾部运动轨迹,黑色实心圆折线为采用人工方法对63帧图像中#2号猪的头部位置标记生成的头部位置运动轨迹。数字按时间各帧顺序排列,1为第一帧图像中的坐标,63为最后一帧图像中的坐标。

图11a中猪的头部运动轨迹与尾部运动轨迹差异较大,红色上三角折线与黑色实心圆折线的重合度较高。圆度算法对头/尾识别的误差可以从图11a中明显看出。如图中的红色上三角60号点离人工标记的黑色实心圆60号点较远,蓝色下三角60号点却与黑色实心圆60号点很接近,说明在第60帧图像中,算法错误地把#2号猪的头部识别成了尾部。

a. 头部/尾部位置运动轨迹

a. Trajectory tracking based on head/tail locations

经过运动趋势修正后,自动识别头部坐标轨迹如图11b所示。红色上三角折线为算法识别头部轨迹,蓝色实心圆为人工标记的头部轨迹,两者较好地吻合。由于自动识别的头部坐标为头部轮廓的质心,人工标记方法为人为主观判断,造成图11b中相应位置偏差,如4号点,58号点等。从#2猪头部活动轨迹可以看出,在试验时间段内,#2猪一直活动在猪图左半边漏缝地板区域。

2.4 头/尾运动轨迹与质心轨迹对比

结合头/尾运动轨迹可更加精确对猪的运动过程和运动趋势进行判断,增加了用机器算法对猪个体和群体的运动、行为理解的可能性。对比头/尾轨迹与相应的质心轨迹,如图12所示。图12a为63帧图像中的第37帧到第42帧,连续6帧图像中#2号猪(蓝色虚箭头)和#3号猪(红色实箭头)的头/尾轨迹,其中箭头为猪的头部坐标,箭尾为猪的尾部坐标。图12b中为同样6帧图像内两猪体的质心坐标生成的轨迹,蓝色实心圆为#2号猪,红色上三角为#3号猪。从图12b中可以观察到#2号猪有从中间位置往猪栏边缘运动的趋势,#3号猪在原地略微向左运动。但是从图12a中可以明确地看出#2猪围绕#3号猪转了一个大约120°的弯,#3号猪也顺势转了一个约20°的角度。两头猪的交互动作在图12a非常明确地显现。

a. 头/尾轨迹

a. Head/Tail trajectory

b. 质心轨迹

b. Centroid trajectory

注:1~6为63帧图像中的第37帧到第42帧;图12a中,箭头为猪的头部坐标,箭尾为猪的尾部坐标。

Note: 1-6 represent images from 37th picture to 42nd picture of 63 images. In Fig.12a, heads of arrows represent coordinates of pig’s heads, and tails of arrows represent coordinates of pig’s tails.

图12 头/尾轨迹与质心轨迹对比

Fig.12 Comparision between trajectories on head/tail locations and centroids

3 结 论

本研究运用机器视觉技术,以定位每头猪头/尾部坐标位置为目标,实现猪的运动轨迹自动追踪。

1)采用改进分水岭分割算法有效分割粘连猪体,保留猪头/尾轮廓特征;

2)采用类Hough聚类和圆度识别算法分别识别猪的头/尾位置,平均识别正确率分别为71.79%和79.67%;经过运动趋势修正后,自动识别的头部轨迹与人工标记的头部轨迹较好吻合。该方法可以正确辨别头尾,并自动追踪出头/尾部运动轨迹;

3)头/尾轨迹和质心轨迹,能够反应更多、更精确猪个体和群体活动、运动信息。

该方法对于自动地记录和研究猪个体以及群体的行为和习性提供了参考。目前该方法用于处理离线视频,实时视频的处理方法,还需要在计算时间上进一步优化。

[1] 施正香,李保明,张晓颖,等. 集约化饲养环境下仔猪行为的研究[J]. 农业工程学报,2004,20(2):220-225.

Shi Zhengxiang, Li Baoming, Zhang Xiaoying, et al. Behaviour of weaning piglets under intensive farm environment[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2004, 20(2): 220-225. (in Chinese with English abstract)

[2] 高娅俊,李保明,李明丽,等. 舍温对母猪行为与仔猪保温箱利用率的影响[J]. 农业工程学报,2011,27(12):191-194.

Gao Yajun, Li Baoming, Li Mingli et al. Impacts of room temperature on sow behaviour and creep box usage for pre-weaning piglet[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2011, 27(12): 191-194. (in Chinese with English abstract)

[3] 郁厚安,高云,黎煊,等. 动物行为监测的研究进展-以舍养商品猪为例[J]. 中国畜牧杂志,2015,51(20):66-70.

Yu Houan, Gao Yun, Li Xuan, et al. Research review of animal behavior monitoring technologies: Commercial pigs as realistic example[J]. Chinese Journal of Animal Science, 2015, 51(20): 66-70. (in Chinese with English abstract)

[4] Scott K, Chennells D J. The welfare of finishing pigs in two contrasting housing systems: Fully-slatted versus straw-bedded accommodation[J]. Livestock Science, 2006, 103(1/2): 104-115.

[5] Jeffery E, William G V A, David H B,et al. Behaviour of pigs with viral and bacterial pneumonia[J]. Applied Animal Behaviour Science, 2007, 105(1): 42-50.

[6] Monica R P E, Joseph P G, Anna K J, et al. A flooring comparison: the impact of rubber mats on the health, behavior, and welfare of group-housed sows at breeding[J]. Applied Animal Behaviour Science, 2010, 123(2): 7-15.

[7] Kashiha M, Bahr C, Ott S, et al. Automatic identification of marked pigs in a pen using image pattern recognition[J]. Computers and Electronics in Agriculture, 2013, 93(2): 111-120.

[8] Kashiha M, Bahr C, Ott S, et al. Automatic monitoring of pig locomotion using image analysis[J]. Livestock Science, 2014, 159(1): 141-148.

[9] Lind N M, Vinther M, Hemmingsen R P, et al. Validation of digital video tracking system for recording pig locomotor behavior[J]. Journal of Neuroscience Methods, 2005, 143(2): 123-132.

[10] Nasirahmadi A, Hensel O, Edwards S A, et al. Automatic detection of mounting behaviours among pigs using image analysis[J]. Computer and Electronics in Agriculture, 2016, 124: 295-302.

[11] 马丽,纪滨,刘宏申,等. 单只猪轮廓图的侧视图识别[J].农业工程学报,2013,29(10):168-174.

Ma Li, Ji Bin, Liu Hongshen, et al. Differentiating profile based on single pig contour[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2013, 29(10): 168-174.

[12] 王勇. 基于轮廓不变矩特征的猪行为姿态识别研究[D]. 镇江:江苏大学,2011. Wang Yong. Research on the Recognition of Pig Behavior Posture Based on Contour Invariant Moments Features[D]. Zhenjiang: JiangSu University, 2011. (in Chinese with English abstract)

[13] 周金金. 基于小波矩及概率神经网络的猪的姿态识别研究[D]. 镇江:江苏大学,2015.

Zhou Jinjin. The Gesture Recognition of Pigs Based on Wavelet Moment and Probabilistic Neural Network[D]. Zhenjiang: JiangSu University, 2015. (in Chinese with English abstract)

[14] 郭依正,朱伟兴,马长华,等. 基于Isomap和支持向量机算法的俯视群养猪个体识别[J]. 农业工程学报,2016,32(3):182-187.

Guo Yizheng, Zhu Weixing, Ma Changhua, et al. Top-view recognition of individual group-housed pig based on isomap and SVM[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2016, 32(3): 182-187. (in Chinese with English abstract)

[15] 陈佳黎. 基于优化特征提取的群养猪个体身份识别方法[D]. 镇江:江苏大学,2015.

Chen Jiali. Individual Identification Method for Group-housed Pigs Based on Optimal Feature Extraction[D]. Zhenjiang: JiangSu University, 2015. (in Chinese with English abstract)

[16] 朱伟兴,浦雪峰,李新城,等. 基于行为监测的疑似病猪自动化识别系统[J]. 农业工程学报,2010,26(1):188-192.

Zhu Weixing, Pu Xuefeng, Li Xincheng, et al. Automatic identification system of pigs with suspected case based on behavior monitoring[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2010, 26(1): 188-192. (in Chinese with English abstract)

[17] 浦雪峰,朱伟兴,陆晨芳. 基于对称像素块识别的病猪行为监测系统[J]. 计算机工程,2009,35(21):250-252.

Pu Xuefeng, Zhu Weixing, Lu Chenfang. Sick pig behavior monitor system based on symmetrical pixel block recognition[J]. Computer Engineering, 2009, 35(21): 250-252. (in Chinese with English abstract)

[18] 朱伟兴,纪滨,秦锋. 基于伪球算子边缘模型的猪前景帧监测[J]. 农业工程学报,2012,28(12):189-194.

Zhu Weixing, Ji Bin, Qin Feng. Detection of foreground- frame of pig using edge model based on pseudosphere- operator[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2012, 28(12): 189-194. (in Chinese with English abstract)

[19] Guo Yizheng, Zhu Weixing, Jiao Pengpeng, et al. Foreground detection of group-housed pigs based on the combination of mixture of gaussians using prediction mechanism and threshold segmentation[J]. Bio-systems Engineering, 2014, 125(3): 98-104.

[20] Guo Yizheng, Zhu Weixing, Jiao Pengpeng, et al. Multi-object extraction from top-view group-housed pig images based on adaptive partitioning and multilevel thresholding segmentation[J]. Bio-systems Engineering, 2015, 135: 54-60.

[21] Zhou Kaijun, Yang Chunhua, Gui Weihua, et al. Clustering- driven watershed adaptive segmentation of bubble image[J]. Journal of Central South University of Technology, 2010, 17(5): 1049-1057.

[22] Malpica N, Solorzano C O, Vaquero J J, et al. Applying watershed algorithms to the segmentation of clustered nuclei[J]. Cytometry, 1997, 28(4): 289-297.

[23] Salman N H, Lin C Q. Image segmentation and edge detection based on watershed techniques[J]. International Journal of Computers and Applications, 2003, 25(4): 69-74.

[24] Sri N A, Varma G P S, Govardhan A. An improved iterative watershed and morphological transformation techniques for segmentation of microarray images[J]. Computer Aided Soft Computing Techniques for Imaging and Biomedical Applications, 2010, CASCT(2): 77-87.

[25] 周广波. 基于颜色和形状特性的交通标志检测[D]. 大连:大连理工大学,2013.

Zhou Guangbo. Traffic Sign Detection Based on Color and Shape Features[D]. Dalian: Dalian University of Technology, 2013. (in Chinese with English abstract)

[26] Soille P. Morphological image analysis: principles and applications[J]. Computer Physics Communications, 2003, 49(5): 94-103.

[27] Vincent L. Morphological grayscale reconstruction in image analysis: applications and efficient algorithms[J]. IEEE Trans. Image Processing, 1993, 2(2): 176-201.

[28] 丁伟杰,范影乐,庞全. 一种改进的基于分水岭算法的粘连分割研究[J]. 计算机工程与应用,2007,43(10):70-72.

Ding Weijie, Fan Yingle, Pang Quan. Improved research for overlapping segmentation based on watershed algorithm[J]. Computer Engineering and Applications, 2007, 43(10): 70-72. (in Chinese with English abstract)

[29] Vincent L, Soille P. Watersheds in digital spaces: An efficient

based on immersion simulations[J]. IEEE Trans. Pattern Anal. Machine Intell, 1991,13(6): 583-598.

[30] 许晓丽. 基于聚类分析的图像分割算法研究[D]. 哈尔滨:哈尔滨工程大学,2012.

Xu Xiaoli. Research of Image Segmentation Algorithm Based on Clustering Analysis[D]. Harbin: Harbin Engineering University, 2012. (in Chinese with English abstract)

[31] 张新野. 基于聚类分析的图像分割方法研究[D]. 大连:大连海事大学,2012.

Zhang Xinye. Study on Image Segmentation Based on Clustering Analysis[D]. Dalian: Dalian Maritime University, 2012. (in Chinese with English abstract)

[32] 朱殿尧,卞红雨. 矩形和(椭)圆区域目标的分类识别[J].激光与红外,2009,39(11):1228-1232.

Zhu Dianrao, Bian hongyu. Classification between rectangular and ellipsoid/circular areas[J]. Laser and Nfrared, 2009, 39(11): 1228-1232. (in Chinese with English abstract)

Trajectory tracking for group housed pigs based on locations of head/tail

Gao Yun1,2, Yu Hou’an1, Lei Minggang2,3, Li Xuan1,2, Guo Xu1, Diao Yaping1

(1.430070,; 2.430070,;3.430070,)

Observing animal’s individual and social behaviors is the most effective way to assess animal welfare and healthy. Automated trajectory tracking based on head/tail locations is supposed to be extremely helpful for the realization of pig behavior recognition, especially for group housed pigs in the commercial pig facility. The methods of trajectory tracking for group housed pigs based on head/tail location were described in this paper. The video of group housed nurseries was taken in a commercial pig breeding farm of Hubei Jinlin Original Breeding Swine Co. Ltd. on January 12th, 2016. A high resolution camera (Woshida CL03) was used to record 15 min video. Afterwards, image frames were extracted from the original video in a one-second time interval. Image frames were processed in a computer (configured with IntelCore i7-4790 CPU (central processing unit), 3.6 GHz, 8 G memory) with MATLAB software platform. The image processing for each image frame included 4 steps: background removal, pigs division, head/tail identification and trajectory tracking modification. The background removal was based on the RGB (red, green, blue) color space, from which a vector of RGB mean values of the pig’s body was calculated. If the Euclidean distance between the RGB values of one pixel and the RGB mean values vector was less than a small threshold of 100, the pixel was involved in a pig body area and set as 1. Otherwise, it was outside any pig body area and set as 0. When all pixels of the image frame were scanned and calculated by this method, a binary image was acquired. The white area referred to pig’s body area, while the black area referred to the background. After that, the morphology erosion and expansion were utilized before the watershed segmentation algorithm to improve the dividing effect for the pigs with adhesion. Pigs division was implemented on the binary images with the improved watershed segmentation algorithm. To discriminate each pig in each image frame, a video tracking and marking method was necessary to be implemented in the video. After being manually marked with the identify number in the first frame, each pig had a unique number and was labelled automatically throughout the video. Abstracting image frames from the video with a very short time interval (1 s), the distance of 2 centroids of the identical pig between 2 continuous image frames would be sufficiently small. Therefore, the video tracking was to find the pig with the closest distance in the next image frame and mark it with the same identify number of the current pig until all the pigs were marked. After each pig was marked throughout the video, using the head/tail location as the coordinates of the pig, the trajectory of each pig in herd could be tracked by the trajectory calculation. Extracting the outline of each pig in frames, the head and the tail outlines were divided from the whole outline, after a sixth of whole outline distance was moved along the outline in 2 opposite directions from the 2 intersection points of the outline and short axis of the minimum bounding rectangle. After the head/tail outline curve was gained from each pig outline, 2 recognition algorithms, the analogous Hough clustering recognition algorithm and the roundness recognition algorithm, were employed to identify the head/tail of each pig. Thus the location of the pig’s head/tail could be spotted by locating the centroid of the heat/tail curve. Then the trajectory tracking of the pigs was calculated based on the location of head/tail, and corrected by the motion trends of pigs. Experiment showed that the background was successfully removed from each image frame using the Euclidean distance of RGB values between the pixels and the mean value vector. The improved watershed segmentation algorithm has been verified as an effective tool to divide the pigs with adhesion. The identify number of each pig was tracked from the first frame to the end. The average recognition rate of analogous Hough clustering algorithm was 71.79% for the identification of pig’s heads/tails, while the roundness algorithm was 79.67%, which was less sensitive to the distortion of head outline curve. If not including the pigs outside the camera range, the recognition rates would be up to 75% and 85.7% respectively. The roundness algorithm shows an obvious advantage in comparison. The modified trajectory of each pig shows a high agreement with the manually labelled trajectory. More understanding for pigs’ behaviors can be acquired from the trajectory of head/tail locations. This trajectory tracking method provides a good reference for further research of behavior recognition.

algorithms; image recognition; image segmentation; pig herd; individual pig; identification of head/tail; improved watershed segmentation; trajectory tracking

10.11975/j.issn.1002-6819.2017.02.030

TP391

A

1002-6819(2017)-02-0220-07

2016-06-15

2016-11-20

“十三五”国家重点研发计划项目(2016YFD0500506);湖北省自然科学基金(2014CFB317);现代农业技术体系(CARS-36)

高 云,博士,副教授,硕士生导师,主要从事农业智能检测与控制方面的研究。武汉 华中农业大学工学院,430070。 Email:angelclouder@mail.hzau.edu.cn。美国农业工程学会会员ASABE(1049530);中国农业工程学会会员(E041700006M)

高 云,郁厚安,雷明刚,黎 煊,郭 旭,刁亚萍. 基于头尾定位的群养猪运动轨迹追踪[J]. 农业工程学报,2017,33(2):220-226. doi:10.11975/j.issn.1002-6819.2017.02.030 http://www.tcsae.org

Gao Yun, Yu Hou’an, Lei Minggang, Li Xuan, Guo Xu, Diao Yaping. Trajectory tracking for group housed pigs based on locations of head/tail[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2017, 33(2): 220-226. (in Chinese with English abstract) doi:10.11975/j.issn.1002-6819.2017.02.030 http://www.tcsae.org

猜你喜欢
猪体圆度轮廓
大型五轴数控机床圆度误差测试与分析
夏季养猪要做好防暑降温
OPENCV轮廓识别研究与实践
猪应激反应综合征的防治措施
基于实时轮廓误差估算的数控系统轮廓控制
改进天牛须搜索算法在圆度误差评定中的研究
基于单视角点云镜像的猪只体尺测量方法
学会8招夏季养猪增膘等4则
高速公路主动发光轮廓标应用方案设计探讨
发动机气缸套内孔圆度测量分析