Void Sentry
An AI-driven, real-time Sentry Turret platform leveraging asynchronous I/O and computer vision to deliver high-precision autonomous motion tracking on resource-constrained embedded hardware.
Loading...
Searching...
No Matches
CameraDiffDetection Class Reference

Motion detection and persistent single-target tracking on camera frames. More...

#include <camera_diff_detection.h>

Inheritance diagram for CameraDiffDetection:
BaseDetectionModule

Public Member Functions

 CameraDiffDetection (const CameraDiffDetection &)=delete
 
CameraDiffDetection & operator= (const CameraDiffDetection &)=delete
 
bool begin ()
 Allocate the pipeline in internal RAM. Without it detect_object() reports no motion.
 
std::tuple< MoveX, MoveY > detect_object (camera_buffer_t frame) override
 Analyse one frame; returns the direction toward the tracked target (None when there is none).
 
bool start_task (FrameStore &store)
 Create the "detect" task (core 1, priority 3, 4096 B stack) and subscribe it to the store.
 
void reset () override
 Publish an Idle snapshot now and request a reset of detector and tracker.
 
TrackSnapshot get_track_snapshot () const override
 Latest tracker output, safe to call from another task (implementations copy under a lock).
 
DetectionStats get_stats () const override
 Detection timings and counters for the stats line.
 
- Public Member Functions inherited from BaseDetectionModule
virtual ~BaseDetectionModule ()=default
 Virtual destructor to ensure proper cleanup of derived classes.
 

Detailed Description

Motion detection and persistent single-target tracking on camera frames.

Each frame: JPEG -> 40x30 gray (jpeg_gray), MotionDetector, Tracker. The pipeline state is allocated once in internal RAM by begin() (~12.6 KB at 40x30; tracking measured 0.6 ms there versus 1.1 ms in PSRAM); nothing is allocated per frame. After start_task(), a dedicated "detect" task (core 1, priority 3) owns the pipeline and calls detect_object() on every new published frame; the snapshot and stats getters and reset() may be called from any task.

Member Function Documentation

◆ detect_object()

std::tuple< MoveX, MoveY > CameraDiffDetection::detect_object ( camera_buffer_t frame)
overridevirtual

Analyse one frame; returns the direction toward the tracked target (None when there is none).

Implements BaseDetectionModule.

◆ get_stats()

DetectionStats CameraDiffDetection::get_stats ( ) const
overridevirtual

Detection timings and counters for the stats line.

Reimplemented from BaseDetectionModule.

◆ get_track_snapshot()

TrackSnapshot CameraDiffDetection::get_track_snapshot ( ) const
overridevirtual

Latest tracker output, safe to call from another task (implementations copy under a lock).

Returns
Default (Idle) snapshot when the module does not track.

Reimplemented from BaseDetectionModule.

◆ reset()

void CameraDiffDetection::reset ( )
overridevirtual

Publish an Idle snapshot now and request a reset of detector and tracker.

Safe from any task. The Idle snapshot and the request flag are written in one critical section of the published-state lock, so get_track_snapshot() returns Idle as soon as reset() returns. While the flag is set, detect_object() still counts stats but does not write the snapshot (checked under the same lock), so a frame that the old pipeline was analysing cannot replace the Idle snapshot with a stale Locked one. The detection task clears the flag and resets the pipeline before its next frame; reset() wakes it, and its 200 ms wait timeout is a backstop. The pipeline reset itself is therefore asynchronous, the snapshot is not.

Reimplemented from BaseDetectionModule.

◆ start_task()

bool CameraDiffDetection::start_task ( FrameStore & store)

Create the "detect" task (core 1, priority 3, 4096 B stack) and subscribe it to the store.

The task sleeps until FrameStore::publish wakes it, then analyses the newest unseen frame. Idempotent. Call after begin() and after the frame pipeline is running; store must outlive this object.

Returns
false if begin() has not succeeded, the task cannot be created or the store has no free subscriber slot.

The documentation for this class was generated from the following files: