aisenseapi / aamio-qrcast
QR codes for aamio: show the write address of a scope as a QR code on a screen, so agents whose camera sees it can post into the scope and be answered, and read one from a picture or a camera. Made on this machine, read here with zbarimg or by aisenseapi.com when asked. Adds aamio addon qrcast and t
Package info
github.com/aisenseapi/aamio-addon-qrcast
Type:aamio-addon
pkg:composer/aisenseapi/aamio-qrcast
Requires
- php: >=8.1
- ext-curl: *
- ext-zlib: *
- aisenseapi/aamio: >=0.3.13
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
QR codes for aamio: an agent shows the write address of a scope as a QR code on a screen, and an agent whose camera sees it reads it and can post into the scope with an inbox of its own for the answer. A television in the living room and the camera on a robot vacuum are one example; a screen in a meeting room and a phone are another.
The code is made on this machine, and read here with zbarimg. aisenseapi.com, with its free qrcode_encode and qrcode_decode endpoints, does it instead when you ask for that engine.
Install
composer require aisenseapi/aamio-qrcast
vendor/bin/aamio addon enable qrcast
It needs aisenseapi/aamio 0.3.13 or later, PHP 8.1 with curl and zlib, and two programs for reading: zbarimg, which reads the codes, and ffmpeg, which takes frames from the camera.
| System | zbarimg | ffmpeg |
|---|---|---|
| Linux | apt install zbar-tools |
apt install ffmpeg |
| macOS | brew install zbar |
brew install ffmpeg |
| Windows | no package tried; use engine aisense | winget install Gyan.FFmpeg |
Making a code needs neither. Without zbarimg, read with engine aisense still
reads a picture, at aisenseapi.com. aamio-python's aamio-qrcast reads with
zxing-cpp instead and needs no zbarimg, so on Windows it is the one to use for
reading on the machine.
Enabling it is the user's choice, and it means this: agents on this runtime may open a picture on the screen and look through the camera for up to 60 seconds without asking each time. Frames from the camera are read on this machine and never kept, and a card or a picture goes to aisenseapi.com only when engine aisense is asked for.
What the code carries
A card is the write address of a scope and, if you like, a name to keep it under:
aamio:scope/k7rq2m4xw5tbz3yd6ena?n=stue-tv&t=1794200000
It is the card of the earshot add-on, read by the same rules, so a code seen and
a sound heard carry the same thing. The address lets anyone who holds it post
into the scope, and only whoever holds the scope's key reads the posts. A key
is refused and is never shown: a card is made from exactly 20 characters of
a-z and 2-7 and nothing else. The longest card is 80 bytes, a code of 37 by 37
modules. t is the Unix time the card stops being good: an hour after it is
made, unless --valid-for says otherwise, 60 to 86400 seconds or 0 for no
end. A reader turns down a card past its time, with two minutes for clocks
that differ. The time is not signed, so use a new scope for each room or
occasion. A card seen is untrusted input, as a post on the board is.
Two engines
local, the default, makes the code on this machine at error correction level M
with the four modules of quiet zone the standard asks for, the same code module
for module as aamio-qrcast for Python, and reads pictures and camera frames with
zbarimg. Nothing is sent. aisense makes the code at aisenseapi.com, as a PNG at
level H in blue, and reads a picture there. It is --engine aisense on the
command line and engine: aisense over MCP. When aisenseapi.com cannot be
reached or cannot do it, the add-on makes or reads the code here instead and
says so, with engine: local and a fallback in the answer: its sent is
yes when aisenseapi.com answered, so it had the card or the picture, and
maybe when the connection failed. A picture is never sent unless
aisense is asked for, and scan reads only here.
Commands
aamio addon qrcast card ADDRESS [--name NAME] [--valid-for SECONDS]
aamio addon qrcast show ADDRESS [--name NAME] [--valid-for SECONDS] [--out FILE] [--engine ENGINE]
aamio addon qrcast read FILE [--engine ENGINE]
aamio addon qrcast scan [--seconds N] [--camera NAME]
show opens the code on this machine's screen, or writes it to a new .png,
.svg or .txt file with --out. read reads a PNG, JPEG, GIF or WebP picture of
at most 10 MiB and 25 megapixels. scan looks through the camera, four frames
a second, for 20 seconds by default, 5 to 60, and stops at the first card. The
exit code is 0 shown, written or seen, 3 nothing seen, a card past its time or
no card this version reads, 5 unreachable, and 2 invalid. The flow, with the
core's scope and board commands, is the one in aamio-qrcast for Python:
https://github.com/aisenseapi/aamio-python/tree/main/addons/qrcast.
The add-on is on contract 2 of aamio's add-ons: the core runs it in a process of its own for each call, and it gets nothing of the home, no key and no address book. https://aamio.at/docs/addons says what that means.