我是新來的,我需要你的幫助! 我正在做一個項目(我的學校的手勢識別),所以imread的圖像是我的手。我想找到點之間的角度(在鏈碼)蟒蛇,openCV,鏈碼 - >我想找點之間的角度
預先感謝您:)
import cv2
import cv2.cv as cv
import numpy as np
# Create display windows
cv2.namedWindow("input", cv.CV_WINDOW_AUTOSIZE)
cv2.namedWindow("output", cv.CV_WINDOW_AUTOSIZE)
# Parameters
blur_ksize = 5
thresh_Tlower = 100
kernel = np.ones((5,5),np.uint8)
# Imread the image
img = cv2.imread ("0_dani_mask.png",0)
# Funding the contours of the hand
contours, hierarchy = cv2.findContours(img.copy(), cv2.RETR_TREE, cv.CV_CHAIN_APPROX_NONE)
# contour = the biggest (area)
big_contour = contours[0]
num_points_cnt = len(big_contour)
print "num_points_cnt = ", num_points_cnt
theta = np.zeros(num_points_cnt, np.uint8)
P0 = big_contour[0]
x0 = P0[0,0]
y0 = P0[0,1]
for n in range(1, num_points_cnt):
P = big_contour[n]
x = P[0,0]
y = P[0,1]
dX = x - x0
dY = y - y0
angulo = np.arctan(dY/dX)
theta[n] = angulo
x0 = x
y0 = y
P = big_contour[0]
x = P[0,0]
y = P[0,1]
dX = x - x0
dY = y - y0
angulo = np.arctan(dY/dX)
theta[0] = angulo
print theta
程序卻對我說:
num_points_cnt = 2031 [ 0 0 0 ...,0 0 0] /Users/dani/Desktop/myproject/src/kasksasa.py:47:RuntimeWarning:除以int_scalars中遇到的零 angulo = np.tanh(dY/dX)
顯然,錯誤消息不是最新的。你的代碼中沒有'tanh'。 –