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
motion_detector.h
Go to the documentation of this file.
1
14#pragma once
15
16#include "tracking_types.h"
17
18namespace tracking
19{
21{
22public:
23 explicit MotionDetector(const DetectorConfig& config = DetectorConfig{});
24
26 const DetectionResult& process(const GrayFrame& frame);
27
29 void reset();
30
31 const DetectionResult& last() const { return result_; }
32
33private:
34 static constexpr int kMaxLabels = kCells / 2;
35 static constexpr int kMaxComponents = 64;
36
37 struct Accum {
38 int area = 0;
39 int sum_x = 0;
40 int sum_y = 0;
41 Box box;
42 };
43
44 void copy_background(const GrayFrame& frame);
45 void seed_background(const GrayFrame& frame);
46 int mask_and_learn(const GrayFrame& frame);
47 void label_blobs();
48 uint16_t find(uint16_t label);
49 void unite(uint16_t a, uint16_t b);
50
51 DetectorConfig config_;
52 bool seeded_ = false;
53 int warmup_left_ = 0;
54 int frame_mean_ = 0;
55 int background_mean_ = 0;
56 DetectionResult result_;
57 std::array<uint16_t, kCells> background_{};
58 std::array<uint8_t, kCells> mask_{};
59 std::array<uint8_t, kCells> fg_age_{};
60 std::array<uint16_t, kCells> labels_{};
61 std::array<uint16_t, kMaxLabels + 1> parent_{};
62 std::array<uint8_t, kMaxLabels + 1> component_of_{};
63 std::array<Accum, kMaxComponents> accum_{};
64};
65} // namespace tracking
Definition motion_detector.h:21
void reset()
Forget the background; the next frame re-seeds it and starts the warm-up.
Definition motion_detector.cpp:19
const DetectionResult & process(const GrayFrame &frame)
Analyse one frame. The returned reference stays valid until the next call.
Definition motion_detector.cpp:26
Inclusive cell rectangle. A default-constructed box is empty.
Definition tracking_types.h:24
What the detector found in one frame. Blobs are sorted by area, largest first.
Definition tracking_types.h:83
Motion detector tunables. Defaults are tuned for an indoor scene 1-3 m away.
Definition tracking_types.h:67
Value types shared by the motion detector and the tracker (pure C++20, natively tested).
std::array< uint8_t, kCells > GrayFrame
One 40x30 luma frame, row-major (index = y * kGridW + x).
Definition tracking_types.h:21