Reputation: 18477
I'm trying to make an LK tracker in OpenCV 2.3.1 with python bindings. When I do
calcOpticalFlowPyrLK(img1, img2,
template_pt, target_pt, status, err,
(win_size_lk, win_size_lk), 0, TERM_CRITERIA_EPS,
(TERM_CRITERIA_EPS | TERM_CRITERIA_COUNT, 10, 0.03), eig)
I'm getting
TypeError: is not a numpy array
where
img1, img2 - iplimage
template_pt, target_pt - A List consisting of tuples with two integers eg. [(120,140),(300,400),..]
win_size_lk = 10
eig = 0.001
status = ""
err = None
More info about cv2.calcOpticalFlowPyrLK() is given here
When I set
eig = np.array([(0.0,1.0),(1.0,0.0)])
It gives me the following error
TypeError: only length-1 arrays can be converted to Python scalars
What could be the problem here ?
Upvotes: 2
Views: 3443
Reputation: 18477
I have figured out the problem.
img1, img2 should be numpy array
template_pt, target_pt should be numpy array
So,
target_pt, status, track_error = calcOpticalFlowPyrLK(img1,
img2,
template_pt,
target_pt,
winSize=(win_size_lk, win_size_lk),
flags = OPTFLOW_USE_INITIAL_FLOW,
criteria = (TERM_CRITERIA_EPS | TERM_CRITERIA_COUNT, 10, 0.03))
works well.
Upvotes: 1