Skip to content

Commit

Permalink
add fps attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Victorlouisdg committed Feb 20, 2024
1 parent 899aedb commit 6cd7645
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __init__(
self.write_lock_shm: Optional[shared_memory.SharedMemory] = None
self.read_lock_shm: Optional[shared_memory.SharedMemory] = None

self.fps = None # set in setup
self.camera_period = None # set in setup

def start(self) -> None:
Expand Down Expand Up @@ -147,9 +148,9 @@ def _setup(self) -> None:
timestamp = np.array([time.time()])
intrinsics = self._camera.intrinsics_matrix()

camera_fps = self._camera.fps
fps = np.array([self._camera.fps], dtype=np.float64)
self.camera_period = 1 / camera_fps
self.fps = self._camera.fps
fps = np.array([self.fps], dtype=np.float64)
self.camera_period = 1 / self.fps

write_lock = np.array([False], dtype=np.bool_)
read_lock = np.array([0], dtype=np.int_)
Expand Down Expand Up @@ -319,6 +320,8 @@ def __init__(
self.write_lock_shm_array: np.ndarray = np.ndarray((1,), dtype=np.bool_, buffer=self.write_lock_shm.buf)
self.read_lock_shm_array: np.ndarray = np.ndarray((1,), dtype=np.int_, buffer=self.read_lock_shm.buf)

self.fps = self.fps_shm_array[0]

# The shape of the image is not known in advance, so we need to retrieve it from the shared memory block.
rgb_shape = tuple(self.rgb_shape_shm_array[:])
self.rgb_shm_array: np.ndarray = np.ndarray(rgb_shape, dtype=np.uint8, buffer=self.rgb_shm.buf)
Expand Down

0 comments on commit 6cd7645

Please sign in to comment.