?

基于頭尾定位的群養豬運動軌跡追蹤

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則
高速公路主動發光輪廓標應用方案設計探討
發動機氣缸套內孔圓度測量分析
91香蕉高清国产线观看免费-97夜夜澡人人爽人人喊a-99久久久无码国产精品9-国产亚洲日韩欧美综合