Compare commits

..
Author SHA1 Message Date
henryruhs 1434c2c9bc use ideal pipesize for our task 2026-07-28 13:39:49 +02:00
Henry RuhsandGitHub a394d48f34 avoid tobytes copy (#1208) 2026-07-28 10:02:08 +02:00
HarisreedharandGitHub 5e8a37110d Restrict the preview frame slider and the reader seek to the last frame index (#1207)
* fix index bug

* fix rounding bug
2026-07-27 18:51:35 +05:30
4 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -11,7 +11,7 @@ FACE_STORE : FaceStore = {}
def get_faces(vision_frame : VisionFrame) -> Optional[List[Face]]: def get_faces(vision_frame : VisionFrame) -> Optional[List[Face]]:
if numpy.any(vision_frame): if numpy.any(vision_frame):
vision_hash = create_hash(vision_frame.tobytes()) vision_hash = create_hash(vision_frame.data)
if FACE_STORE.get(vision_hash): if FACE_STORE.get(vision_hash):
return FACE_STORE.get(vision_hash).get('faces') return FACE_STORE.get(vision_hash).get('faces')
@@ -21,7 +21,7 @@ def get_faces(vision_frame : VisionFrame) -> Optional[List[Face]]:
def set_faces(vision_frame : VisionFrame, faces : List[Face]) -> None: def set_faces(vision_frame : VisionFrame, faces : List[Face]) -> None:
if numpy.any(vision_frame): if numpy.any(vision_frame):
vision_hash = create_hash(vision_frame.tobytes()) vision_hash = create_hash(vision_frame.data)
FACE_STORE.setdefault(vision_hash, FACE_STORE.setdefault(vision_hash,
{ {
'lock': threading.Lock() 'lock': threading.Lock()
@@ -30,7 +30,7 @@ def set_faces(vision_frame : VisionFrame, faces : List[Face]) -> None:
def resolve_lock(vision_frame : VisionFrame) -> threading.Lock: def resolve_lock(vision_frame : VisionFrame) -> threading.Lock:
if numpy.any(vision_frame): if numpy.any(vision_frame):
vision_hash = create_hash(vision_frame.tobytes()) vision_hash = create_hash(vision_frame.data)
return FACE_STORE.setdefault(vision_hash, return FACE_STORE.setdefault(vision_hash,
{ {
'lock': threading.Lock() 'lock': threading.Lock()
+1 -1
View File
@@ -66,7 +66,7 @@ def run_ffmpeg(commands : List[Command]) -> subprocess.Popen[bytes]:
def open_ffmpeg(commands : List[Command]) -> subprocess.Popen[bytes]: def open_ffmpeg(commands : List[Command]) -> subprocess.Popen[bytes]:
commands = ffmpeg_builder.run(commands) commands = ffmpeg_builder.run(commands)
return subprocess.Popen(commands, stdin = subprocess.PIPE, stdout = subprocess.PIPE) return subprocess.Popen(commands, stdin = subprocess.PIPE, stdout = subprocess.PIPE, pipesize = 1024 * 1024)
def create_video_reader(video_path : str, frame_number : int, video_metadata : VideoReaderMetadata) -> subprocess.Popen[bytes]: def create_video_reader(video_path : str, frame_number : int, video_metadata : VideoReaderMetadata) -> subprocess.Popen[bytes]:
+1 -1
View File
@@ -106,7 +106,7 @@ def start(webcam_device_id : int, webcam_mode : WebcamMode, webcam_resolution :
yield capture_vision_frame yield capture_vision_frame
if webcam_mode in [ 'udp', 'v4l2' ]: if webcam_mode in [ 'udp', 'v4l2' ]:
try: try:
stream.stdin.write(capture_vision_frame.tobytes()) stream.stdin.write(capture_vision_frame.data)
except Exception: except Exception:
pass pass
+1 -1
View File
@@ -133,7 +133,7 @@ def get_writer(video_path : str, temp_video_fps : Fps, temp_video_resolution : R
def write_video_frame(video_writer : VideoWriter, vision_frame : VisionFrame) -> None: def write_video_frame(video_writer : VideoWriter, vision_frame : VisionFrame) -> None:
video_writer.get('process').stdin.write(vision_frame.tobytes()) video_writer.get('process').stdin.write(vision_frame.data)
def close_video_writer(video_writer : VideoWriter) -> bool: def close_video_writer(video_writer : VideoWriter) -> bool: