Skip to content

Commit

Permalink
updates motion estimation
Browse files Browse the repository at this point in the history
+ limit to motion to translation + rotation
+ set a higher threshold on the effective number of matched points (3 -> 10)
  • Loading branch information
jiupinjia authored Oct 25, 2020
1 parent a1bfc40 commit 94ae8f4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions skyboxengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ def skybox_tracking(self, frame, frame_prev, skymask):
curr_gray = np.array(255*curr_gray, dtype=np.uint8)

mask = np.array(skymask[:,:,0] > 0.99, dtype=np.uint8)
mask = cv2.erode(mask, np.ones([20, 20]))

template_size = int(0.05*mask.shape[0])
mask = cv2.erode(mask, np.ones([template_size, template_size]))

# ShiTomasi corner detection
prev_pts = cv2.goodFeaturesToTrack(
Expand All @@ -129,12 +131,14 @@ def skybox_tracking(self, frame, frame_prev, skymask):

prev_pts, curr_pts = removeOutliers(prev_pts, curr_pts)

if curr_pts.shape[0] < 3:
if curr_pts.shape[0] < 10:
print('no good point matched')
return np.array([[1, 0, 0], [0, 1, 0]], dtype=np.float32)

m = cv2.estimateAffinePartial2D(
np.array(prev_pts), np.array(curr_pts))[0]
# limit the motion to translation + rotation
dxdyda = estimate_partial_transform((
np.array(prev_pts), np.array(curr_pts)))
m = build_transformation_matrix(dxdyda)

return m

Expand Down

0 comments on commit 94ae8f4

Please sign in to comment.