markdown
#說明
這裡是使用 Opencv 的套件 findcontour 做邊緣偵測等辨識。
- 參考 : https://gogoprivateryan.blogspot.com/2015/08/opencv-2-opencv-python.html
#操作流程
##Code
```
import numpy as np
import cv2
im = cv2.imread('t.png')
imgray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(imgray, 127, 255, 0)
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
print("there are " + str(len(contours)) + " contours")
cnt = contours[0]
print("there are " + str(len(cnt)) + " points in contours[0]")
print(cnt)
cnt = contours[1]
print("there are " + str(len(cnt)) + " points in contours[1]")
print(cnt)
cv2.namedWindow('im', cv2.WINDOW_NORMAL)
cv2.resizeWindow("im", 640, 480)
cv2.imshow('im', im)
cv2.waitKey(0)
cv2.destroyAllWindows()
```
##DEMO
原圖
計算的邊緣點
留言
張貼留言