Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[project]
name = "stream"
version = "0.5.3"
version = "0.5.4"
description = "Groundlight Stream Processor - Container for analyzing video using RTSP etc"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"framegrab>=0.11.3",
"groundlight>=0.22.6",
"groundlight>=0.23.3",
"jsonformatter>=0.3.4",
"numpy<2.0.0",
"opencv-python-headless>=4.11.0.86",
Expand Down
10 changes: 5 additions & 5 deletions src/stream/grabber.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def grab(self):
start = time.time()
frame = cv2.imread(self.filename_list[0], cv2.IMREAD_GRAYSCALE)
self.filename_list.pop(0)
logger.debug(f"read the frame in {1000*(time.time()-start):.1f}ms")
logger.debug(f"read the frame in {1000 * (time.time() - start):.1f}ms")

return frame

Expand Down Expand Up @@ -112,7 +112,7 @@ def grab(self):
if not ret:
raise RuntimeWarning("could not read frame from {self.capture=}. possible end of file.")
now = time.time()
logger.debug(f"read the frame in {1000*(now-start):.1f}ms")
logger.debug(f"read the frame in {1000 * (now - start):.1f}ms")
return frame


Expand Down Expand Up @@ -145,7 +145,7 @@ def grab(self):
if not ret:
raise RuntimeWarning("could not read frame from {self.capture=}")
now = time.time()
logger.debug(f"read the frame in {1000*(now-start):.1f}ms")
logger.debug(f"read the frame in {1000 * (now - start):.1f}ms")
return frame


Expand Down Expand Up @@ -194,7 +194,7 @@ def grab(self):
if not ret:
logger.error(f"could not read frame from {self.capture=}")
now = time.time()
logger.debug(f"read the frame in {1000*(now-start):.1f}ms")
logger.debug(f"read the frame in {1000 * (now - start):.1f}ms")
return frame

def _grab_implementation(self) -> np.ndarray:
Expand Down Expand Up @@ -278,7 +278,7 @@ def grab(self):
if not ret:
logger.error(f"failed to effectively reset stream {self.stream=} / {self.best_video.url=}")
now = time.time()
logger.debug(f"read the frame in {1000*(now-start):.1f}ms")
logger.debug(f"read the frame in {1000 * (now - start):.1f}ms")
self.capture.release()
return frame

Expand Down
10 changes: 5 additions & 5 deletions src/stream/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def process_single_frame(frame: cv2.Mat, gl: Groundlight, detector: str) -> None
is_success, buffer = cv2.imencode(".jpg", frame)
io_buf = io.BytesIO(buffer) # type: ignore
end = time.time()
logger.info(f"Prepared the image in {1000*(end-start):.1f}ms")
logger.info(f"Prepared the image in {1000 * (end - start):.1f}ms")

# Submit image to Groundlight
start = time.time()
image_query = gl.ask_async(detector=detector, image=io_buf)
end = time.time()
logger.debug(f"{image_query=}")
logger.info(f"API time for image {1000*(end-start):.1f}ms")
logger.info(f"API time for image {1000 * (end - start):.1f}ms")
except Exception as e:
logger.error(f"Exception while processing frame : {e}", exc_info=True)

Expand Down Expand Up @@ -126,7 +126,7 @@ def run_capture_loop( # noqa: PLR0912 PLR0913
continue

now = time.time()
logger.debug(f"Captured frame in {now-start:.3f}s, size {frame.shape}")
logger.debug(f"Captured frame in {now - start:.3f}s, size {frame.shape}")

# Apply cropping if configured
if crop_region:
Expand Down Expand Up @@ -163,7 +163,7 @@ def run_capture_loop( # noqa: PLR0912 PLR0913
actual_delay = desired_delay - elapsed_time
if actual_delay < 0:
logger.warning(
f"Cannot maintain {fps} FPS. Processing took {now-start:.3f}s (queue size: {queue.qsize()})"
f"Cannot maintain {fps} FPS. Processing took {now - start:.3f}s (queue size: {queue.qsize()})"
)
else:
logger.debug(f"Waiting {actual_delay:.3f}s until next frame")
Expand All @@ -178,7 +178,7 @@ def print_banner(gl: Groundlight, args: argparse.Namespace) -> None:
print(f" Target Detector: {detector}")
print(f" Groundlight Endpoint: {gl.endpoint}")
print(f" Whoami: {gl.whoami()}")
print(f" Frames/sec: {args.fps} (Seconds/frame: {1/args.fps:.3f})")
print(f" Frames/sec: {args.fps} (Seconds/frame: {1 / args.fps:.3f})")
print(f" Motion Detection: {motdet}")
print("==================================================")

Expand Down
22 changes: 11 additions & 11 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.