Status

The package lives in the raccoon-cam repository. It is a standalone Python package. It depends on numpy and on raccoon-transport version 0.1.59 or later, which has the hand-written cam_* messages. Version 0.1.33, which is installed in the virtual environment of drum-bot, has the old LCM-generated Python messages that need the wire patch from drum-bot, so it does not work with raccoon-cam. It needs OpenCV from the system for the USB backend and for the frame stream, and raccoon-lib for the robot transport.

What is verified

All of this runs in the test suite against an in-memory bus and a fake OpenCV.

PartCovered by tests
Interfaces and selectionCamProcessor, CamBackend, set_backend, load_processor, set_processor, the required backend flags
Loading, setting and swapping processorsOne active processor out of the loaded ones, change_processor without loading, loading at the call and refusing a processor the service rejects, a lease without an open camera that frees the loaded processors, refusing what is wrong where it is declared, refusing a processor that is not loaded (in the client and in the service), dropping the old processor’s detections at a swap, the set processor surviving a restart of the service, validate_camera and the check in start_camera
UsbCameraBackendDelivery of numbered frames, open retries and giving up after the configured attempts, reopening after failed reads, stop, configuration errors
ReplayBackendPlaying a video, a folder and a single image, looping, finishing, scaling, the playback rate, failing at once for a bad source, running through the service with a processor
Robot setup (the post-install step)Root check, unit install and keeping an edited unit, one apt call for all missing packages, nothing to install when all is present, a failing or missing apt, --no-service
Backend dependenciesA missing dependency fails the start with an install hint, and is not checked before the backend is used
ProcessorHostFailure isolation, disabling, replacement, commands, the active processor, refusing processors for backends without frames
Service and clientLeases (open on start, immediate close on stop, expiry after a crash, heartbeat, extended after a stalled service), on_fail, the falsy FailedCamera, results with their source, ready and the start timeout per backend, retries and delay from the backend, restarts of the program and of the service, exclusive start, switching backends, the backend saved on the robot, pause, errors, dropping frames, the frame stream, the wire format, the journal and the log of each run

What has not been tried

  • A real camera. The USB backend has not run against a real device on a Raspberry Pi.
  • The robot transport. TransportBus wraps raccoon.get_transport() the way drum-bot uses it, but it has not run on a robot.
  • Running as a service. The services: entry and the unit file are written from the drum-bot example and the unit tests of raccoon-cli, and have not been started. The same holds for loading OpenCV at start of the service, the log directory of each run and the version check at start.
  • Switching processors on a running robot. change_processor is tested with an in-memory bus. How long a swap takes with a real model on the Raspberry Pi is not measured.
  • Memory and CPU on the Raspberry Pi 3. Nothing is measured yet. The Pi has 1 GB of RAM and the system already uses 300 to 400 MB.
  • The UI. What BotUI does with the frames and detections is not checked.

What does not exist

  • Steps such as waiting for a detection.
  • A processor included in the package. There is no colour detector and no example. The pink and blue drum detection from drum-bot is not moved over.
  • The AI camera backend. The interface leaves room for it. What the camera delivers is not known yet.
  • A release of raccoon-cam. The image and raccoon update can install it once a release with the wheel exists. The bundle entry and the image build are written, but have not run.

libstp-cam in raccoon-lib, an earlier client that nothing used, is removed. The pull request is open in raccoon-lib.

Open decisions

  1. The frame stream is off by default. drum-bot always publishes frames for the UI. Encoding JPEGs costs CPU on the Pi, so the service only does it after stream(fps) or --stream-fps. If BotUI expects frames without asking, this needs a default.
  2. extra and the wire format. cam_blob_t cannot carry Detection.extra, and the source travels as a label prefix. New fields in the message would remove both limits.
  3. When the service runs. Always on from the bundle, or started on request.
  4. Where the Steps live, in this package or in raccoon-lib, depending on whether the web IDE picks up steps from outside the library.
  5. Python only for now. Heavy image processing in C++ is not part of the design yet. If measurements on the robot show that Python is the bottleneck, the backend interface leaves room for a C++ implementation.
Written by Mario Scholze