Files
xiaozhi-esp32/main/boards/common/esp32s3_camera.h
Kevincoooool d5ec8f7081 Add ESP32-S3 camera component selection and support (#1670)
Introduces a new esp32s3_camera implementation for ESP32-S3 boards using the esp_camera component, with conditional compilation and Kconfig options to select between esp_camera and esp_video. Updates board initialization code and config files to use the new camera class where appropriate, and adjusts build system and dependencies to support both camera components on ESP32-S3 and ESP32-P4 targets.
2026-01-20 19:56:36 +08:00

54 lines
1.3 KiB
C++

#pragma once
#include "sdkconfig.h"
// esp32s3_camera (使用 esp_camera 组件) 仅用于 ESP32-S3 且选择使用 esp_camera 时
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(CONFIG_XIAOZHI_USE_ESP_CAMERA)
#include <lvgl.h>
#include <thread>
#include <memory>
#include <vector>
#include <freertos/FreeRTOS.h>
#include <freertos/queue.h>
#include "camera.h"
#include "esp_camera.h"
struct JpegChunk
{
uint8_t *data;
size_t len;
};
class Esp32S3Camera : public Camera
{
private:
struct FrameBuffer
{
uint8_t *data = nullptr;
size_t len = 0;
uint16_t width = 0;
uint16_t height = 0;
pixformat_t format = PIXFORMAT_RGB565;
} frame_;
bool streaming_on_ = false;
std::string explain_url_;
std::string explain_token_;
std::thread encoder_thread_;
camera_fb_t *current_fb_ = nullptr;
public:
Esp32S3Camera(const camera_config_t &config);
~Esp32S3Camera();
virtual void SetExplainUrl(const std::string &url, const std::string &token) override;
virtual bool Capture() override;
virtual bool SetHMirror(bool enabled) override;
virtual bool SetVFlip(bool enabled) override;
virtual std::string Explain(const std::string &question) override;
};
#endif // CONFIG_IDF_TARGET_ESP32S3 && CONFIG_XIAOZHI_USE_ESP_CAMERA