Update native RC1 samples and supported device documentation
Browse files- README.md +14 -0
- opencv_sample.py +57 -0
README.md
CHANGED
|
@@ -51,6 +51,10 @@ Typical Metro deployments include:
|
|
| 51 |
|
| 52 |
## Prerequisites
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
- Python 3.11+
|
| 55 |
- OpenCV and NumPy
|
| 56 |
|
|
@@ -86,7 +90,16 @@ baseline, and classifies each frame as `normal`, `dark`, `bright`, or
|
|
| 86 |
`sudden-change`.
|
| 87 |
The annotated frames are written to `output_opencv.mp4`.
|
| 88 |
|
|
|
|
|
|
|
|
|
|
| 89 |
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
import cv2
|
| 91 |
import numpy as np
|
| 92 |
|
|
@@ -139,6 +152,7 @@ cap.release()
|
|
| 139 |
writer.release()
|
| 140 |
print(f"Light-level anomalies detected: {anomalies}", flush=True)
|
| 141 |
```
|
|
|
|
| 142 |
|
| 143 |
**Device targets:**
|
| 144 |
|
|
|
|
| 51 |
|
| 52 |
## Prerequisites
|
| 53 |
|
| 54 |
+
Target stack: Intel DLStreamer **2026.3.0 RC1** with the matching OpenVINO GenAI bundle **2026.5.0.0.dev20261030** (OpenVINO Runtime **2026.5.0.dev20261030**).
|
| 55 |
+
Use the [native RC1 setup](../README.md#native-rc1-runtime) before running these samples; this is a development stack, not a stable release.
|
| 56 |
+
See the [device validation matrix](../DEVICE_SUPPORT_MATRIX.md) for measured CPU, GPU, and NPU results.
|
| 57 |
+
|
| 58 |
- Python 3.11+
|
| 59 |
- OpenCV and NumPy
|
| 60 |
|
|
|
|
| 90 |
`sudden-change`.
|
| 91 |
The annotated frames are written to `output_opencv.mp4`.
|
| 92 |
|
| 93 |
+
The full sample is in [opencv_sample.py](opencv_sample.py); run it with `python3 opencv_sample.py` or copy the code below.
|
| 94 |
+
|
| 95 |
+
<!-- sample: opencv_sample.py -->
|
| 96 |
```python
|
| 97 |
+
# SPDX-License-Identifier: MIT
|
| 98 |
+
# Copyright (C) Intel Corporation
|
| 99 |
+
#
|
| 100 |
+
# Light-Level Anomaly Detection: OpenCV sample.
|
| 101 |
+
# See README.md for prerequisites and inputs. Run: python3 opencv_sample.py
|
| 102 |
+
|
| 103 |
import cv2
|
| 104 |
import numpy as np
|
| 105 |
|
|
|
|
| 152 |
writer.release()
|
| 153 |
print(f"Light-level anomalies detected: {anomalies}", flush=True)
|
| 154 |
```
|
| 155 |
+
<!-- /sample -->
|
| 156 |
|
| 157 |
**Device targets:**
|
| 158 |
|
opencv_sample.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-License-Identifier: MIT
|
| 2 |
+
# Copyright (C) Intel Corporation
|
| 3 |
+
#
|
| 4 |
+
# Light-Level Anomaly Detection: OpenCV sample.
|
| 5 |
+
# See README.md for prerequisites and inputs. Run: python3 opencv_sample.py
|
| 6 |
+
|
| 7 |
+
import cv2
|
| 8 |
+
import numpy as np
|
| 9 |
+
|
| 10 |
+
INPUT_VIDEO = "test_video.mp4"
|
| 11 |
+
DARK_BOUND = 40.0 # mean luminance below this is underexposed
|
| 12 |
+
BRIGHT_BOUND = 215.0 # mean luminance above this is overexposed
|
| 13 |
+
JUMP_BOUND = 35.0 # frame-to-frame luminance jump that counts as sudden
|
| 14 |
+
|
| 15 |
+
cap = cv2.VideoCapture(INPUT_VIDEO)
|
| 16 |
+
fps = cap.get(cv2.CAP_PROP_FPS) or 30.0
|
| 17 |
+
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
| 18 |
+
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
| 19 |
+
writer = cv2.VideoWriter(
|
| 20 |
+
"output_opencv.mp4", cv2.VideoWriter_fourcc(*"mp4v"), fps, (width, height))
|
| 21 |
+
|
| 22 |
+
prev_level = None
|
| 23 |
+
frame_idx = 0
|
| 24 |
+
anomalies = 0
|
| 25 |
+
while True:
|
| 26 |
+
ok, frame = cap.read()
|
| 27 |
+
if not ok:
|
| 28 |
+
break
|
| 29 |
+
frame_idx += 1
|
| 30 |
+
|
| 31 |
+
v = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)[:, :, 2]
|
| 32 |
+
level = float(np.mean(v))
|
| 33 |
+
|
| 34 |
+
status = "normal"
|
| 35 |
+
if level < DARK_BOUND:
|
| 36 |
+
status = "dark"
|
| 37 |
+
elif level > BRIGHT_BOUND:
|
| 38 |
+
status = "bright"
|
| 39 |
+
elif prev_level is not None and abs(level - prev_level) >= JUMP_BOUND:
|
| 40 |
+
status = "sudden-change"
|
| 41 |
+
prev_level = level
|
| 42 |
+
|
| 43 |
+
if status != "normal":
|
| 44 |
+
anomalies += 1
|
| 45 |
+
print(f"Frame {frame_idx}: LIGHT ANOMALY ({status}) level={level:.1f}",
|
| 46 |
+
flush=True)
|
| 47 |
+
color = (0, 255, 0) if status == "normal" else (0, 0, 255)
|
| 48 |
+
label = f"level={level:.1f} {status}"
|
| 49 |
+
(_, text_height), _ = cv2.getTextSize(
|
| 50 |
+
label, cv2.FONT_HERSHEY_SIMPLEX, 5.0, 2)
|
| 51 |
+
cv2.putText(frame, label, (10, text_height + 10),
|
| 52 |
+
cv2.FONT_HERSHEY_SIMPLEX, 5.0, color, 2)
|
| 53 |
+
writer.write(frame)
|
| 54 |
+
|
| 55 |
+
cap.release()
|
| 56 |
+
writer.release()
|
| 57 |
+
print(f"Light-level anomalies detected: {anomalies}", flush=True)
|