Skip to content

Commit

Permalink
utils/apply_flow: is_zero_flow used to eliminate duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
CSRavasio committed Nov 24, 2021
1 parent 4813f94 commit 5cc0c47
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/oflibnumpy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def apply_flow(flow: np.ndarray, target: np.ndarray, ref: str, mask: np.ndarray
raise TypeError("Error applying flow to a target: Mask needs to be boolean")

field = flow.astype('float32')
if np.all(np.linalg.norm(flow, axis=-1) <= DEFAULT_THRESHOLD): # If the flow field is actually 0 or very close
if is_zero_flow(flow, thresholded=True):
return target
if ref == 't':
field *= -1 # Due to the direction in which cv2.remap defines the flow vectors
Expand Down

0 comments on commit 5cc0c47

Please sign in to comment.