我是新来的,我需要你的帮助! 我正在做一个项目(我的学校的手势识别),所以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'。 –