init
This commit is contained in:
31
include/camera_service.h
Normal file
31
include/camera_service.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#include "esp_camera.h"
|
||||
|
||||
class CameraService {
|
||||
public:
|
||||
class Frame {
|
||||
camera_fb_t* fb;
|
||||
public:
|
||||
Frame(camera_fb_t* _fb) : fb(_fb) {}
|
||||
~Frame() {
|
||||
if (fb) {
|
||||
esp_camera_fb_return(fb);
|
||||
}
|
||||
}
|
||||
|
||||
Frame(const Frame&) = delete;
|
||||
Frame& operator=(const Frame&) = delete;
|
||||
Frame(Frame&& other) noexcept : fb(other.fb) {
|
||||
other.fb = nullptr;
|
||||
}
|
||||
|
||||
bool isValid() const { return fb != nullptr; }
|
||||
uint8_t* getData() const { return fb ? fb->buf : nullptr; }
|
||||
size_t getWidth() const { return fb ? fb->width : 0; }
|
||||
size_t getHeight() const { return fb ? fb->height : 0; }
|
||||
size_t getLength() const { return fb ? fb->len : 0; }
|
||||
};
|
||||
|
||||
static void init();
|
||||
static Frame capture();
|
||||
};
|
||||
Reference in New Issue
Block a user