Skip to content

Commit

Permalink
more debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
timmarkhuff committed Sep 4, 2024
1 parent ae41541 commit 31d8125
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/framegrab/grabber.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ def _set_cv2_resolution(self) -> None:
do nothing. This is because setting the resolution of a cv2.VideoCapture object is non-trivial and
can take multiple seconds, so we should only do it when something has changed.
"""
t1 = time.time()
resolution = self.config.get("options", {}).get("resolution")
if resolution is None:
return
Expand All @@ -500,6 +501,9 @@ def _set_cv2_resolution(self) -> None:
current_height = int(self.capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
if new_height != current_height:
self.capture.set(cv2.CAP_PROP_FRAME_HEIGHT, new_height)

t2 = time.time()
logger.info(f'debug | _set_cv2_resolution: {t2 - t1}')

def apply_options(self, options: dict) -> None:
"""Update generic options such as crop and zoom as well as
Expand Down Expand Up @@ -708,12 +712,7 @@ def _apply_camera_specific_options(self, options: dict) -> None:
self._set_cv2_resolution()

# set the buffer size to 1 to always get the most recent frame
result = self.capture.set(cv2.CAP_PROP_BUFFERSIZE, 0)
if result:
logger.info(f'Succeeded setting buffer size to 0')
else:
logger.info(f'Failed setting buffer size to 0')
result = self.capture.set(cv2.CAP_PROP_BUFFERSIZE, 1)
self.capture.set(cv2.CAP_PROP_BUFFERSIZE, 1)

@staticmethod
def _run_system_command(command: str) -> str:
Expand Down

0 comments on commit 31d8125

Please sign in to comment.