esp32cam
OV2640 camera on ESP32-CAM
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
camera.hpp
Go to the documentation of this file.
1 #ifndef ESP32CAM_CAMERA_HPP
2 #define ESP32CAM_CAMERA_HPP
3 
4 #include "config.hpp"
5 #include "mjpeg.hpp"
6 #include <functional>
7 
8 namespace esp32cam {
9 
10 class CameraClass {
11 public:
16  bool begin(const Config& config);
17 
22  bool end();
23 
29 
37  bool changeResolution(const Resolution& resolution, int sleepFor = 500);
38 
43  Settings status() const;
44 
53  bool update(const Settings& settings, int sleepFor = 0);
54 
63  template<typename Fn>
64  std::enable_if_t<std::is_assignable_v<std::function<void(Settings&)>, Fn>, bool> //
65  update(const Fn& modifier, int sleepFor = 0) {
66  Settings settings = status();
67  modifier(settings);
68  return update(settings, sleepFor);
69  }
70 
76  std::unique_ptr<Frame> capture();
77 
83  int streamMjpeg(Client& client, const MjpegConfig& cfg = MjpegConfig());
84 };
85 
87 extern CameraClass Camera;
88 
89 } // namespace esp32cam
90 
91 #endif // ESP32CAM_CAMERA_HPP
Definition: camera.hpp:10
bool end()
Disable camera.
Definition: camera.cpp:17
Settings status() const
Retrieve runtime settings.
Definition: config.cpp:96
bool update(const Settings &settings, int sleepFor=0)
Update runtime settings.
Definition: config.cpp:119
bool changeResolution(const Resolution &resolution, int sleepFor=500)
Change camera resolution.
Definition: camera.cpp:37
bool begin(const Config &config)
Enable camera.
Definition: camera.cpp:12
ResolutionList listResolutions() const
Retrieve list of resolutions (likely) supported by hardware.
Definition: camera.cpp:22
std::unique_ptr< Frame > capture()
Capture a frame of picture.
Definition: camera.cpp:58
std::enable_if_t< std::is_assignable_v< std::function< void(Settings &)>, Fn >, bool > update(const Fn &modifier, int sleepFor=0)
Update runtime settings using modifier function.
Definition: camera.hpp:65
int streamMjpeg(Client &client, const MjpegConfig &cfg=MjpegConfig())
Stream Motion JPEG.
Definition: camera.cpp:67
Camera initialization configuration.
Definition: config.hpp:17
A collection of resolutions.
Definition: resolution.hpp:86
Picture width and height.
Definition: resolution.hpp:12
Definition: camera.cpp:6
CameraClass Camera
ESP32 camera API.
Definition: camera.cpp:9
Definition: mjpeg.hpp:11
Camera runtime settings.
Definition: config.hpp:77