PiCrawler / Camera & Vision
Camera & Vision
Vilib lifecycle, color, QR, face detection and conditional model paths.
Camera and vision: what is implemented and what is conditional
The official kit camera page specifies a 5 MP OV5647 CSI module with fixed focus. It lists 2592×1944 still capture, several video modes and a 65-degree viewing angle. Those are documented product-family specifications; the exact installed sensor, lens and effective modes need a marking photograph and camera enumeration. The user has a front-facing camera, not a verified present-day capture session. The camera does not record microphone audio.
Pi 5's smaller camera connectors require the appropriate ribbon/adapter for the module. Cable contact direction and connector choice matter. Power must be off for ribbon changes. A camera ribbon that appears inserted can still be reversed, incompletely latched or damaged. The recovery procedure uses rpicam-hello --list-cameras or the installed predecessor command only after state capture, rather than changing overlays first.
The actual processing stack
The inspected Vilib source is version 0.3.20. It uses Picamera2/libcamera, OpenCV, NumPy, PIL and a Flask streaming service. Vilib.picam2 = Picamera2() is evaluated at class definition, so importing Vilib is already more than reading package metadata. Camera activity and helper processes may initialize before an explicit camera-start call. Initial forensics should inspect metadata and files, not casually import every installed package.
camera_start() starts a thread and waits until camera_run becomes true. The camera thread requests RGB888 frames, defaults to 640×480 and asks for a 60 fps control setting. That is a request, not a measured processing rate. The thread processes selected detection paths sequentially, updates the latest image and optionally displays locally. Running several models can lower throughput; timing should be measured at the full application level.
If startup fails in the camera thread before the flag is set, the caller's readiness wait has no timeout in the pinned source. This can look like a frozen program. A future wrapper should bound camera initialization and report the actual exception. Restarting the camera in the same process also needs testing because camera_close() closes the class-level Picamera2 object without establishing a fresh object in camera_start().
Capability distinctions
| Feature | Pinned implementation | Qualification |
|---|---|---|
| Live capture, photo and video recording | Vilib core | Camera, codecs/storage and permissions required |
| MJPEG web preview | Flask core, port 9000 | Network and active camera; no authentication layer established |
| Color detection | HSV thresholds and contours | Lighting-dependent color blobs, not semantic object recognition |
| Face detection | OpenCV cascade | Detects faces; does not identify people |
| QR/barcode reading | pyzbar/libzbar path | Decodes a code in an image; not waypoint localization by itself |
| Traffic-sign detection | Model-dependent module | Model/label files and compatible runtime required |
| Image classification | TFLite-based path | Global image label; not an obstacle position |
| Object detection | TFLite model/labels | Model, labels, interpreter and selected threshold required |
| Hand landmarks | MediaPipe path | hands_detect_switch; gesture interpretation is extra logic |
| Body pose landmarks | MediaPipe path | Human pose estimation, not the crawler's body orientation |
| Face recognition | Not established as a current identity API | Historical face-recognition dependency was abandoned |
gesture_detect_switch | Referenced by current control documentation but absent in inspected core | Do not advertise it as a working API |
The installer supplies model/cascade assets in /opt/vilib, outside the Python module directory. A repository clone or pip metadata record alone does not establish those assets. A model has its own provenance and redistribution conditions; the package license does not automatically describe every model's origin. Record asset hashes before migration and avoid inventing trained-model performance.
Python 3.13 is a real boundary
The pinned installer explicitly skips MediaPipe unless the system is 64-bit and Python is older than 3.13. It also skips tflite-runtime on Python 3.13 or newer. Basic camera, color, face and QR paths can still have different dependency conditions, but the installation's general success does not prove hand/pose/object/classification features. The historical Python 3.13 evidence therefore matters. It is not proof of current installed availability.
The October 2026 changelog records a NumPy fix: Bookworm-and-older installations pin NumPy 1.26.4 to avoid shadowing the system NumPy 1.x used by apt-built simplejpeg/Picamera2 components. Trixie paths differ. This is a binary-compatibility issue between packages, not something solved by editing a color threshold. Do not indiscriminately install the newest NumPy into the recovered system.
From pixels to behavior
Color-following reads detect_obj_parameter fields such as color_n, color_x and color_w. Count indicates a detection condition; X gives a pixel location; width supplies an image-size cue. The bull-fight example steers by horizontal position and moves forward when in its center band. It does not fuse sonar, estimate range from calibrated optics, or enforce a distance-based stop. The treasure-hunt example is keyboard-guided and considers a large target blob a successful find. It is not autonomous QR navigation.
The current bull-fight thresholds are 100 and 220 pixels while the default image width is 640. This mismatch must be reviewed against the actual detection frame rather than presented as validated centering. Camera flip settings, exposure, color thresholds and target scale also change behavior. A future follower should normalize X by image width, require fresh detections, define a lost-target state and place collision supervision ahead of forward commands.
Headless developer arrangement
Run the source on the Pi through a Remote SSH terminal and use Vilib.display(local=False,web=True) for the camera. View /mjpg through port 9000 in the laptop browser, preferably via SSH forwarding on a shared network. Local OpenCV display requires a Pi-side graphical environment; Windows showing a VS Code editor does not itself provide a remote GUI display. Source inspection establishes routes and defaults, not that any stream is currently available.
Source evidence: vi-core, vi-install, vi-changelog, vi-detection, pc-bull-fight, pc-treasure, pc-control-api, pc-camera-doc, pi-camera.
Vision: projects, pipelines and performance gates
The stock camera is a valuable perception source after recovery. Capture, detection and behavior are different components. Vilib handles camera/model plumbing; member Python should normally select behavior. Keep one camera owner and distribute timestamped frames/results, rather than letting several projects independently instantiate Picamera2.
What level of work is involved?
| Idea | Support class | Difficulty | Fun / engineering value (editorial 1–5) | First useful output |
|---|---|---|---|---|
| Remote camera/snapshot station | STOCK EXAMPLE → minor customization | Beginner/intermediate | 3 / 4 | Verified stream/file with timestamp and lifecycle |
| Color hunter / red-target follower | STOCK EXAMPLE → custom supervision | Intermediate | 5 / 5 | Normalized target-center trace plus range veto |
| Face-facing robot | MINOR CUSTOMIZATION | Beginner/intermediate | 4 / 3 | Detection-to-turn with cooldown; no identity recognition |
| QR reader / action tokens | Decoder stock, CUSTOM APPLICATION | Intermediate | 5 / 5 | Allowlisted token event and deduplicated mission progress |
| QR scavenger hunt | CUSTOM APPLICATION | Intermediate | 5 / 5 | Checkpoint state and loss handling, not room coordinates |
| Visual reaction game | CUSTOM APPLICATION | Beginner after prerequisites | 5 / 3 | Card/pose match and latency record |
| Event-triggered capture | CUSTOM APPLICATION; recorder review | Intermediate | 3 / 5 | Readable media linked to event telemetry |
| Camera telemetry dashboard | CUSTOM APPLICATION | Intermediate | 3 / 5 | Frame age, capture/process FPS and model state |
| Object detector/follower | MODEL/RUNTIME RESEARCH REQUIRED | Advanced | 5 / 5 | Qualified detector on recorded scenes before motion |
| Person follow-me | MODEL/RESEARCH REQUIRED | Advanced/semester | 5 / 5 | Association and target-loss evidence, supervised approach |
| Gesture interaction | Hand landmarks conditional; CUSTOM GESTURE RULES | Advanced | 5 / 4 | Stable gesture state without actuating |
| Patrol camera | CUSTOM APPLICATION; course/localization gates | Advanced/semester | 4 / 5 | Operator-supervised checkpoint mission trace |
| Calibrated landmark pose | CUSTOM APPLICATION / RESEARCH | Advanced | 4 / 5 | Camera-relative pose with calibration/error record |
Scores are qualitative authoring priorities, not measured user preferences. No added electronics are inherently required for these camera paths, but printed targets, storage, model assets or a compatible runtime may be required. Added microphone is a voice input requirement, not a camera feature. A depth camera is a separate hardware expansion.
A flagship tracker in stages
First show image/detection overlay only. Log color_n/x/w/h with actual width, flip and application frame identity. Then compute normalized image error and turn left/right with a deadband. Verify steering sign in a supported test, add a lost-target timeout and choose a target consistently. Next replace binary thresholds with proportional bounded turn selections and filtered error. Filtering reduces noise but adds lag, so retain raw error and timing. Only then add approach: stable centered target, fresh valid range, short segment, reobserve.
Target apparent size can trigger a rough near/far heuristic only for a particular target/scene. Object width changes with orientation, focal length and cropping; it is not a universal range measurement. For camera-plus-range fusion, establish extrinsic alignment and target/echo association. Evaluate reacquisition, competing targets, glare, blur and disappearance, rather than counting one successful follow as a reliable autonomous robot.
QR, gesture and patrol details
QR payload → bounded token parser → allowlist → mission state → proposed command → supervisor. Require token length limits, dwell and removal/rearm or mission-index deduplication. Do not execute Python/shell from a marker. In particular, stock action lookup uses eval internally, so mapping external text straight to an action is inappropriate. A QR checkpoint needs no metric pose claim; calibrated corner-based landmark pose is a distinct project.
Gesture input uses actual hands_detect_switch and hands_joints, then club geometry/classification rules, confidence/dwell and a neutral rearm state. MediaPipe landmarks are not a tested gesture recognizer. pose_detect_switch estimates a person's landmarks, not crawler body attitude. Face detection is a face-presence/localization cue, not identity recognition.
Patrol is a supervised mission along a reviewed level course. The first version can be teleoperated between photo stops. A later QR checkpoint runner needs explicit lost-marker and stale-video behavior. Calling a moving camera a security robot does not establish navigation or monitoring reliability. Store only appropriate experiment media with retention limits and space checks; recordings are not automatically public website assets.
Beyond Vilib
Use recorded frames to qualify an owned OpenCV path before involving motion. ArUco marker detection plus calibrated intrinsics/known marker scale can estimate relative pose; solvePnP/frame transforms require version-specific API review. Optical flow can measure image motion but is affected by scene depth, robot rotation and blur; it is not stock metric odometry. Human pose/custom detectors can use selected TFLite, ONNX or other runtimes only after actual arm64/Python/model support is checked. No ONNX model throughput, NPU presence or heavy detector feasibility is asserted here.
The pinned installer skips MediaPipe and tflite-runtime on Python>=3.13, and MediaPipe also requires 64-bit. Qualify a spare environment rather than downgrade/reinstall the preserved card impulsively. Models, labels and cascades may live in /opt/vilib; code install alone is insufficient. Record model format, preprocessing, labels, input size, asset hash, runtime, OS/Python and measured latency/memory. The Pi has 4GB shared with Linux, camera buffers and development services. Offboard inference trades compute headroom for transport delay, privacy and link-failure behavior.
The current camera_start waits without a failure deadline; import initializes Picamera2; close/restart is not established as reusable. A future manager needs bounded startup, fresh-frame evidence and a recovery policy. The source recorder's tight loop can write the same latest frame repeatedly, has no explicit pacing, and contains comparison expressions where flag-clearing assignments appear intended. These are source-review findings, not measured corruption. For real event video, validate cadence, timestamps, writer close, file readability and disk-full handling, or use an application-owned writer.
Source evidence: vi-core, vi-install, vi-detection, pc-bull-fight, pc-treasure, opencv-markers. Project records p2-color-hunter through p2-vision-game contain distinct implementation and acceptance paths.
Continue
Meeting checklist · Source library · Modification atlas · All project proposals