Smart Camera ESP32
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_data.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <Arduino.h>
11
20{
21private:
22 bool _detected;
23 int _centroid_x;
24 int _centroid_y;
25 int _frame_width;
26 int _frame_height;
27 int _pixel_count;
28
29public:
39 MotionData() : _detected(false), _centroid_x(0), _centroid_y(0), _frame_width(0), _frame_height(0), _pixel_count(0)
40 {
41 }
42
51 MotionData(int centroid_x, int centroid_y, int frame_width, int frame_height, int pixel_count)
52 : _detected(true), _centroid_x(centroid_x), _centroid_y(centroid_y), _frame_width(frame_width),
53 _frame_height(frame_height), _pixel_count(pixel_count)
54 {
55 }
67 bool is_detected() const { return this->_detected; }
68
73 int get_centroid_x() const { return this->_centroid_x; }
74
79 int get_centroid_y() const { return this->_centroid_y; }
80
85 int get_frame_width() const { return this->_frame_width; }
86
91 int get_frame_height() const { return this->_frame_height; }
92
97 int get_pixel_count() const { return this->_pixel_count; }
99};
100
109{
110private:
111 uint32_t _detection_time_ms;
112 int _pixels_changed;
113 float _motion_confidence;
114 int _consecutive_motion_frames;
115 int _consecutive_static_frames;
116 uint32_t _total_detections;
117 uint32_t _total_frames;
118 uint32_t _last_frame_timestamp;
119 uint32_t _average_fps;
120
121public:
126 : _detection_time_ms(0), _pixels_changed(0), _motion_confidence(0.0f), _consecutive_motion_frames(0),
127 _consecutive_static_frames(0), _total_detections(0), _total_frames(0), _last_frame_timestamp(0),
128 _average_fps(0)
129 {
130 }
131
136 void set_detection_time_ms(uint32_t time) { this->_detection_time_ms = time; }
137 void set_pixels_changed(int count) { this->_pixels_changed = count; }
138
143 void set_motion_confidence(float conf)
144 {
145 this->_motion_confidence = (conf < 0.0f) ? 0.0f : (conf > 1.0f) ? 1.0f : conf;
146 }
147 void set_consecutive_motion_frames(int count) { this->_consecutive_motion_frames = count; }
148 void set_consecutive_static_frames(int count) { this->_consecutive_static_frames = count; }
149 void set_total_detections(uint32_t count) { this->_total_detections = count; }
150 void set_total_frames(uint32_t count) { this->_total_frames = count; }
151 void set_last_frame_timestamp(uint32_t ts) { this->_last_frame_timestamp = ts; }
152 void set_average_fps(uint32_t fps) { this->_average_fps = fps; }
160 uint32_t get_detection_time_ms() const { return this->_detection_time_ms; }
162 int get_pixels_changed() const { return this->_pixels_changed; }
164 float get_motion_confidence() const { return this->_motion_confidence; }
166 int get_consecutive_motion_frames() const { return this->_consecutive_motion_frames; }
168 int get_consecutive_static_frames() const { return this->_consecutive_static_frames; }
170 uint32_t get_total_detections() const { return this->_total_detections; }
172 uint32_t get_total_frames() const { return this->_total_frames; }
174 uint32_t get_last_frame_timestamp() const { return this->_last_frame_timestamp; }
176 uint32_t get_average_fps() const { return this->_average_fps; }
178};
Performance and health metrics for the Motion Detection engine.
Definition motion_data.h:109
uint32_t get_total_frames() const
Definition motion_data.h:172
uint32_t get_last_frame_timestamp() const
Definition motion_data.h:174
float get_motion_confidence() const
Definition motion_data.h:164
uint32_t get_total_detections() const
Definition motion_data.h:170
int get_pixels_changed() const
Definition motion_data.h:162
uint32_t get_detection_time_ms() const
Definition motion_data.h:160
uint32_t get_average_fps() const
Definition motion_data.h:176
void set_motion_confidence(float conf)
Sets confidence and clamps value between 0.0 and 1.0.
Definition motion_data.h:143
DetectionMetrics()
Constructor: Initializes all metrics to zero.
Definition motion_data.h:125
int get_consecutive_static_frames() const
Definition motion_data.h:168
int get_consecutive_motion_frames() const
Definition motion_data.h:166
Clean abstraction for motion detection results.
Definition motion_data.h:20
int get_centroid_x() const
Get motion centroid X coordinate.
Definition motion_data.h:73
int get_frame_height() const
Get the height of the frame processed.
Definition motion_data.h:91
MotionData()
Default Constructor: Create empty motion data.
Definition motion_data.h:39
int get_pixel_count() const
Get the volume of detected motion.
Definition motion_data.h:97
int get_centroid_y() const
Get motion centroid Y coordinate.
Definition motion_data.h:79
int get_frame_width() const
Get the width of the frame processed.
Definition motion_data.h:85
bool is_detected() const
Check if valid motion was detected in this snapshot.
Definition motion_data.h:67
MotionData(int centroid_x, int centroid_y, int frame_width, int frame_height, int pixel_count)
Parameterized Constructor: Create motion data from algorithm output.
Definition motion_data.h:51