WebcamCapture API#
Bases: AnyWidget
Webcam capture widget with manual and interval snapshots.
The widget shows a live webcam preview plus a capture button and an
auto-capture toggle. When capturing is enabled, the browser updates
image_base64 on the cadence specified by interval_ms.
Examples:
Create a WebcamCapture widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
interval_ms
|
int
|
Capture interval in milliseconds when auto-capture is on. |
1000
|
facing_mode
|
str
|
Camera facing mode ("user" or "environment"). |
'user'
|
Source code in wigglystuff/webcam_capture.py
get_bytes #
Return the captured frame as raw bytes.
Source code in wigglystuff/webcam_capture.py
get_pil #
Return the captured frame as a PIL Image.
Source code in wigglystuff/webcam_capture.py
Synced traitlets#
| Traitlet | Type | Notes |
|---|---|---|
image_base64 |
str |
PNG data URL for the latest frame. |
capturing |
bool |
Enable auto-capture mode. |
interval_ms |
int |
Auto-capture interval in milliseconds. |
facing_mode |
str |
Camera facing mode ("user" or "environment"). |
ready |
bool |
True when the preview stream is ready. |
error |
str |
Error message when webcam access fails. |