Skip to content

Commit

Permalink
Fix the order (x,y) in top left corner variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Agustín Castro committed Feb 26, 2024
1 parent c86c7f1 commit bed08ed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion demos/camera_motion/src/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def run():
"--fixed-camera-scale",
type=float,
default=0,
help="Scale of the fixed camera, set to 0 to disable. Note that this only works for translation",
help="Scale of the fixed camera, set to 0 to disable.",
)
parser.add_argument(
"--draw-absolute-grid",
Expand Down
7 changes: 4 additions & 3 deletions norfair/drawing/fixed_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def adjust_frame(
np.array(self._background.shape[:2]) // 2
- np.array(frame.shape[:2]) // 2
)
self.top_left = self.top_left[::-1]
else:
self._background = (self._background * self._attenuation_factor).astype(
frame.dtype
Expand All @@ -109,7 +110,7 @@ def adjust_frame(
# top_left_translation o rel_to_abs
if isinstance(coord_transformation, HomographyTransformation):
top_left_translation = np.array(
[[1, 0, self.top_left[1]], [0, 1, self.top_left[0]], [0, 0, 1]]
[[1, 0, self.top_left[0]], [0, 1, self.top_left[1]], [0, 0, 1]]
)
full_transformation = (
top_left_translation @ coord_transformation.inverse_homography_matrix
Expand All @@ -126,8 +127,8 @@ def adjust_frame(

full_transformation = np.array(
[
[1, 0, self.top_left[1] - coord_transformation.movement_vector[0]],
[0, 1, self.top_left[0] - coord_transformation.movement_vector[1]],
[1, 0, self.top_left[0] - coord_transformation.movement_vector[0]],
[0, 1, self.top_left[1] - coord_transformation.movement_vector[1]],
]
)
background_with_current_frame = cv2.warpAffine(
Expand Down
1 change: 1 addition & 0 deletions norfair/drawing/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def draw(self, frame, tracked_objects, coord_transform=None):
np.array(self._background.shape[:2]) // 2
- np.array(frame.shape[:2]) // 2
)
self.top_left = self.top_left[::-1]
else:
self._background = (self._background * self._attenuation_factor).astype(
frame.dtype
Expand Down

0 comments on commit bed08ed

Please sign in to comment.