Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit f7dbd57

Browse files
authored
YOLO webcam example - add assert for webcam load (#202) (#204)
* YOLO webcam example - add assert for webcam load * update readme to note other options for annotate * formatting
1 parent c47bfb8 commit f7dbd57

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

integrations/ultralytics/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,14 @@ python annotate.py \
151151
zoo:cv/detection/yolo_v3-spp/pytorch/ultralytics/coco/pruned_quant-aggressive_94 \
152152
--source 0 \
153153
--quantized-inputs \
154-
--image-shape 416 416
154+
--image-shape 416 416 \
155+
--no-save # webcam only
155156
```
156157

158+
In addition to webcam `--source` can take a path to a `.jpg` file, directory or glog pat
159+
of `.jpg` files, or path to a `.mp4` video file. If source is an integer and no
160+
corresponding webcam is available, an exception will be raised.
161+
157162

158163
### Benchmarking
159164
`benchmarking.py` is a script for benchmarking sparsified and quantized YOLOv3

integrations/ultralytics/deepsparse/deepsparse_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ def __iter__(self) -> Iterator[Tuple[numpy.ndarray, numpy.ndarray]]:
199199
self._stream.release()
200200
cv2.destroyAllWindows()
201201
break
202-
_, frame = self._stream.read()
202+
loaded, frame = self._stream.read()
203+
204+
assert loaded, f"Could not load image from webcam {self._camera}"
205+
203206
frame = cv2.flip(frame, 1) # flip left-right
204207
yield load_image(frame, image_size=self._image_size)
205208

0 commit comments

Comments
 (0)