2017-08-04 15 views
1

私はこれらの三角形の角のピクセル値を見つけようとしています。 出力イメージのポイントをマークすることはできますが、印刷用の変数として取得する方法はわかりません。これらの角の値を変数に格納したい。 Thisは入力画像 "triangles.png"です。 Thisは出力イメージです。三角形の角を見つける

import cv2 
import numpy as np 
from matplotlib import pyplot as plt 
filename = 'triangles.png' 
img = cv2.imread(filename) 
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) 
gray = np.float32(gray) 
dst = cv2.cornerHarris(gray,2,3,0.04) 
##result is dilated for marking the corners, not important 
dst = cv2.dilate(dst,None) 
img[dst>0.01*dst.max()]=[250,0,0] 
cv2.imshow('dst',img) 
if cv2.waitKey(0) & 0xff == 27: 
    cv2.destroyAllWindows() 
+1

ドキュメントの例で何が問題になっていますか? http://docs.opencv.org/2.4/doc/tutorials/features2d/trackingmotion/harris_detector/harris_detector.html – Piglet

答えて

1
dst = cv2.cornerHarris(gray, 2, 3, 0.04) 
x, y = np.nonzero(dst > 0.01 * dst.max()) 

X、Y - 隅のx座標とy座標とnumpyのアレイ。後で使用することができます。

coordinates = zip(x, y) 
関連する問題