朱镕杰,朱穎匯,王 玲,盧 偉,羅 慧,張志川
(南京農(nóng)業(yè)大學工學院,南京 210031)
基于尺度不變特征轉(zhuǎn)換算法的棉花雙目視覺定位技術(shù)
朱镕杰,朱穎匯,王 玲※,盧 偉,羅 慧,張志川
(南京農(nóng)業(yè)大學工學院,南京 210031)
為了給采棉機器人提供運動參數(shù),設(shè)計了一套雙目視覺測距裝置以定位棉株。對獲取的左右棉株圖像進行經(jīng)背景分割等預處理。求取其在8個尺度下的高斯圖,通過尺度不變特征轉(zhuǎn)換SIFT(scale-invariant feature transform)算法在相鄰高斯差分圖中提取出SIFT關(guān)鍵點;計算每個高斯圖中關(guān)鍵點鄰域內(nèi)4×4個種子點的梯度模值,得到128維特征向量。分割右圖關(guān)鍵點構(gòu)成的128維空間,得到二叉樹;利用最優(yōu)節(jié)點優(yōu)先BBF(best bin first)算法在二叉樹中尋找到172個與左圖對應的粗匹配點。由隨機采樣一致性RANSAC(random sample consensus)算法求出基礎(chǔ)矩陣F,恢復極線約束,剔除誤匹配,得到分布在11朵棉花上的151對精匹配。結(jié)合通過標定和F得到的相機內(nèi)外參數(shù),最終重建出棉花點云的三維坐標。結(jié)果表明,Z軸重建結(jié)果比較接近人工測量,平均誤差為0.039 3 m,能夠反映棉花間的相對位置。
機器人;圖像處理;視覺;棉花;SIFT特征;雙目視覺;二叉樹;RANSAC算法
朱镕杰,朱穎匯,王 玲,盧 偉,羅 慧,張志川.基于尺度不變特征轉(zhuǎn)換算法的棉花雙目視覺定位技術(shù)[J].農(nóng)業(yè)工程學報,2016,32(6):182-188.doi:10.11975/j.issn.1002-6819.2016.06.025 http://www.tcsae.org
Zhu Rongjie,Zhu Yinghui,Wang Ling,Lu Wei,Luo Hui,Zhang Zhichuan.Cotton positioning technique based on binocular vision with implementation of scale-invariant feature transform algorithm[J].Transactions of the Chinese Society of Agricultural Engineering(Transactions of the CSAE),2016,32(6):182-188.(in Chinese with English abstract) doi:10.11975/j.issn.1002-6819.2016.06.025 http://www.tcsae.org
棉花是中國的主要經(jīng)濟作物之一。美國、俄羅斯、埃及等產(chǎn)棉大國通常采用大規(guī)模機械化采收方式[1]。中國棉花常用的人工采摘方式勞動強度大、成本高,嚴重制約著棉花生產(chǎn)規(guī)模的進一步擴大[2]。為此,采用棉花采摘機器人代替人工勞作有望大幅度降低采摘成本并提高生產(chǎn)效率[3-5],而雙目立體視覺系統(tǒng)正是采棉機器人的核心技術(shù)之一。
國內(nèi)外對農(nóng)業(yè)中的雙目視覺應用均有不同程度的研究。國外方面,Kassay[6]等利用雙目立體視覺系統(tǒng)采集到水果圖像后,采用霍夫變換進行圖像處理獲取水果的中心位置。Kondo[7]等基于番茄的顏色特征尋找和識別成熟的果實,采用立體視覺技術(shù)獲取番茄的位置信息。Takahashi[8-10]等根據(jù)蘋果在立體圖像對中的視差將給定范圍的三維空間分割成若干個等距離的區(qū)間,將2幅圖像合成一幅中心圖像,然后獲取蘋果的深度信息。國內(nèi)方面,王玲[11]等利用激光傳感器采用了非接觸式的方法測量棉株表面的深度信息,但處理速度較慢且穩(wěn)定性不高。彭輝[12]等結(jié)合加速魯棒特征SURF(speed-up robust features)算子和極線約束對柑橘立體圖像對進行匹配,在果實光線強弱不同時仍然能較好的進行匹配,但是SURF算子對匹配對象視角差異的容忍度仍有不足。
本文在分析了國內(nèi)外對采摘機器人視覺系統(tǒng)的研究的基礎(chǔ)上,利用尺度不變特征轉(zhuǎn)換SIFT(scale-invariant feature transform)[13-14]算法對棉花的平移、旋轉(zhuǎn)、尺度縮放良好的抑制性提取棉花表面特征,采用基于最優(yōu)節(jié)點優(yōu)先BBF(best bin first)[15]算法的二叉樹搜索算法提高特征匹配的精度與效率,利用隨機采樣一致性RANSAC(random sample consensus)[16]算法估計基礎(chǔ)矩陣并去除誤匹配,并結(jié)合標定結(jié)果得到相機內(nèi)部參數(shù)和外部運動參數(shù)進行匹配點的三維重建完成棉花定位,以此為采摘機器人運動軌跡的規(guī)劃提供參數(shù)。
將鏡頭焦距為16mm的雙目相機、投影儀、1.8m×0.7m× 1.8 m角鋼架和PC機組建測距試驗裝置,相機固定在投影儀兩側(cè),可隨意調(diào)整其俯仰角和偏轉(zhuǎn)角,以保證棉株處在相機的視野范圍內(nèi)(圖1-a)。
在投影儀打光和不打光二種條件下連續(xù)拍攝二張棉株圖像(圖1-b,c)。利用打光圖像棉花與背景對比度強的特點對圖像進行二值化處理,以去除背景;結(jié)合不打光圖像獲取邊界清晰、紋理豐富的黑背景棉花圖像,進一步進行灰度拉伸、銳化等預處理,以增強棉花的灰度細節(jié)(圖1-d)。
圖1 圖像采集與預處理Fig.1 Image acquisition and pretreatment
2.1 SIFT關(guān)鍵點檢測與特征提取
尺度不變特征轉(zhuǎn)換SIFT特征僅依賴于圖像的局部信息,具有平移、旋轉(zhuǎn)、縮放不變性,同時,對光照、投影、仿射的變化也具有一定的魯棒性。
首先,用不同尺度的二維高斯核函數(shù)(式1)與二維圖像卷積,實現(xiàn)棉花圖像的模糊濾波處理,獲取尺度k(k= 0~8)的高斯圖(式2);進一步計算相鄰尺度高斯圖之間的差分圖(式3),獲得尺度k(k=1~8)的高斯差分圖。
其次,將尺度1~8的高斯差分圖堆積成一個三維尺度空間,檢測該空間中的數(shù)據(jù)點是否為其3×3×3立體鄰域內(nèi)的局部極值點,局部極值點即為關(guān)鍵點(圖2-a),進一步基于曲面擬合來精確定位關(guān)鍵點的坐標,并用二階求導法消除邊緣處的噪聲響應。
最后,以關(guān)鍵點為中心,在其4×4鄰域窗口內(nèi)采樣16個種子點,針對每一個種子點,在尺度1~8的高斯圖上分別計算其梯度模值和方向(式4-5),基于種子點的8個模值獲取關(guān)鍵點的16×8=128維SIFT特征(圖2-b)。
試驗結(jié)果表明,左、右圖分別檢測出1 529、1 493個關(guān)鍵點。
式中(x,y)表示圖像I上像素點的位置;σ為尺度空間因子。
圖2 SIFT特征向量Fig.2 SIFT feature vectors
2.2 二叉樹搜索
關(guān)鍵點匹配可以歸結(jié)為一個通過距離函數(shù)在高維空間上的相似性檢索問題,窮盡搜索雖能搜索到正確的匹配點,但耗時大;基于二叉樹搜索算法并結(jié)合最優(yōu)節(jié)點優(yōu)先BBF的嵌套搜索算法可有效解決該問題。以左圖的第14個關(guān)鍵點為例,在右圖中搜索其匹配點的方法如圖3所示。
圖3 二叉樹搜索Fig.3 Search of binary tree
首先,創(chuàng)建二叉樹。在128維上分別計算右圖1 493個關(guān)鍵點的特征值方差,最大方差所在維為第105維,該維特征排序后的中值56.270 6對應關(guān)鍵點366,以此為根節(jié)點,將小于或等于中值的關(guān)鍵點集合歸入根節(jié)點的左枝,否則歸入右枝;依此類推,分別劃分根節(jié)點的左枝和右枝,直至葉節(jié)點,從而創(chuàng)建了一個二叉樹(圖3-a)。同時按照尋找到的各節(jié)點劃分右圖棉花的二維圖像區(qū)域,這樣搜索匹配點時只需在由對應節(jié)點劃分的區(qū)域內(nèi)尋找,而不必遍歷所有關(guān)鍵點,有效地縮小了匹配點的搜索范圍(圖3-b)。
其次,二叉樹搜索。從二叉樹根節(jié)點366開始,在第105維上,由于左圖關(guān)鍵點14的特征值25.707 8小于等于右圖根節(jié)點的特征值56.2706,即表1中L-R≤0,則搜索路徑指向根節(jié)點的左子節(jié)點,即關(guān)鍵點653,反之亦然。重復以上步驟,直至搜索路徑指向葉節(jié)點,即366、653、167、404、112、22、11、41、164、13(圖3-a),搜索過程中同時依次記錄途經(jīng)節(jié)點的兄弟節(jié)點771、1 166、602、125、48、49、10、8、133。
再次,二叉樹嵌套搜索。獲取上述兄弟節(jié)點在二叉樹創(chuàng)建過程中產(chǎn)生的最大方差所在維及其特征值,并與左圖關(guān)鍵點14在對應維上的特征值進行比較,并將比較結(jié)果| L′-R′|進行升序排序(表1),生成BBF優(yōu)先級序列兄弟節(jié)點10、602、8、771、1 166、125、49、48、133。依次從優(yōu)先級序列中的兄弟節(jié)點出發(fā),嵌套搜索二叉樹至葉節(jié)點(圖3-a),直至優(yōu)先級序列為空或到達200次搜索限制,返回若干個葉節(jié)點。
最后,確定匹配點。在128維特征空間下用歐氏距離比較左圖關(guān)鍵點14與右圖二叉樹搜索到的所有葉節(jié)點的相似度,返回歐氏距離最小的相似點13和次相似點121,對應的相似度和次相似度分別為47.875 8和297.975 9(表2),定義相似度小于0.49×次相似度的相似點為匹配點,則相似點13為左圖關(guān)鍵點14的匹配點。
表1 二叉樹搜索過程Table 1 Search procedure of binary tree
試驗結(jié)果表明,針對左圖的1 529個關(guān)鍵點,在右圖二叉樹上總計搜索出172對粗匹配點(表2),將匹配點在原圖中用線連起來(圖4),對應于空間中的同一點。棉花在左右圖像中的對應位姿不盡相同,有些差異甚至很大,由于SIFT特征對旋轉(zhuǎn)、平移和仿射的高抑制性,關(guān)鍵點的匹配效果良好,SIFT算法適應棉花的形貌。
圖4 左右圖中棉花粗匹配點連線Fig.4 Connected lines of rough matches in left and right cotton images
3.1 基礎(chǔ)矩陣估計原理
從不同角度對同一場景拍攝的影像I與I′的極線幾何關(guān)系如圖5所示,空間任一點X在平面I與I′上的投影點分別為m與m′,2相機的光心C與C′的連線與平面I與I′相交于極點e與e′,平面XCC′與圖像平面I與I′的交線lm與lm′分別為點X在平面I和I′上的極線。
圖5 極線幾何約束Fig.5 Epipolar geometry constraint
假設(shè)匹配點對m與m′的齊次坐標為u=(x,y,1)與u′=(x′,y′,1),平面I上的極線lm用基礎(chǔ)矩陣F或矢量f(式6-7)描述,由匹配點對與極線共面可給出平面I的極線方程(式8),u′TF為極線的直線坐標,極線方程展開后可表示為一個矢量內(nèi)積(式9),則基礎(chǔ)矩陣F可由在平面I與I′上的對應點u與u′求出。由n組匹配點對的集合可得到一個線性齊次方程組(式10),A的子空間的解即為矢量f。由于基礎(chǔ)矩陣具有7個自由度,故至少需要7個匹配點對,通常采用7點或8點算法來估計基礎(chǔ)矩陣[17]。
3.2 基于RANSAC算法的基礎(chǔ)矩陣優(yōu)化
實際應用中,由于噪聲的影響,粗匹配點對可能存在誤匹配,其中的誤匹配點對姑且稱作外點對,因而有外點對參與的8點法對基礎(chǔ)矩陣的估計會產(chǎn)生誤差,從而使基礎(chǔ)矩陣的估計值惡化。為了解決這一問題,采用隨機采樣一致性RANSAC方法,通過重復地對特征集采樣,基于歐式距離來獲得內(nèi)點對并剔除外點對,基于內(nèi)點對的基礎(chǔ)矩陣估算可提高8點算法的魯棒性。具體步驟分二步:
首先,基于8點法求解基礎(chǔ)矩陣并估計參數(shù)。從172個粗匹配點對中任取8個匹配點對,對這些匹配點對坐標進行歸一化處理[18],以提高結(jié)果的穩(wěn)定性。將歸一化的8組匹配點坐標代入線性齊次方程組(式10),求解基礎(chǔ)矩陣F(表3)。將左圖的關(guān)鍵點坐標u=(x,y,1)和基礎(chǔ)矩陣F代入平面I的極線方程(式8),以恢復右圖的極線,計算右圖的粗匹配點到該極線的距離distL,反之可獲取左圖的關(guān)鍵點到極線的距離distR,距離均小于1.5的粗匹配點對為內(nèi)點對(表4),并估計所有內(nèi)點對的誤差(式11)。
式中inlierCount表示內(nèi)點對數(shù)。
表3 8點法的輸入與輸出Table 3 Inputs and outputs of 8 point algorithm
表4 判別內(nèi)點對Table 4 Determination of inliers
然后,基于RANSAC法優(yōu)化基礎(chǔ)矩陣。在采樣次數(shù)N足夠大的情況下,假設(shè)n=8組匹配點對組成的隨機樣本中,至少有一次沒有外點對的概率為P,默認值為0.99;在粗匹配點對中,出現(xiàn)外點對的概率為e,默認值為0.6;則初始N=7 024.6(式12)。在每一次重復采樣過程中,都要基于8點法求解基礎(chǔ)矩陣,估計內(nèi)點對數(shù)及其誤差,以內(nèi)點對數(shù)最多或誤差較小來優(yōu)化F(表5);同時,還要根據(jù)上一次的e自適應地決定新的N,這樣,隨著內(nèi)點對數(shù)的不斷增加,e和N越來越小,從而使得重復采樣過程快速收斂,提高算法的運算速度。試驗結(jié)果表明,在第16次采樣過程中(表4,表5),內(nèi)點對數(shù)增加到151時,由N<16終止重復采樣過程,從172組粗匹配點對中剔除了誤匹配。
表5 基于RANSAC法優(yōu)化基礎(chǔ)矩陣Table 5 Refined fundamental matrix based on RANSAC
4.1 相機內(nèi)外參數(shù)的獲取
假設(shè)世界坐標系下的一個點(X,Y,Z)在圖像坐標系下的坐標為(u,v),根據(jù)針孔成像模型和圖像坐標系與世界坐標系之間的轉(zhuǎn)換關(guān)系[19-20](式13)可知,必須標定相機的內(nèi)參矩K和外參矩陣M,才能根據(jù)圖像坐標點轉(zhuǎn)換成世界坐標點。
式中λ為比例系數(shù),相機的內(nèi)參K包括u、v軸的歸一化焦距fu、fv,相機光心坐標(u0,v0);相機的外參M包括相機之間的旋轉(zhuǎn)矩陣R和平移矩陣t。
首先,相機內(nèi)參標定。張正友[21]和Tsai[22]的方法假設(shè)平面網(wǎng)格在世界坐標系中,通過線性模型計算攝像機內(nèi)部參數(shù)的優(yōu)化解,并基于最大似然法進行非線性求解,標定出考慮鏡頭畸變的目標函數(shù),從而求出左右相機的內(nèi)參矩陣(表6)。由于標定試驗中采用了DH-HV3151UC-ML型CMOS工業(yè)數(shù)字相機,其分辨率為2 048×1 536,單位像素尺寸為3.2 μm×3.2 μm,鏡頭焦距為16 mm。因而,理想情況下,相機的歸一化焦距fu=fv=16 000 μm/3.2 μm=5 000,相機的光心坐標u0=1 024、v0=768。由此可見,相機內(nèi)參的實際標定結(jié)果與理論值有些許偏差,這可能是由相機制造工藝引起的。
然后,相機外參標定。在已知相機內(nèi)參K的情況下,基礎(chǔ)矩陣F可由本質(zhì)矩陣E求?。ㄊ?4),使用歸一化坐標系時,基礎(chǔ)矩陣F的一種特殊形式就是本質(zhì)矩陣[23]。本質(zhì)矩陣最早由Longuet-Higgins在1981年由從運動到結(jié)構(gòu)的求解中導出[24],該矩陣是一個自由度為5、秩為2的3× 3矩陣,它的一個重要性質(zhì)就是與內(nèi)參無關(guān),僅由相機的外參確定(式14),實際計算時用四元數(shù)表示法[25](式15)通過本質(zhì)矩陣E恢復出相機的旋轉(zhuǎn)矩陣R和平移矩陣t(表6)。
表6 相機內(nèi)外參數(shù)標定Table 6 Calibration of camera intrinsic and extrinsic parameters
4.2 棉花的三維重建
采摘機器人工作時,隨著機器人在田間行走,固定在機械臂上空橫桿上的兩相機角度可調(diào),需要不斷估計2個相機之間的外參。因而可將左相機光心作為世界坐標系的原點,調(diào)整左相機的俯仰角和偏轉(zhuǎn)角,使世界坐標系的Z軸垂直于地面,這樣左相機相對自身的旋轉(zhuǎn)、平移矩陣為單位陣I、零向量,右相機相對左相機的旋轉(zhuǎn)、平移矩陣為R、t,將151組精匹配點對的圖像坐標以及左右相機的內(nèi)外參數(shù)代入方程組(式13)進行最小二乘法求解,得到151個空間點的三維坐標(圖6),由圖可知,11簇點云團代表了棉花的空間位置。
將預處理后的棉花灰度圖(圖1-d)二值化,并以其為模板獲取單朵棉花表面的點云,進而求取單朵棉花的三維質(zhì)心坐標,將其Z軸坐標轉(zhuǎn)化為棉花到地面的距離(表7)。試驗結(jié)果表明,雙目視覺的Z軸測距結(jié)果比較接近人工測量,平均誤差為0.039 3 m,能夠反映棉花間的相對位置。
圖6 棉花點云三維坐標Fig.6 Scatter diagram of cotton point cloud
表7 棉花三維重建結(jié)果Table 7 Result of cotton 3D reconstruction
1)設(shè)計試驗裝置時,采用投影儀打光和不打光結(jié)合的方式采集圖像,在保留了棉花表面豐富紋理的同時兼顧了邊界的清晰;相機角度的可調(diào)性要求不斷估計新的相機外參,能夠適應機器人田間行走的多樣性。
2)SIFT特征的旋轉(zhuǎn),平移,縮放和仿射不變性能夠適應田間棉花的形貌。
3)結(jié)合BBF優(yōu)先級序列的二叉樹搜索算法提高了粗匹配的運行效率,并且避免了高維特征搜索問題;基于RANSAC的基礎(chǔ)矩陣優(yōu)化算法極大地降低了精匹配的計算開銷。
[1]王玲,姬長英.農(nóng)業(yè)機器人采摘棉花的前景展望與技術(shù)分析[J].棉花學報,2006,18(2):124-128.Wang Ling,Ji Changying.Technical analysis and expectation for cotton harvesting based on agricultural robot[J].Cotton Science, 2006,18(2):124-128.(in Chinese with English abstract)
[2]王玲,姬長英,陳兵林,等.基于機器視覺技術(shù)的田間籽棉品級抽樣分級模型研究[J].中國農(nóng)業(yè)科學,2007,40(4):704-711.Wang Ling,Ji Changying,Chen Binglin,et al.Researches of grading model of field sampling cotton based on machine vision technology[J].Scientia Agricultura Sinica,2007,40(4):704-711.(in Chinese with English abstract)
[3]韋皆頂,費樹岷,汪木蘭,等.采棉機器人的研究現(xiàn)狀及關(guān)鍵技術(shù)[J].農(nóng)機化研究,2007(7):14-18.Wei Jieding,Fei Shumin,Wang Mulan,et al.Key techniques and research statue for cotton picking robot[J].Journal of Agricultural Mechanization Research,2007(7):14-18.(in Chinese with English abstract)
[4]Edan Y,Miles G E.Design of an agricultural robot for harvesting melons[J].Transactions of the ASAE,1993,36(2):593-603.
[5]Arima S,Kondo N.Cucumber harvesting robot and plant training system[J].Journal of Robotics and Mechatronics,1999,11(3): 208-212.
[6]Kassay L,Slaughter D.Robotic apple harvest[Z].St.Joseph. Mich:ASAE,1992,ASAE Paper No.922047.
[7]Kondo N,Nishitsuji Y,Ling P.Visual feedback guided robotic cherry tomato harvesting[J].Transactions of the ASAE,1996,39 (6):2331-2338.
[8]Takahashi T,Zhang S,Sun M,et al.New method of image processing for distance measurement by a passive stereo vision [Z].St.Joseph,Mich:ASAE,1998,ASAE Paper No.983031.
[9]Takahashi T,Zhang S,Fukuchi H,et al.Binocular stereo vision system for measuring distance of apples in orchard(Part 1)-Method due to composition of left and right images[J].Journal of the Japanese Society of Agricultural Machinery,2000,62(1): 89-99.
[10]Takahashi T,Zhang S,Fukuchi H,et al.Binocular stereo vision system for measuring distance of apples in orchard(Part 2)-Analysis of and solution to the correspondence problem[J]. Journal of the Japanese Society of Agricultural Machinery,2000, 62(3):94-102.
[11]王玲,劉思瑤,盧偉,等.面向采摘機器人的棉花激光定位算[J].農(nóng)業(yè)工程學報,2014,30(14):42-48.Wang Ling,Liu Siyao,Lu Wei,et al.Laser detection method for cotton orientation in robotic cotton picking[J].Transactions of the Chinese Society of Agricultural Engineering(Transactions of the CSAE),2014,30(14):42-48.(in Chinese with English abstract)
[12]彭輝,文友先,翟瑞芳,等.結(jié)合SURF算子和極線約束的柑橘立體圖像對匹配[J].計算機工程與應用,2011,47(8):157-160.Peng Hui,Wen Youxian,Zhai Ruifang,et al.Stereo matching for binocular citrus images using SURF operator and epipolar constraint[J].Computer Engineering and Applications,2011,47 (8):157-160.(in Chinese with English abstract)
[13]Lowe D G.Distinctive image features from scale-invariant key points[C].International Journal of Computer Vision,2004,60(2): pp91-110.
[14]Lowe D G.Object recognition from local scale invariant features [C].Proceeding of the Seventh International Conference on Computer.Vision.Washington,DC:IEEE Computer Society, 1999:1150.
[15]張開玉,梁鳳梅.基于改進SURF的圖像配準關(guān)鍵算法研究[J].科學技術(shù)與工程,2013,13(10):2875-2879.Zhang Kaiyu,Liang Fengmei.Research on the key algorithm for image matching based on improved SURF[J].Science Technology and Engineering,2013,13(10):2875-2879.(in Chinese with English abstract)
[16]Fischler M,Bolles R.Random sample consensus:A paradigm formodel fitting with application to image analysis and automated cartography[J].Communications of the ACM,1981(24):381-395.
[17]Richard I.Hartley.In defense of the 8-point algorithm[C],In Proceeding of International Conference on Computer Vision (ICCV),1995:1064-1070.
[18]Hartley,Richard.計算機視覺中的多視圖幾何[M].安徽:安徽大學出版社,2002:193.
[19]馬頌德,張正友.計算機視覺-計算理論與算法基礎(chǔ)[M].北京:科學出版社,1998:53~58.
[20]David A,Forsyth,Jean Ponce.計算機視覺-一種現(xiàn)代方法[M].北京:電子工業(yè)出版社,2004,54~55.
[21]Zhang Zhengyou.Flexible camera calibration by viewing a plane from unknown orientations[C],IEEE International Conference on Computer Vision,1999,1:666-673.
[22]Tsai R Y.An efficient and accurate camera calibration technique for 3D machine vision[C],CVPR,1986,364-374.
[23]Quanquan Gu,Jie Zhou.Belief propagation on Riemannian manifold for stereo matching[C].IEEE International Conference on Image Processing,2008,15:1788-1791.
[24]HughC.Longuet-Higgins.Acomputeralgorithm forreconstructing a scene from two projections[J].Nature,1981,293(5):133-135.
[25]Zhang Zhengyou.A new multistage approach to motion and structure estimation by gradually enforcing geometric constraints [C].Proceedings of the ACCV’98,Hong Kong,l998:567-574.
Cotton positioning technique based on binocular vision with implementation of scale-invariant feature transform algorithm
Zhu Rongjie,Zhu Yinghui,Wang Ling※,Lu Wei,Luo Hui,Zhang Zhichuan
(College of Engineering,Nanjing Agricultural University,Nanjing 210031,China)
Rapid development of mechanization in agriculture has made it possible to lower the manual labor hour and increase efficiency at the same time.In order to provide the mechanical arm of the cotton picking robot with the needed movement locus parameters,a cotton distance measuring device based on binocular vision with a full implementation of SIFT (scale-invariant feature transform)algorithm was introduced,which realized the positioning of all 11 pieces of cotton planted. Under indoor environment,the cotton images were captured with the control of projector flashlight and the unneeded backgrounds were segmented.Turn the RGB images into gray scale and enhance the gray value to make the cotton more obvious,and after sharpening the edges,the pretreatments of cotton images were finished.Blur the images through Gaussian filter with 8 different scales,calculate the DoG(difference of Gaussian)of Gaussian images and acquire the extrema of 26 neighboring pixels within neighboring scales,and thus SIFT key points were detected,all these key points were invariant to rotation,translation,zoom and affine,which was suitable for the match of cotton images.Calculate the gray gradient modulus value of the 4×4 seed points in 8 directions within the key point neighborhood,and the 128-dimensional SIFT descriptor of each key point was acquired.As to all the SIFT key points in the right image,select the dimension with the maximum variance,and calculate the median value of this dimension,find its corresponding key point and split the other key points according to the median value,repeat this step and the binary tree was built.As to every SIFT key point in the left image, search its potential matches(probably more than one)in the binary tree of the right image until its leaf node was found;save the brother nodes found along the path,establish priority sequence with BBF(best bin first)and expand from the brother nodes to their leaves,find the nearest and second nearest neighbors according to the similarity degree of the 128-dimensional key points between the potential matches until the sequence was empty or the algorithm exceeded its 200 times constraint. Thus 172 pairs of rough cotton matches of key points in 2 images were acquired,but there was still a possibility that there might be wrong matches among rough matches.In order to eliminate the wrong matches,estimate fundamental matrix with RANSAC(random sample consensus)algorithm and recover epipolar geometry constraint;during each sampling,use 8-point algorithm to compute an initial fundamental matrix,calculate the distance from every point to its corresponding epipolar line and count the ones within the threshold as inliers.Repeat this step and choose the fundamental matrix with the most inliers or the least error(in case there were more than one fundamental matrix with the same inlier number)as the final output fundamental matrix,and the corresponding inliers were called refined cotton matches.Using the RANSAC algorithm we got 151 pairs of refined cotton matches,and there were no wrong matches in the refined matches,which helped make the results of cotton three-dimensional(3D)reconstruction more accurate.Calibrate the camera to get its intrinsic matrix,and then get essential matrix according to fundamental matrix and intrinsic matrix through transformation.Split essential matrix and the camera′s external rotation matrix and translation vector were acquired.To this point,inputs needed for cotton 3D reconstruction were all ready,and they were 151 pairs of refined matches of cotton,intrinsic matrix,external rotation matrix and translation vector.Put these inputs into the equations and 2D cotton image coordinates could be transformed into 3D coordinates,and the 3D reconstruction of cotton point cloud on the plant was realized.At last the 3D coordinate values of every cotton were obtained and their centroid coordinate values were calculated.Result showed that all 11 pieces of cotton were all successfully 3D positioned,with an average error of 0.039 3m compared with manual measurement,which proves the calculated data are valid and this binocular vision system is reliable enough for practical application.
robots;image processing;vision;cotton;SIFT features;binocular vision;binary tree;RANSAC algorithm
10.11975/j.issn.1002-6819.2016.06.025
S24;TP242.6
A
1002-6819(2016)-06-0182-07
2015-12-01
2016-01-28
朱镕杰(1991-),男,江蘇南通人,主要從事雙目視覺技術(shù)研究。南京 南京農(nóng)業(yè)大學工學院 210031。Email:zrj564366@126.com
※通信作者:王 玲(1966-),女,江西南昌人,副教授,博士,碩士生導師,主要從事圖像處理與模式識別技術(shù)研究。南京 南京農(nóng)業(yè)大學工學院 210031。Email:Lingw@njau.edu.cn