precompute the layout offsets and dimensions

This commit is contained in:
Blake Blackshear
2021-06-12 07:23:14 -05:00
parent cbd418b8de
commit babe1dd1eb
2 changed files with 23 additions and 16 deletions
+17 -1
View File
@@ -135,7 +135,13 @@ class BirdsEyeFrameManager:
)
channel_dims = self.cameras[camera]["channel_dims"]
copy_yuv_to_position(position, self.frame, self.layout_dim, frame, channel_dims)
copy_yuv_to_position(
self.frame,
self.layout_offsets[position],
self.layout_frame_shape,
frame,
channel_dims,
)
def camera_active(self, object_box_count, motion_box_count):
if self.mode == "continuous":
@@ -192,6 +198,16 @@ class BirdsEyeFrameManager:
self.active_cameras = set()
self.layout_offsets = []
# calculate the x and y offset for each position in the layout
for position in range(0, len(self.camera_layout)):
y_offset = self.layout_frame_shape[0] * math.floor(
position / self.layout_dim
)
x_offset = self.layout_frame_shape[1] * (position % self.layout_dim)
self.layout_offsets.append((y_offset, x_offset))
removed_cameras = self.active_cameras.difference(active_cameras)
added_cameras = active_cameras.difference(self.active_cameras)