Esacode

Docs / Blocks / Devices

Camera capture

Takes pictures or a video with a camera plugged into the worker (USB, built-in, or a network stream), with a live preview.

Runs on a worker (Python) Devices Version 1.0 Code you can open and adapt

How it works

Camera: 0 for the first camera of the worker, 1 for the next, a device path (/dev/video2) or a stream address (rtsp://…, http://…/video). Modes: one picture; pictures every few seconds; a video; or Until stopped, which shows the camera live and takes a picture each time a message asks for one.

While it runs it shows a live preview (connect its live telemetry to an Images view), and it answers messages on the channel named below: {"control": "picture"} takes a picture now, {"control": "stop"} ends. On Windows, a worker installed as a service may not be allowed to use cameras: run it in a window (esasim-worker run) for this block.

Outputs

OutputGivesWhat it is
Pictures
pictures
Files
jpg, png
picture_0001.jpg …
Video
video
Files
mp4
Live telemetry
telemetry
Live telemetryWhat the block sends while it runs, for views such as Chart or 3D view.

Settings

SettingDefaultWhat it does
Camera
camera
0 0, 1 … a device path, or rtsp:// / http:// address
Mode
mode
one picture
One of: one picture, pictures, video, until stopped
Pictures
count
10
From 1 to 100000
Every (seconds)
every
1
From 0 to 86400
Video length or longest wait (seconds)
duration
10
From 1 to 86400
Width (pixels)
width
1280
From 160 to 4096
Height (pixels)
height
720
From 120 to 3072
Frames per second (video)
fps
30
From 1 to 120
Pictures as
format
jpg
One of: jpg, png
Live preview every (seconds, 0 = none)
preview
0.5
From 0 to 60
Channel for messages
channel
camera

Where it runs

On one of your computers with the EsaSim worker: Any worker. The worker installs the Python packages it needs when they are missing: opencv-python-headless.

In its code, settings are ctx.params["key"], inputs ctx.inputs["id"] and outputs ctx.output("id", "name.ext"); see Custom blocks.

More in Devices