88 lines
1.8 KiB
C++
88 lines
1.8 KiB
C++
/**
|
|
* Claude's Eyes - Camera Module Header
|
|
*
|
|
* Handles OV5640 camera initialization and image capture
|
|
*/
|
|
|
|
#ifndef CAMERA_H
|
|
#define CAMERA_H
|
|
|
|
#include <Arduino.h>
|
|
#include "esp_camera.h"
|
|
|
|
// Resolution enum for easy selection
|
|
enum CameraResolution {
|
|
RES_QVGA, // 320x240
|
|
RES_VGA, // 640x480
|
|
RES_SVGA, // 800x600
|
|
RES_XGA, // 1024x768
|
|
RES_SXGA, // 1280x1024
|
|
RES_UXGA // 1600x1200
|
|
};
|
|
|
|
class CameraModule {
|
|
public:
|
|
CameraModule();
|
|
|
|
/**
|
|
* Initialize the camera
|
|
* @return true if successful
|
|
*/
|
|
bool begin();
|
|
|
|
/**
|
|
* Capture a JPEG image
|
|
* @param quality JPEG quality (10-63, lower = better)
|
|
* @return Camera frame buffer (must be returned with returnFrame())
|
|
*/
|
|
camera_fb_t* capture(int quality = -1);
|
|
|
|
/**
|
|
* Return frame buffer after use
|
|
* @param fb Frame buffer to return
|
|
*/
|
|
void returnFrame(camera_fb_t* fb);
|
|
|
|
/**
|
|
* Set camera resolution
|
|
* @param resolution Resolution enum value
|
|
* @return true if successful
|
|
*/
|
|
bool setResolution(CameraResolution resolution);
|
|
|
|
/**
|
|
* Set JPEG quality
|
|
* @param quality Quality value (10-63, lower = better)
|
|
* @return true if successful
|
|
*/
|
|
bool setQuality(int quality);
|
|
|
|
/**
|
|
* Get current resolution as string
|
|
*/
|
|
const char* getResolutionString();
|
|
|
|
/**
|
|
* Check if camera is initialized
|
|
*/
|
|
bool isInitialized() { return _initialized; }
|
|
|
|
/**
|
|
* Get last error message
|
|
*/
|
|
const char* getLastError() { return _lastError; }
|
|
|
|
private:
|
|
bool _initialized;
|
|
const char* _lastError;
|
|
CameraResolution _currentResolution;
|
|
int _currentQuality;
|
|
|
|
framesize_t resolutionToFramesize(CameraResolution res);
|
|
};
|
|
|
|
// Global instance
|
|
extern CameraModule Camera;
|
|
|
|
#endif // CAMERA_H
|