### setup() Source: https://esp32cam.yoursunny.dev/globals_func.html Standard Arduino setup function for initialization. ```APIDOC ## setup() ### Description Initializes hardware and software components required for the ESP32-CAM operation. ### Defined In - AsyncCam.ino - WifiCam.ino ``` -------------------------------- ### addRequestHandlers() Source: https://esp32cam.yoursunny.dev/WifiCam_2handlers_8cpp.html Registers the necessary request handlers for the WifiCam service. This function is typically called during the setup phase to enable camera streaming and control endpoints. ```APIDOC ## void addRequestHandlers() ### Description Registers the request handlers required for the WifiCam functionality. This allows the ESP32-CAM to respond to specific URI requests for camera operations. ### Signature `void addRequestHandlers()` ``` -------------------------------- ### MjpegController::notifyCapture() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1detail_1_1MjpegController.html Notifies the controller that a frame capture operation has started. ```APIDOC ## void notifyCapture() ### Description Notify that frame capture has started. ### Postcondition decideAction() == RETURN ``` -------------------------------- ### bool begin(const Config &config) Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1CameraClass.html Enables the camera with the provided configuration. ```APIDOC ## bool begin(const Config &config) ### Description Enables the camera using the specified configuration object. ### Parameters - **config** (const Config &) - Required - The configuration settings for the camera. ### Returns - **bool** - Returns true if the camera was enabled successfully, false otherwise. ``` -------------------------------- ### Initialize AsyncWebServer Source: https://esp32cam.yoursunny.dev/AsyncCam_8ino.html Initializes the AsyncWebServer instance on port 80. ```cpp AsyncWebServer server (80) ``` -------------------------------- ### begin() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1ResolutionList.html Returns an iterator to the beginning of the resolution collection. ```APIDOC ## begin() ### Description Returns an iterator pointing to the first resolution in the list. ``` -------------------------------- ### Include configuration headers Source: https://esp32cam.yoursunny.dev/config_8hpp.html Required headers for accessing camera configuration and resolution settings. ```cpp #include "pins.hpp" #include "resolution.hpp" ``` -------------------------------- ### server() Source: https://esp32cam.yoursunny.dev/globals_func.html Accesses the web server instance. ```APIDOC ## server() ### Description Returns or initializes the web server instance used by the application. ### Defined In - AsyncCam.ino - WifiCam.ino ``` -------------------------------- ### Include Directives Source: https://esp32cam.yoursunny.dev/config_8cpp.html Required headers for camera configuration and logging. ```cpp #include "config.hpp" #include "camera.hpp" #include "logger.hpp" #include #include #include ``` -------------------------------- ### prepareTrailer() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1detail_1_1MjpegHeader.html Prepares the trailer for the MJPEG stream. ```APIDOC ## void prepareTrailer() ### Description Prepares the final trailer for the MJPEG stream. ### Signature `void prepareTrailer()` ``` -------------------------------- ### esp32cam::Config Methods Source: https://esp32cam.yoursunny.dev/config_8hpp_source.html Methods available on the Config object to set up camera parameters. ```APIDOC ## Config::setPins ### Description Sets the camera hardware pins. ### Signature `Config& setPins(const Pins& pins)` ## Config::setResolution ### Description Sets the camera resolution. ### Signature `Config& setResolution(const Resolution& resolution)` ## Config::setBufferCount ### Description Sets the number of frame buffers. ### Signature `Config& setBufferCount(int n)` ## Config::setRgb ### Description Changes the pixel format to RGB565. ### Signature `Config& setRgb()` ## Config::setYuv ### Description Changes the pixel format to YUV422. ### Signature `Config& setYuv()` ## Config::setGrayscale ### Description Changes the pixel format to grayscale. ### Signature `Config& setGrayscale()` ## Config::setJpeg ### Description Changes the pixel format to JPEG with a specified quality. ### Signature `Config& setJpeg(int quality)` ``` -------------------------------- ### Include AsyncCam and WiFi headers Source: https://esp32cam.yoursunny.dev/AsyncCam_8ino.html Required headers for utilizing the AsyncCam library and WiFi connectivity on the ESP32-CAM. ```cpp #include "AsyncCam.hpp" #include ``` -------------------------------- ### Include esp32cam headers Source: https://esp32cam.yoursunny.dev/esp32cam_8h.html Include these headers to access camera functionality, asynchronous web support, and logging utilities. ```cpp #include "esp32cam/asyncweb.hpp" #include "esp32cam/camera.hpp" #include "esp32cam/logger.hpp" ``` -------------------------------- ### Include WifiCam headers Source: https://esp32cam.yoursunny.dev/WifiCam_8ino.html Required headers for initializing the WifiCam functionality and WiFi connectivity. ```cpp #include "WifiCam.hpp" #include ``` -------------------------------- ### Iterating through ResolutionList Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1ResolutionList.html Demonstrates how to iterate through the available resolutions using a range-based for loop. ```cpp for (const auto& resolution : Resolution::list()) { Serial.println(resolution); } ``` -------------------------------- ### Save Setting Macros Source: https://esp32cam.yoursunny.dev/AsyncCam_2handlers_8cpp.html Macros to update camera settings from HTTP request arguments. ```cpp #define SAVE_BOOL(MEM) s.MEM = req->hasArg(#MEM) ``` ```cpp #define SAVE_INT(MEM) s.MEM = decltype(s.MEM)(req->arg(#MEM).toInt()) ``` -------------------------------- ### Include camera headers Source: https://esp32cam.yoursunny.dev/camera_8cpp.html Required headers for utilizing the ESP32 camera functionality within an Arduino environment. ```cpp #include "camera.hpp" #include #include ``` -------------------------------- ### Include resolution header and dependencies Source: https://esp32cam.yoursunny.dev/resolution_8cpp.html Required header inclusions for utilizing resolution settings and camera functionality. ```cpp #include "resolution.hpp" #include #include ``` -------------------------------- ### Include necessary headers for WifiCam Source: https://esp32cam.yoursunny.dev/WifiCam_2handlers_8cpp.html Required headers for implementing WifiCam request handlers. ```cpp #include "WifiCam.hpp" #include #include ``` -------------------------------- ### list() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Resolution.html Retrieves a list of all possible resolutions. ```APIDOC ## static ResolutionList list() ### Description Returns an iterable collection of all possible resolutions defined in the library. ``` -------------------------------- ### Include WifiCam headers Source: https://esp32cam.yoursunny.dev/WifiCam_8hpp.html Required headers for utilizing the WifiCam functionality and the WebServer class. ```cpp #include #include ``` -------------------------------- ### void addRequestHandlers() Source: https://esp32cam.yoursunny.dev/AsyncCam_8hpp.html Registers the necessary request handlers for the camera server. ```APIDOC ## void addRequestHandlers() ### Description Registers the camera-related request handlers to the global AsyncWebServer instance. ### Signature `void addRequestHandlers()` ``` -------------------------------- ### Include directives for frame.cpp Source: https://esp32cam.yoursunny.dev/frame_8cpp.html Required headers for frame processing and camera configuration. ```cpp #include "frame.hpp" #include "config.hpp" #include #include #include ``` -------------------------------- ### prepareResponseHeaders() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1detail_1_1MjpegHeader.html Prepares the standard HTTP response headers for an MJPEG stream. ```APIDOC ## void prepareResponseHeaders() ### Description Prepares the HTTP response headers necessary for initiating an MJPEG stream. ### Signature `void prepareResponseHeaders()` ``` -------------------------------- ### Predefined Board Pin Configurations Source: https://esp32cam.yoursunny.dev/pins_8hpp_source.html Collection of constexpr instances for specific hardware modules. ```cpp constexpr Pins AiThinker{ D0: 5, D1: 18, D2: 19, D3: 21, D4: 36, D5: 39, D6: 34, D7: 35, XCLK: 0, PCLK: 22, VSYNC: 25, HREF: 23, SDA: 26, SCL: 27, RESET: -1, PWDN: 32, }; ``` ```cpp constexpr Pins XiaoSense{ D0: 15, D1: 17, D2: 18, D3: 16, D4: 14, D5: 12, D6: 11, D7: 48, XCLK: 10, PCLK: 13, VSYNC: 38, HREF: 47, SDA: 40, SCL: 39, RESET: -1, PWDN: -1, }; ``` ```cpp constexpr Pins S3N16R8{ D0: 11, D1: 9, D2: 8, D3: 10, D4: 12, D5: 18, D6: 17, D7: 16, XCLK: 15, PCLK: 13, VSYNC: 6, HREF: 7, SDA: 4, SCL: 5, RESET: -1, PWDN: -1, }; ``` ```cpp constexpr Pins FreeNove{ D0: 4, D1: 5, D2: 18, D3: 19, D4: 36, D5: 39, D6: 34, D7: 35, XCLK: 21, PCLK: 22, VSYNC: 25, HREF: 23, SDA: 26, SCL: 27, RESET: -1, PWDN: -1, }; ``` ```cpp constexpr Pins M5Camera{ D0: 32, D1: 35, D2: 34, D3: 5, D4: 39, D5: 18, D6: 36, D7: 19, XCLK: 27, PCLK: 21, VSYNC: 25, HREF: 26, SDA: 22, SCL: 23, RESET: 15, PWDN: -1, }; ``` ```cpp constexpr Pins M5CameraLED{ D0: 32, D1: 35, D2: 34, D3: 5, D4: 39, D5: 18, D6: 36, D7: 19, XCLK: 27, PCLK: 21, VSYNC: 25, HREF: 26, SDA: 22, SCL: 23, RESET: 15, PWDN: 14, }; ``` ```cpp constexpr Pins TTGO{ D0: 5, D1: 14, D2: 4, D3: 15, D4: 37, D5: 38, D6: 36, D7: 39, XCLK: 32, PCLK: 19, VSYNC: 27, HREF: 25, SDA: 13, SCL: 12, RESET: -1, PWDN: -1, }; ``` -------------------------------- ### Include AsyncCam headers Source: https://esp32cam.yoursunny.dev/AsyncCam_8hpp.html Required headers for utilizing the AsyncCam functionality within an ESP32-CAM project. ```cpp #include #include ``` -------------------------------- ### Include Headers Source: https://esp32cam.yoursunny.dev/AsyncCam_2handlers_8cpp.html Required headers for AsyncCam functionality and string streaming. ```cpp #include "AsyncCam.hpp" #include ``` -------------------------------- ### AsyncWebServer Request Handlers Source: https://esp32cam.yoursunny.dev/asyncweb_8hpp_source.html Helper functions to register still and MJPEG responses with an AsyncWebServerRequest. ```cpp inline void handleStill(AsyncWebServerRequest* request) { request->send(new StillResponse()); } inline void handleMjpeg(AsyncWebServerRequest* request) { request->send(new MjpegResponse()); } ``` -------------------------------- ### bool update(const Settings &settings, int sleepFor) Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1CameraClass.html Updates the runtime settings of the camera. ```APIDOC ## bool update(const Settings &settings, int sleepFor) ### Description Updates the camera's runtime settings. The camera must be enabled. ### Parameters - **settings** (const Settings &) - Required - The new settings to apply. - **sleepFor** (int) - Optional - Time in milliseconds to wait for stabilization. ### Returns - **bool** - Returns true if the update was successful. ``` -------------------------------- ### void setLogger(Print& output) Source: https://esp32cam.yoursunny.dev/logger_8hpp_source.html Configures the output destination for library logs by providing a Print object. ```APIDOC ## void setLogger(Print& output) ### Description Sets the global logger output destination. All subsequent logs will be directed to the provided Print object (e.g., Serial). ### Parameters - **output** (Print&) - Required - A reference to a Print object where logs will be written. ``` -------------------------------- ### Predefined Board Configurations Source: https://esp32cam.yoursunny.dev/pins_8hpp_source.html Predefined constexpr instances of the Pins structure for common ESP32-CAM boards. ```APIDOC ## Predefined Board Pinouts Available in the `esp32cam::pins` namespace: - **AiThinker**: AI Thinker ESP32-CAM - **XiaoSense**: Seeed Studio XIAO ESP32S3 Sense - **S3N16R8**: ESP32-S3-CAM with ESP32-S3-N16R8 chip - **FreeNove**: FREENOVE WROVER ESP32-CAM - **M5Camera**: M5Stack M5Camera - **M5CameraLED**: M5Stack M5Camera with LED - **TTGO**: TTGO ESP32-CAM ``` -------------------------------- ### HTML Form Generation Macros Source: https://esp32cam.yoursunny.dev/AsyncCam_2handlers_8cpp.html Macros for rendering HTML form controls based on camera state. ```cpp #define SHOW_GAIN(val, dsp) b.printf("", val, s.gain == val ? " selected" : "", dsp) ``` ```cpp #define SHOW_BOOL(MEM) else if (var == #MEM) { b.printf("", s.MEM ? " checked" : ""); } ``` ```cpp #define SHOW_INT(MEM, MIN, MAX) else if (var == #MEM) { b.printf("", s.MEM, MIN, MAX); } ``` ```cpp #define SHOW_LM(MODE, symbol) b.printf("", static_cast(esp32cam::LightMode::MODE), #MODE, s.lightMode == esp32cam::LightMode::MODE ? " selected" : "", symbol) ``` ```cpp #define SHOW_SE(MODE, symbol) b.printf("", static_cast(esp32cam::SpecialEffect::MODE), #MODE, s.specialEffect == esp32cam::SpecialEffect::MODE ? " selected" : "", symbol) ``` -------------------------------- ### prepareBoundary() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1detail_1_1MjpegHeader.html Prepares the multipart boundary header for the MJPEG stream. ```APIDOC ## void prepareBoundary(size_t contentLength) ### Description Prepares the multipart boundary header based on the provided content length. ### Parameters - **contentLength** (size_t) - The size of the content to be sent. ### Signature `void prepareBoundary(size_t contentLength)` ``` -------------------------------- ### find(int minWidth, int minHeight) Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Resolution.html Finds a resolution that meets specific constraints. ```APIDOC ## static Resolution find(int minWidth, int minHeight) ### Description Finds a resolution that satisfies the given width and height constraints. ### Parameters - **minWidth** (int) - Required - Minimum width. - **minHeight** (int) - Required - Minimum height. ``` -------------------------------- ### AsyncCam.hpp Header Definition Source: https://esp32cam.yoursunny.dev/AsyncCam_8hpp_source.html Defines the necessary includes and external declarations for the asynchronous camera server. ```cpp #ifndef ASYNCCAM_HPP #define ASYNCCAM_HPP // It is necessary to include ESPAsyncWebServer.h before esp32cam.h for Arduino builder to // recognize the dependency. #include #include extern esp32cam::Resolution initialResolution; extern AsyncWebServer server; void addRequestHandlers(); #endif // ASYNCCAM_HPP ``` -------------------------------- ### Include Resolution headers Source: https://esp32cam.yoursunny.dev/resolution_8hpp.html Required headers for using resolution-related functionality in the esp32cam library. ```cpp #include ``` ```cpp #include ``` -------------------------------- ### loop() Source: https://esp32cam.yoursunny.dev/globals_func.html Standard Arduino loop function for continuous execution. ```APIDOC ## loop() ### Description Main execution loop for the ESP32-CAM application. ### Defined In - AsyncCam.ino - WifiCam.ino ``` -------------------------------- ### esp32cam::Resolution::list Source: https://esp32cam.yoursunny.dev/resolution_8hpp_source.html Returns an iterable collection of all possible resolutions supported by the camera. ```APIDOC ## static ResolutionList list() ### Description Return an iterable collection of possible resolutions. ### Returns - **ResolutionList** - A collection of available resolutions. ``` -------------------------------- ### ESP32CAM_LOG(fmt, ...) Source: https://esp32cam.yoursunny.dev/logger_8hpp_source.html A macro used to output formatted log messages if a logger has been configured. ```APIDOC ## ESP32CAM_LOG(fmt, ...) ### Description Logs a formatted message to the configured LogOutput. The message is prefixed with the current system uptime in milliseconds. ### Parameters - **fmt** (const char*) - Required - The format string (printf style). - **...** (variadic) - Optional - Arguments for the format string. ``` -------------------------------- ### capture() Source: https://esp32cam.yoursunny.dev/namespacemembers_func.html Captures an image using the camera. ```APIDOC ## capture() ### Description Captures an image from the OV2640 camera. ### Namespace esp32cam ``` -------------------------------- ### Pixel Format Methods Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Config.html Methods to set the pixel format of the camera output. ```APIDOC ## Config::setRgb() Changes pixel format to RGB565. ## Config::setYuv() Changes pixel format to YUV422. ## Config::setGrayscale() Changes pixel format to grayscale. ``` -------------------------------- ### StillResponse and MJPEGResponse Classes Source: https://esp32cam.yoursunny.dev/asyncweb_8hpp_source.html Classes inheriting from AsyncAbstractResponse to handle image and stream delivery via ESPAsyncWebServer. ```cpp class StillResponse : public AsyncAbstractResponse { public: explicit StillResponse(); ~StillResponse() override; bool _sourceValid() const override { return true; } size_t _fillBuffer(uint8_t* buf, size_t buflen) override; private: detail::CaptureTask m_task; std::unique_ptr m_frame; size_t m_index = 0; }; class MjpegResponse : public AsyncAbstractResponse { public: explicit MjpegResponse(const MjpegConfig& cfg = MjpegConfig()); ~MjpegResponse() override; bool _sourceValid() const override { return true; } size_t _fillBuffer(uint8_t* buf, size_t buflen) override; private: size_t sendPart(uint8_t* buf, size_t buflen); private: detail::CaptureTask m_task; using Ctrl = detail::MjpegController; Ctrl m_ctrl; detail::MjpegHeader m_hdr; enum SendItem { SINone, SIBoundary, SIFrame, }; SendItem m_sendNext = SINone; const uint8_t* m_sendBuf = nullptr; size_t m_sendRemain = 0; unsigned long m_createTime = millis(); unsigned long m_sendSince = 0; }; ``` -------------------------------- ### WifiCam.hpp Header Definition Source: https://esp32cam.yoursunny.dev/WifiCam_8hpp_source.html Contains the header guard, necessary includes, and external declarations for the camera server and resolution settings. ```cpp #ifndef WIFICAM_HPP #define WIFICAM_HPP #include #include extern esp32cam::Resolution initialResolution; extern WebServer server; void addRequestHandlers(); #endif // WIFICAM_HPP ``` -------------------------------- ### addRequestHandlers() Source: https://esp32cam.yoursunny.dev/WifiCam_8hpp.html Registers the necessary request handlers for the web server to interact with the camera. ```APIDOC ## void addRequestHandlers() ### Description Registers the request handlers required for the web server to interface with the ESP32-CAM camera module. ### Signature `void addRequestHandlers()` ``` -------------------------------- ### ESP32CAM Configuration Header Source: https://esp32cam.yoursunny.dev/config_8hpp_source.html The main configuration header defining the Config class, LightMode and SpecialEffect enums, and the Settings structure. ```cpp #ifndef ESP32CAM_CONFIG_HPP #define ESP32CAM_CONFIG_HPP #include "pins.hpp" #include "resolution.hpp" namespace esp32cam { namespace detail { int convertJpegQuality(int quality); } // namespace detail class Config { public: Config(); ~Config(); Config& setPins(const Pins& pins); Config& setResolution(const Resolution& resolution); Config& setBufferCount(int n); Config& setRgb(); Config& setYuv(); Config& setGrayscale(); Config& setJpeg(int quality); private: class CameraConfigT; CameraConfigT* m_cfg; friend class CameraClass; }; enum class LightMode { NONE = -1, AUTO = 0, SUNNY = 1, CLOUDY = 2, OFFICE = 3, HOME = 4, }; enum class SpecialEffect { NONE = 0, NEGATIVE = 1, BLACKWHITE = 2, REDDISH = 3, GREENISH = 4, BLUISH = 5, ANTIQUE = 6, }; struct Settings { Resolution resolution; int8_t brightness; int8_t contrast; int8_t saturation; int8_t gain; LightMode lightMode; SpecialEffect specialEffect; bool hmirror = false; bool vflip = false; bool rawGma = false; bool lensCorrection = false; }; } // namespace esp32cam #endif // ESP32CAM_CONFIG_HPP ``` -------------------------------- ### CameraClass Methods Source: https://esp32cam.yoursunny.dev/camera_8hpp_source.html Methods available on the esp32cam::Camera object for controlling the camera hardware. ```APIDOC ## bool begin(const Config& config) ### Description Initializes and enables the camera using the provided configuration. ## bool end() ### Description Disables the camera. ## ResolutionList listResolutions() const ### Description Retrieves a list of resolutions supported by the camera hardware. ## bool changeResolution(const Resolution& resolution, int sleepFor = 500) ### Description Changes the current camera resolution. The optional sleepFor parameter defines a delay in milliseconds. ## Settings status() const ### Description Retrieves the current runtime settings of the camera. ## bool update(const Settings& settings, int sleepFor = 0) ### Description Updates the camera runtime settings. ## bool update(const Fn& modifier, int sleepFor = 0) ### Description Updates the camera runtime settings using a modifier function that accepts a Settings object. ## std::unique_ptr capture() ### Description Captures a single frame from the camera. ## int streamMjpeg(Client& client, const MjpegConfig& cfg = MjpegConfig()) ### Description Streams Motion JPEG data to the provided client. ``` -------------------------------- ### Define initial resolution variable Source: https://esp32cam.yoursunny.dev/AsyncCam_8ino.html Variable declaration for the camera resolution using the esp32cam namespace. ```cpp esp32cam::Resolution initialResolution ``` -------------------------------- ### writeTo() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1detail_1_1MjpegHeader.html Writes the prepared header data to the specified output stream. ```APIDOC ## size_t writeTo(Print &os) ### Description Writes the buffered header data to the provided Print object. ### Parameters - **os** (Print &) - The output stream to write the headers to. ### Returns - **size_t** - The number of bytes written. ### Signature `size_t writeTo(Print &os)` ``` -------------------------------- ### esp32cam::Resolution::find Source: https://esp32cam.yoursunny.dev/resolution_8hpp_source.html Finds a resolution that satisfies the specified minimum width and height constraints. ```APIDOC ## static Resolution find(int minWidth, int minHeight) ### Description Finds a resolution that satisfies given constraints. ### Parameters - **minWidth** (int) - The minimum required width in pixels. - **minHeight** (int) - The minimum required height in pixels. ### Returns - **Resolution** - A Resolution object meeting the criteria. ``` -------------------------------- ### prepareResponseContentType() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1detail_1_1MjpegHeader.html Prepares the Content-Type header for the MJPEG stream. ```APIDOC ## void prepareResponseContentType() ### Description Sets the Content-Type header to the appropriate MIME type for MJPEG streaming. ### Signature `void prepareResponseContentType()` ``` -------------------------------- ### Include MJPEG headers Source: https://esp32cam.yoursunny.dev/mjpeg_8cpp.html Required headers for utilizing MJPEG functionality and logging within the project. ```cpp #include "mjpeg.hpp" #include "logger.hpp" ``` -------------------------------- ### Define MJPEG logging macro Source: https://esp32cam.yoursunny.dev/mjpeg_8cpp.html Macro for logging MJPEG controller events with instance pointer identification. ```cpp #define MC_LOG(fmt, ...) ESP32CAM_LOG("MjpegController(%p) " fmt, this, ##__VA_ARGS__) ``` -------------------------------- ### esp32cam::ResolutionList Source: https://esp32cam.yoursunny.dev/resolution_8hpp_source.html A collection of available camera resolutions. ```APIDOC ## esp32cam::ResolutionList ### Methods - **Iterator begin() const** - Returns an iterator to the beginning of the resolution list. - **Iterator end() const** - Returns an iterator to the end of the resolution list. - **Resolution find(int minWidth, int minHeight) const** - Finds a resolution within the list that satisfies the given width and height constraints. ``` -------------------------------- ### Define LightMode enumeration Source: https://esp32cam.yoursunny.dev/config_8hpp.html Enumeration for white balance and light mode settings. ```cpp enum class esp32cam::LightMode { esp32cam::NONE = -1 , esp32cam::AUTO = 0 , esp32cam::SUNNY = 1 , esp32cam::CLOUDY = 2 , esp32cam::OFFICE = 3 , esp32cam::HOME = 4 } ``` -------------------------------- ### setPins(const Pins &pins) Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Config.html Configures the hardware pins for the camera interface. ```APIDOC ## Config::setPins(const Pins &pins) ### Description Sets the hardware pins for the camera. ### Parameters - **pins** (const Pins &) - Required - The pin configuration object. ``` -------------------------------- ### esp32cam::MjpegConfig Source: https://esp32cam.yoursunny.dev/structesp32cam_1_1MjpegConfig.html Configuration structure for MJPEG stream options. ```APIDOC ## struct esp32cam::MjpegConfig ### Description Configuration structure used to define settings for MJPEG streaming. ### Public Attributes - **minInterval** (int) - Minimum interval between frame captures in milliseconds. A negative value causes the response to enter continuous mode. Default is 0. - **maxFrames** (int) - Maximum number of frames before disconnecting. A negative value means unlimited. Default is -1. - **frameTimeout** (int) - Time limit for writing one frame in milliseconds. Default is 10000. ``` -------------------------------- ### setResolution(const Resolution &resolution) Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Config.html Sets the image resolution for the camera. ```APIDOC ## Config::setResolution(const Resolution &resolution) ### Description Sets the camera resolution. ### Parameters - **resolution** (const Resolution &) - Required - The resolution configuration object. ``` -------------------------------- ### CameraClass Header Definition Source: https://esp32cam.yoursunny.dev/camera_8hpp_source.html The header file defining the CameraClass interface and its public methods for camera management. ```cpp #ifndef ESP32CAM_CAMERA_HPP #define ESP32CAM_CAMERA_HPP #include "config.hpp" #include "mjpeg.hpp" #include namespace esp32cam { class CameraClass { public: 16 bool begin(const Config& config); 22 bool end(); 28 ResolutionList listResolutions() const; 37 bool changeResolution(const Resolution& resolution, int sleepFor = 500); 43 Settings status() const; 53 bool update(const Settings& settings, int sleepFor = 0); 63 template 64 std::enable_if_t, Fn>, bool> // 65 update(const Fn& modifier, int sleepFor = 0) { 66 Settings settings = status(); 67 modifier(settings); 68 return update(settings, sleepFor); 69 } 65 update(const Fn& modifier, int sleepFor = 0) {…} 76 std::unique_ptr capture(); 83 int streamMjpeg(Client& client, const MjpegConfig& cfg = MjpegConfig()); 84}; 10class CameraClass {…}; 87extern CameraClass Camera; 89} // namespace esp32cam #endif // ESP32CAM_CAMERA_HPP ``` -------------------------------- ### Frame::toJpeg() / Frame::toBmp() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Frame.html Converts the current frame buffer to JPEG or BMP format. ```APIDOC ### bool toJpeg(int quality) Converts the frame to JPEG format. - **quality**: JPEG quality between 0 (worst) and 100 (best). ### bool toBmp() Converts the frame to BMP format. ``` -------------------------------- ### setLogger() Source: https://esp32cam.yoursunny.dev/namespacemembers_func.html Configures the logger for the library. ```APIDOC ## setLogger() ### Description Sets the logger instance used by the library. ### Namespace esp32cam ``` -------------------------------- ### MJPEG Configuration and Controller Definition Source: https://esp32cam.yoursunny.dev/mjpeg_8hpp_source.html Defines the configuration parameters for MJPEG streams and the controller class responsible for managing frame lifecycle and stream actions. ```cpp #ifndef ESP32CAM_MJPEG_HPP #define ESP32CAM_MJPEG_HPP #include "frame.hpp" #include namespace esp32cam { struct MjpegConfig { int minInterval = 0; int maxFrames = -1; int frameTimeout = 10000; }; namespace detail { class MjpegController { public: explicit MjpegController(MjpegConfig cfg); int countSentFrames() const { return m_count; } int decideAction(); void notifyCapture(); void notifyReturn(std::unique_ptr frame); Frame* getFrame() const { return m_frame.get(); } void notifySent(bool ok); void notifyFail(); public: enum Action { CAPTURE = -1, RETURN = -2, SEND = -3, STOP = -4, }; const MjpegConfig cfg; private: std::unique_ptr m_frame; unsigned long m_nextCaptureTime; int m_nextAction = CAPTURE; int m_count = 0; }; class MjpegHeader { public: void prepareResponseHeaders(); void prepareResponseContentType(); void prepareBoundary(size_t contentLength); void prepareTrailer(); size_t writeTo(Print& os); public: size_t size = 0; char buf[120]; }; } // namespace detail } // namespace esp32cam #endif // ESP32CAM_MJPEG_HPP ``` -------------------------------- ### Resolution(int frameSize) Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Resolution.html Constructor for the Resolution class. ```APIDOC ## Resolution(int frameSize) ### Description Constructs a new Resolution object. ### Parameters - **frameSize** (int) - Optional - The framesize_t value. ``` -------------------------------- ### int streamMjpeg(Client &client, const MjpegConfig &cfg) Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1CameraClass.html Streams Motion JPEG data to a client. ```APIDOC ## int streamMjpeg(Client &client, const MjpegConfig &cfg) ### Description Streams Motion JPEG to the provided client. The camera must be initialized in JPEG mode. ### Parameters - **client** (Client &) - Required - The client to stream data to. - **cfg** (const MjpegConfig &) - Optional - Configuration for the MJPEG stream. ### Returns - **int** - The number of frames successfully streamed. ``` -------------------------------- ### Define ESP32CAM_LOG Macro Source: https://esp32cam.yoursunny.dev/logger_8hpp.html This macro provides conditional logging to a Print object if it has been initialized. ```cpp #define ESP32CAM_LOG(fmt, ...) do { \ if (LogOutput != nullptr) { \ LogOutput->printf("[%8lu] " fmt "\n", millis(), ##__VA_ARGS__); \ } \ } while (false) ``` -------------------------------- ### ESP32CAM_LOG Source: https://esp32cam.yoursunny.dev/logger_8hpp.html A macro for logging formatted messages with a timestamp. ```APIDOC ## ESP32CAM_LOG(fmt, ...) ### Description Logs a formatted message to the configured logger output, prefixed with the current system uptime in milliseconds. This macro only executes if a logger has been set via setLogger. ### Parameters - **fmt** (string) - Required - The format string for the log message. - **...** (variadic) - Optional - Arguments for the format string. ``` -------------------------------- ### ResolutionList(int max) Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1ResolutionList.html Constructor for the ResolutionList class. Initializes a collection of resolutions with an optional exclusive maximum framesize_t. ```APIDOC ## ResolutionList(int max) ### Description Constructs a new ResolutionList object. ### Parameters - **max** (int) - Optional - Exclusive maximum framesize_t. ``` -------------------------------- ### ESP32CAM Header Definition Source: https://esp32cam.yoursunny.dev/esp32cam_8h_source.html The main header file for the ESP32-CAM library, including necessary dependencies and the capture function wrapper. ```cpp #ifndef ESP32CAM_H #define ESP32CAM_H #include "esp32cam/asyncweb.hpp" #include "esp32cam/camera.hpp" #include "esp32cam/logger.hpp" namespace esp32cam { inline std::unique_ptr capture() { return Camera.capture(); } } // namespace esp32cam #endif // ESP32CAM_H ``` -------------------------------- ### Set Logger Output Function Source: https://esp32cam.yoursunny.dev/logger_8hpp.html Configures the output destination for the library's logging system. ```cpp void esp32cam::setLogger (Print &output) ``` -------------------------------- ### esp32cam::capture() Source: https://esp32cam.yoursunny.dev/esp32cam_8h_source.html Captures a single frame of picture from the camera. ```APIDOC ## esp32cam::capture() ### Description Captures a frame with the camera and returns a unique pointer to the captured Frame object. ### Signature std::unique_ptr capture() ### Returns - **std::unique_ptr** - A pointer to the captured image frame. ``` -------------------------------- ### setJpeg(int quality) Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Config.html Configures the camera to output in JPEG format with a specified quality level. ```APIDOC ## Config::setJpeg(int quality) ### Description Changes the pixel format to JPEG. ### Parameters - **quality** (int) - Required - JPEG quality between 0 (worst) and 100 (best). ``` -------------------------------- ### getWidth() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Resolution.html Retrieves the width of the resolution. ```APIDOC ## int getWidth() ### Description Returns the picture width in pixels. ### Returns - **int** - Width in pixels. ``` -------------------------------- ### esp32cam::setLogger Source: https://esp32cam.yoursunny.dev/logger_8hpp.html Configures the output stream for the library's logging system. ```APIDOC ## void esp32cam::setLogger(Print &output) ### Description Sets the output destination for library logs. The provided object must inherit from the Arduino Print class. ### Parameters - **output** (Print&) - Required - The stream object (e.g., Serial) to which logs will be written. ``` -------------------------------- ### Request Handler Registration Source: https://esp32cam.yoursunny.dev/AsyncCam_2handlers_8cpp.html Function to register request handlers for the camera server. ```cpp void addRequestHandlers () ``` -------------------------------- ### Logger Header Definition Source: https://esp32cam.yoursunny.dev/logger_8hpp_source.html The complete header file content defining the logger interface and the ESP32CAM_LOG macro. ```cpp #ifndef ESP32CAM_LOGGER_HPP #define ESP32CAM_LOGGER_HPP #include namespace esp32cam { extern Print* LogOutput; inline void setLogger(Print& output) { LogOutput = &output; } #define ESP32CAM_LOG(fmt, ...) \ do { \ if (LogOutput != nullptr) { \ LogOutput->printf("[%8lu] " fmt "\n", millis(), ##__VA_ARGS__); \ } \ } while (false) } // namespace esp32cam #endif // ESP32CAM_LOGGER_HPP ``` -------------------------------- ### esp32cam::Resolution Source: https://esp32cam.yoursunny.dev/resolution_8hpp_source.html Represents a camera resolution setting. ```APIDOC ## esp32cam::Resolution ### Methods - **static Resolution list()** - Returns a list of available resolutions. - **static Resolution find(int minWidth, int minHeight)** - Finds a resolution that meets the minimum width and height requirements. - **bool isValid() const** - Checks if the resolution is valid. - **int getWidth() const** - Returns the width of the resolution. - **int getHeight() const** - Returns the height of the resolution. - **template T as() const** - Casts the internal frame size to the specified type. ``` -------------------------------- ### Define Pins Structure Source: https://esp32cam.yoursunny.dev/pins_8hpp_source.html The base structure used to define the GPIO mapping for camera modules. ```cpp struct Pins { int D0; int D1; int D2; int D3; int D4; int D5; int D6; int D7; int XCLK; int PCLK; int VSYNC; int HREF; int SDA; int SCL; int RESET; int PWDN; }; ``` -------------------------------- ### getHeight() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Resolution.html Retrieves the height of the resolution. ```APIDOC ## int getHeight() ### Description Returns the picture height in pixels. ### Returns - **int** - Height in pixels. ``` -------------------------------- ### CaptureTask Class Definition Source: https://esp32cam.yoursunny.dev/asyncweb_8hpp_source.html Manages background frame capture tasks with configurable queue length and priority. ```cpp class CaptureTask { public: explicit CaptureTask(uint32_t queueLength, uint32_t priority = 1, bool continuous = false); ~CaptureTask(); explicit operator bool() const { return m_queue != nullptr && m_task != nullptr; } void request(); std::unique_ptr retrieve(); private: static void run0(void* ctx); void run(); private: void* m_queue = nullptr; void* m_task = nullptr; bool m_continuous; }; ``` -------------------------------- ### Frame::getWidth() / getHeight() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Frame.html Retrieves the dimensions of the captured frame. ```APIDOC ### int getWidth() Returns the width of the frame in pixels. ### int getHeight() Returns the height of the frame in pixels. ``` -------------------------------- ### MjpegController::decideAction() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1detail_1_1MjpegController.html Determines the next action to perform in the MJPEG stream lifecycle based on current state. ```APIDOC ## int decideAction() ### Description Decide what to do next in the MJPEG stream. Returns an action code or a delay duration. ### Returns - **int**: If non-negative, represents the delay in milliseconds before the next action. If negative, returns an Action enum value (CAPTURE, RETURN, SEND, or STOP). ``` -------------------------------- ### Frame::data() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Frame.html Returns a pointer to the raw frame buffer data. ```APIDOC ### uint8_t* data() Returns a pointer to the raw image data buffer. ``` -------------------------------- ### esp32cam::Resolution::getHeight Source: https://esp32cam.yoursunny.dev/resolution_8hpp_source.html Retrieves the height of the resolution in pixels. ```APIDOC ## int getHeight() const ### Description Return picture height in pixels. ### Returns - **int** - Height in pixels. ``` -------------------------------- ### Resolution Class Definition Source: https://esp32cam.yoursunny.dev/resolution_8hpp_source.html Defines the Resolution class which inherits from Printable and provides methods to query and compare camera resolutions. ```cpp #ifndef ESP32CAM_RESOLUTION_HPP #define ESP32CAM_RESOLUTION_HPP #include #include namespace esp32cam { class ResolutionList; class Resolution : public Printable { public: static ResolutionList list(); static Resolution find(int minWidth, int minHeight); explicit Resolution(int frameSize = -1); bool isValid() const; int getWidth() const; int getHeight() const; size_t printTo(Print& p) const override; template T as() const { return static_cast(m_frameSize); } private: int m_frameSize; friend bool operator==(const Resolution& lhs, const Resolution& rhs) { return (!lhs.isValid() && !rhs.isValid()) || (lhs.m_frameSize == rhs.m_frameSize); } friend bool operator!=(const Resolution& lhs, const Resolution& rhs) { return !(lhs == rhs); } friend bool operator<(const Resolution& lhs, const Resolution& rhs) { return lhs.m_frameSize < rhs.m_frameSize; } friend bool operator>(const Resolution& lhs, const Resolution& rhs) { return lhs.m_frameSize > rhs.m_frameSize; } }; ``` -------------------------------- ### ResolutionList Class Definition Source: https://esp32cam.yoursunny.dev/resolution_8hpp_source.html Defines the ResolutionList class and its nested Iterator for traversing available camera resolutions. ```cpp class ResolutionList { public: class Iterator { public: using iterator_catagory = std::forward_iterator_tag; using value_type = const Resolution; using difference_type = std::ptrdiff_t; using pointer = void; using reference = value_type; explicit Iterator(int value = -1) : m_frameSize(value) {} Iterator& operator++() { ++m_frameSize; return *this; } Iterator operator++(int) { Iterator copy(*this); ++*this; return copy; } reference operator*() { return Resolution(m_frameSize); } private: int m_frameSize; friend bool operator==(const Iterator& lhs, const Iterator& rhs) { return lhs.m_frameSize == rhs.m_frameSize; } friend bool operator!=(const Iterator& lhs, const Iterator& rhs) { return !(lhs == rhs); } }; explicit ResolutionList(int max = 0); Iterator begin() const; Iterator end() const; Resolution find(int minWidth, int minHeight) const; private: int m_max; }; ``` -------------------------------- ### Capture a frame Source: https://esp32cam.yoursunny.dev/esp32cam_8h.html Use this function to capture a single frame from the OV2640 camera. ```cpp std::unique_ptr< Frame > esp32cam::capture () ``` -------------------------------- ### std::unique_ptr capture() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1CameraClass.html Captures a single frame from the camera. ```APIDOC ## std::unique_ptr capture() ### Description Captures a picture frame. The camera must be enabled before calling this method. ### Returns - **std::unique_ptr** - The captured picture frame, or nullptr if an error occurred. ``` -------------------------------- ### esp32cam::Frame Methods Source: https://esp32cam.yoursunny.dev/frame_8hpp_source.html Public methods available for the Frame class to interact with captured image data. ```APIDOC ## uint8_t* data() Returns a pointer to the raw frame data. ## size_t size() Returns the size of the frame data in bytes. ## int getWidth() Returns the width of the frame in pixels. ## int getHeight() Returns the height of the frame in pixels. ## bool writeTo(Print& os, int timeout = 10000) Writes the frame buffer to the provided Print object. ## bool writeTo(Client& os, int timeout = 10000) Writes the frame buffer to the provided Client object. ## bool isJpeg() Checks if the current frame is in JPEG format. ## bool toJpeg(int quality) Converts the current frame to JPEG format with the specified quality. ## bool isBmp() Checks if the current frame is in BMP format. ## bool toBmp() Converts the current frame to BMP format. ``` -------------------------------- ### ESP32-CAM Hardware Pin Definitions Source: https://esp32cam.yoursunny.dev/namespaceesp32cam_1_1pins.html These constexpr structures define the GPIO pin mappings for various supported ESP32-CAM development boards. ```cpp { D0: 5, D1: 18, D2: 19, D3: 21, D4: 36, D5: 39, D6: 34, D7: 35, XCLK: 0, PCLK: 22, VSYNC: 25, HREF: 23, SDA: 26, SCL: 27, RESET: -1, PWDN: 32, } ``` ```cpp { D0: 4, D1: 5, D2: 18, D3: 19, D4: 36, D5: 39, D6: 34, D7: 35, XCLK: 21, PCLK: 22, VSYNC: 25, HREF: 23, SDA: 26, SCL: 27, RESET: -1, PWDN: -1, } ``` ```cpp { D0: 32, D1: 35, D2: 34, D3: 5, D4: 39, D5: 18, D6: 36, D7: 19, XCLK: 27, PCLK: 21, VSYNC: 25, HREF: 26, SDA: 22, SCL: 23, RESET: 15, PWDN: -1, } ``` ```cpp { D0: 32, D1: 35, D2: 34, D3: 5, D4: 39, D5: 18, D6: 36, D7: 19, XCLK: 27, PCLK: 21, VSYNC: 25, HREF: 26, SDA: 22, SCL: 23, RESET: 15, PWDN: 14, } ``` ```cpp { D0: 11, D1: 9, D2: 8, D3: 10, D4: 12, D5: 18, D6: 17, D7: 16, XCLK: 15, PCLK: 13, VSYNC: 6, HREF: 7, SDA: 4, SCL: 5, RESET: -1, PWDN: -1, } ``` ```cpp { D0: 5, D1: 14, D2: 4, D3: 15, D4: 37, D5: 38, D6: 36, D7: 39, XCLK: 32, PCLK: 19, VSYNC: 27, HREF: 25, SDA: 13, SCL: 12, RESET: -1, PWDN: -1, } ``` ```cpp { D0: 15, D1: 17, D2: 18, D3: 16, D4: 14, D5: 12, D6: 11, D7: 48, XCLK: 10, PCLK: 13, VSYNC: 38, HREF: 47, SDA: 40, SCL: 39, RESET: -1, PWDN: -1, } ``` -------------------------------- ### esp32cam::Resolution::getWidth Source: https://esp32cam.yoursunny.dev/resolution_8hpp_source.html Retrieves the width of the resolution in pixels. ```APIDOC ## int getWidth() const ### Description Return picture width in pixels. ### Returns - **int** - Width in pixels. ``` -------------------------------- ### operator++(int) Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1ResolutionList_1_1Iterator.html Increments the iterator to the next position (postfix). ```APIDOC ## Iterator operator++(int) ### Description Postfix increment operator to move the iterator to the next element in the list. ``` -------------------------------- ### operator== and operator!= Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1ResolutionList_1_1Iterator.html Comparison operators for the Iterator class. ```APIDOC ## bool operator==(const Iterator &lhs, const Iterator &rhs) ## bool operator!=(const Iterator &lhs, const Iterator &rhs) ### Description Compares two iterators for equality or inequality. ``` -------------------------------- ### Frame::size() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Frame.html Returns the size of the frame buffer in bytes. ```APIDOC ### size_t size() Returns the total size of the frame buffer in bytes. ``` -------------------------------- ### isValid() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Resolution.html Checks if the current resolution instance is valid. ```APIDOC ## bool isValid() ### Description Determines if this resolution is valid. ### Returns - **bool** - True if valid, false otherwise. ``` -------------------------------- ### Frame::writeTo() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1Frame.html Writes the frame buffer to a specified output stream or client socket. ```APIDOC ### bool writeTo(Print &os, int timeout=10000) ### bool writeTo(Client &os, int timeout=10000) Writes the frame buffer to the provided output stream or socket. - **os**: The output stream or client socket. - **timeout**: Total time limit in milliseconds (default 10000). Returns true if writing completed successfully, false otherwise. ``` -------------------------------- ### MjpegController::notifySent() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1detail_1_1MjpegController.html Notifies the controller that a frame has been sent to the client. ```APIDOC ## void notifySent(bool ok) ### Description Notify that a frame is sent to the client. ### Parameters - **ok** (bool) - Whether the frame was sent successfully. ``` -------------------------------- ### esp32cam::Resolution::isValid Source: https://esp32cam.yoursunny.dev/resolution_8hpp_source.html Checks if the current resolution instance is valid. ```APIDOC ## bool isValid() const ### Description Determine if this resolution is valid. ### Returns - **bool** - True if valid, false otherwise. ``` -------------------------------- ### end() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1ResolutionList.html Returns an iterator to the end of the resolution collection. ```APIDOC ## end() ### Description Returns an iterator pointing to the element following the last resolution in the list. ``` -------------------------------- ### MjpegController::notifyReturn() Source: https://esp32cam.yoursunny.dev/classesp32cam_1_1detail_1_1MjpegController.html Notifies the controller that a frame capture has completed. ```APIDOC ## void notifyReturn(std::unique_ptr frame) ### Description Notify that frame capture has completed. ### Parameters - **frame** (std::unique_ptr) - The captured frame, possibly nullptr. ``` -------------------------------- ### convertJpegQuality Source: https://esp32cam.yoursunny.dev/namespaceesp32cam_1_1detail.html Converts a JPEG quality value from a standard 0-100 scale to the 63-0 scale required by the hardware. ```APIDOC ## int convertJpegQuality(int quality) ### Description Converts JPEG quality from a 0-100 scale to the 63-0 scale used by the OV2640 camera hardware. ### Parameters - **quality** (int) - Required - The quality value on a 0-100 scale. ### Returns - (int) - The converted quality value on a 63-0 scale. ```