Skip to content

Commit

Permalink
add exec time measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
nlef committed Aug 5, 2024
1 parent ccfffbd commit 41b942f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bot/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,13 @@ def _set_cv2_params(self):
@cam_light_toggle
def take_raw_frame(self, rgb: bool = True) -> ndarray:
with self._camera_lock:
st = time.time() * 1000
self.cam_cam.open(self._host)
self._set_cv2_params()
success, image = self.cam_cam.read()
self.cam_cam.release()
et = time.time() *1000
logger.debug(f"_take_raw_frame cam read execution time: {et-st} millis")

if not success:
logger.debug("failed to get camera frame for photo")
Expand Down Expand Up @@ -382,9 +385,12 @@ def write_video():

with self._camera_lock:
cv2.setNumThreads(self._threads)
st = time.time() * 1000
self.cam_cam.open(self._host)
self._set_cv2_params()
success, frame = self.cam_cam.read()
et = time.time() *1000
logger.debug(f"take_video cam read first frame execution time: {et-st} millis")

if not success:
logger.debug("failed to get camera frame for video")
Expand All @@ -405,7 +411,10 @@ def write_video():
threading.Thread(target=write_video, args=()).start()
t_end = time.time() + self._video_duration
while success and time.time() <= t_end:
st = time.time() * 1000
success, frame_loc = self.cam_cam.read()
et = time.time() * 1000
logger.debug(f"take_video cam read frame execution time: {et - st} millis")
try:
frame_queue.put(frame_loc, block=False)
except Exception as ex:
Expand Down

0 comments on commit 41b942f

Please sign in to comment.