mirror of
https://github.com/m5stack/xiaoling-esp32.git
synced 2026-05-20 11:42:56 -07:00
feat(common_esp32s3): 增加 UVC 摄像头驱动
This commit is contained in:
@@ -34,6 +34,12 @@ file(GLOB BOARD_COMMON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/boards/common/*.cc)
|
||||
list(APPEND SOURCES ${BOARD_COMMON_SOURCES})
|
||||
list(APPEND INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/boards/common)
|
||||
|
||||
if(CONFIG_IDF_TARGET_ESP32S3)
|
||||
file(GLOB BOARD_COMMON_ESP32S3_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/boards/common_esp32s3/*.cc)
|
||||
list(APPEND SOURCES ${BOARD_COMMON_ESP32S3_SOURCES})
|
||||
list(APPEND INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/boards/common_esp32s3)
|
||||
endif()
|
||||
|
||||
# 根据 BOARD_TYPE 配置添加对应的板级文件
|
||||
if(CONFIG_BOARD_TYPE_BREAD_COMPACT_WIFI)
|
||||
set(BOARD_TYPE "bread-compact-wifi")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,62 @@
|
||||
#ifndef USB_ESP32_CAMERA_H
|
||||
#define USB_ESP32_CAMERA_H
|
||||
|
||||
#include <esp_camera.h>
|
||||
#include <lvgl.h>
|
||||
#include <thread>
|
||||
#include <memory>
|
||||
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/queue.h>
|
||||
#include "ppbuffer.h"
|
||||
#include "usb_stream.h"
|
||||
#include "esp_jpeg_common.h"
|
||||
#include "esp_jpeg_dec.h"
|
||||
#include "camera.h"
|
||||
|
||||
#define DEMO_KEY_RESOLUTION "resolution"
|
||||
#define DEMO_UVC_XFER_BUFFER_SIZE ( 88 * 1024) /* 双缓冲 */
|
||||
#define BIT0_FRAME_START (0x01 << 0)
|
||||
|
||||
struct JpegChunk {
|
||||
uint8_t* data;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
} camera_frame_size_t;
|
||||
|
||||
struct JpegData {
|
||||
uint8_t* fb_buf;
|
||||
size_t fb_buf_size;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
camera_frame_size_t camera_frame_size;
|
||||
uvc_frame_size_t *camera_frame_list;
|
||||
size_t camera_frame_list_num;
|
||||
size_t camera_currect_frame_index;
|
||||
} camera_resolution_info_t;
|
||||
|
||||
class USB_Esp32Camera : public Camera {
|
||||
private:
|
||||
lv_img_dsc_t preview_image_;
|
||||
std::string explain_url_;
|
||||
std::string explain_token_;
|
||||
std::thread encoder_thread_;
|
||||
|
||||
public:
|
||||
USB_Esp32Camera();
|
||||
~USB_Esp32Camera();
|
||||
|
||||
virtual void SetExplainUrl(const std::string& url, const std::string& token);
|
||||
virtual bool Capture();
|
||||
// 翻转控制函数
|
||||
virtual bool SetHMirror(bool enabled) override;
|
||||
virtual bool SetVFlip(bool enabled) override;
|
||||
virtual std::string Explain(const std::string& question);
|
||||
};
|
||||
|
||||
#endif // ESP32_CAMERA_H
|
||||
@@ -74,6 +74,14 @@ dependencies:
|
||||
rules:
|
||||
- if: target in [esp32c3]
|
||||
espressif/esp_new_jpeg: ^0.5.*
|
||||
lijunru-hub/esp-ppbuffer:
|
||||
version: ^0.1.0
|
||||
rules:
|
||||
- if: target in [esp32s3]
|
||||
espressif/usb_stream:
|
||||
version: ^1.5.1
|
||||
rules:
|
||||
- if: target in [esp32s3]
|
||||
|
||||
## Required IDF version
|
||||
idf:
|
||||
|
||||
Reference in New Issue
Block a user