Skip to content

Commit 68aac33

Browse files
authored
Merge pull request #2 from JosephPenaQuino/master
Thanks for your contribution!
2 parents e239b3a + 6d1566c commit 68aac33

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sparse-solution.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
2727
# Calculates sparse optical flow by Lucas-Kanade method
2828
# https://docs.opencv.org/3.0-beta/modules/video/doc/motion_analysis_and_object_tracking.html#calcopticalflowpyrlk
29+
prev = cv.goodFeaturesToTrack(prev_gray, mask = None, **feature_params)
2930
next, status, error = cv.calcOpticalFlowPyrLK(prev_gray, gray, prev, None, **lk_params)
3031
# Selects good feature points for previous position
31-
good_old = prev[status == 1]
32+
good_old = prev[status == 1].astype(int)
3233
# Selects good feature points for next position
33-
good_new = next[status == 1]
34+
good_new = next[status == 1].astype(int)
3435
# Draws the optical flow tracks
3536
for i, (new, old) in enumerate(zip(good_new, good_old)):
3637
# Returns a contiguous flattened array as (x, y) coordinates for new point

0 commit comments

Comments
 (0)