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
camera_diff_detection.h
1#pragma once
2
3#include "base_detection_module.h"
4#include "motion_data.h"
5
14{
15private:
16 // Sensitivity parameters (tune these for your environment)
17 // Resolution: QVGA is 320x240 = 76,800 pixels (optimized for fast overlay encoding)
18 static const int FRAME_WIDTH = 320;
19 static const int FRAME_HEIGHT = 240;
20 static const int DIFF_THRESHOLD = 20;
21 static const int MOTION_THRESHOLD =
22 150;
23 static const int CENTER_DEADZONE = 20;
24
25 uint8_t* _prev_frame;
26 uint8_t* _curr_frame;
27 uint8_t* _diff_buffer;
28 bool _buffers_allocated;
29 bool _first_frame;
30
31 // Motion tracking data
32 MotionData _last_motion_data;
33 int _last_centroid_x;
34 int _last_centroid_y;
35 DetectionMetrics _current_metrics;
36
37public:
40
46 std::tuple<MoveX, MoveY> detect_object(camera_buffer_t frame) override;
47
48 MotionData get_motion_data() const { return this->_last_motion_data; }
49
50 DetectionMetrics get_detection_metrics() const { return this->_current_metrics; }
51
52private:
53 bool jpeg_to_greyscale(void* frame, uint8_t* output);
54
66 bool find_motion(uint8_t* prev, uint8_t* curr, int width, int height, int& center_x, int& center_y,
67 int& pixel_count);
68
70 void calculate_fps();
71};
An abstract base class (Interface) that defines the contract for detection algorithms....
Definition base_detection_module.h:22
Motion detection using frame differencing.
Definition camera_diff_detection.h:14
MotionData get_motion_data() const
Get the latest motion data from the detection module.
Definition camera_diff_detection.h:48
std::tuple< MoveX, MoveY > detect_object(camera_buffer_t frame) override
Detects motion by comparing frames and returns direction to track.
Definition camera_diff_detection.cpp:31
Performance and health metrics for the Motion Detection engine.
Definition motion_data.h:109
Clean abstraction for motion detection results.
Definition motion_data.h:20
Definition camera.h:49