path='D:\Python\LearnOpenCV\pics'
for picname in os.listdir(path):
picpath=path+"\\"+picname
img=cv.imread(picpath,0)
thresh,img1=cv.threshold(img,111,255,cv.THRESH_BINARY)
contours,hierarchy=cv.findContours(img1,cv.RETR_LIST,cv.CHAIN_APPROX_NONE)
print("輪廓尺寸:",contours[0].shape)
print("輪廓前三點:\n",contours[0][:3])

----------------
由于嫌C++寫起來麻煩,在試驗演算法可行性的時候就想先用python實作。
發現cv-python的輪廓竟然是三維陣列,驚呆了。
C++的OpenCV就是二維陣列,直接能拿來做矩陣變換。
想必cv-python應該是在C++后面出的吧,特意多一維出來,究竟是哪個天才設計的,居心何在?
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/38472.html
標籤:OpenCV
