forked from xiaozhi/xiaozhi-esp32
增加DFRobot ESP32-S3 AI智能摄像头模块,适配视觉识别功能 (#692)
* 增加 DFRobot ESP32-S3 AI智能摄像头模块 * 适配视觉识别功能 * 修改dfrobot-esp32-s3-ai-cam为df-s3-ai-cam
This commit is contained in:
@@ -46,6 +46,8 @@ elseif(CONFIG_BOARD_TYPE_BREAD_COMPACT_ESP32_LCD)
|
||||
set(BOARD_TYPE "bread-compact-esp32-lcd")
|
||||
elseif(CONFIG_BOARD_TYPE_DF_K10)
|
||||
set(BOARD_TYPE "df-k10")
|
||||
elseif(CONFIG_BOARD_TYPE_DF_S3_AI_CAM)
|
||||
set(BOARD_TYPE "df-s3-ai-cam")
|
||||
elseif(CONFIG_BOARD_TYPE_ESP_BOX_3)
|
||||
set(BOARD_TYPE "esp-box-3")
|
||||
elseif(CONFIG_BOARD_TYPE_ESP_BOX)
|
||||
|
||||
@@ -64,6 +64,8 @@ choice BOARD_TYPE
|
||||
bool "立创·实战派ESP32-C3开发板"
|
||||
config BOARD_TYPE_DF_K10
|
||||
bool "DFRobot 行空板 k10"
|
||||
config BOARD_TYPE_DF_S3_AI_CAM
|
||||
bool "DFRobot ESP32-S3 AI智能摄像头模块"
|
||||
config BOARD_TYPE_MAGICLICK_2P4
|
||||
bool "神奇按钮 Magiclick_2.4"
|
||||
config BOARD_TYPE_MAGICLICK_2P5
|
||||
|
||||
54
main/boards/df-s3-ai-cam/README.md
Normal file
54
main/boards/df-s3-ai-cam/README.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# DFRobot ESP32-S3 AI智能摄像头模块
|
||||
|
||||
## 介绍
|
||||
ESP32-S3 AI CAM是一款基于ESP32-S3芯片设计的智能摄像头模组,专为视频图像处理和语音交互打造,适用于视频监控、边缘图像识别、语音对话等AI项目。
|
||||

|
||||
|
||||
[点击查看详细介绍](https://wiki.dfrobot.com.cn/SKU_DFR1154_ESP32_S3_AI_CAM)
|
||||
|
||||
[点击查看视觉功能演示](https://www.bilibili.com/video/BV1ktjSzNEUU/)
|
||||
|
||||
# 特性
|
||||
* 使用PDM麦克风
|
||||
* 板载 OV3660 摄像头
|
||||
|
||||
## 按键配置
|
||||
* BOOT:短按-打断/唤醒
|
||||
|
||||
## 编译配置命令
|
||||
|
||||
**配置编译目标为 ESP32S3:**
|
||||
|
||||
```bash
|
||||
idf.py set-target esp32s3
|
||||
```
|
||||
|
||||
**打开 menuconfig:**
|
||||
|
||||
```bash
|
||||
idf.py menuconfig
|
||||
```
|
||||
|
||||
**选择板子:**
|
||||
|
||||
```
|
||||
Xiaozhi Assistant -> Board Type -> DFRobot ESP32-S3 AI智能摄像头模块
|
||||
```
|
||||
|
||||
**修改 psram 配置:**
|
||||
|
||||
```
|
||||
Component config -> ESP PSRAM -> SPI RAM config -> Mode (QUAD/OCT) -> Octal Mode PSRAM
|
||||
```
|
||||
|
||||
**修改 WiFi 发射功率 为 10:**
|
||||
|
||||
```
|
||||
Component config -> PHY -> (10)Max WiFi TX power (dBm)
|
||||
```
|
||||
|
||||
**编译:**
|
||||
|
||||
```bash
|
||||
idf.py build
|
||||
```
|
||||
63
main/boards/df-s3-ai-cam/config.h
Normal file
63
main/boards/df-s3-ai-cam/config.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifndef _BOARD_CONFIG_H_
|
||||
#define _BOARD_CONFIG_H_
|
||||
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#define AUDIO_INPUT_SAMPLE_RATE 16000
|
||||
#define AUDIO_OUTPUT_SAMPLE_RATE 24000
|
||||
|
||||
#define AUDIO_I2S_MIC_GPIO_SCK GPIO_NUM_38
|
||||
#define AUDIO_I2S_MIC_GPIO_DIN GPIO_NUM_39
|
||||
#define AUDIO_I2S_SPK_GPIO_DOUT GPIO_NUM_42
|
||||
#define AUDIO_I2S_SPK_GPIO_BCLK GPIO_NUM_45
|
||||
#define AUDIO_I2S_SPK_GPIO_LRCK GPIO_NUM_46
|
||||
#define AUDIO_I2S_SPK_GPIO_GAIN GPIO_NUM_41
|
||||
|
||||
#define BUILTIN_LED_GPIO GPIO_NUM_3
|
||||
#define BOOT_BUTTON_GPIO GPIO_NUM_0
|
||||
#define TOUCH_BUTTON_GPIO GPIO_NUM_NC
|
||||
#define VOLUME_UP_BUTTON_GPIO GPIO_NUM_NC
|
||||
#define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_NC
|
||||
#define RESET_NVS_BUTTON_GPIO GPIO_NUM_NC
|
||||
#define RESET_FACTORY_BUTTON_GPIO GPIO_NUM_NC
|
||||
|
||||
/* DFRobot Camera pins */
|
||||
#define PWDN_GPIO_NUM -1
|
||||
#define RESET_GPIO_NUM -1
|
||||
#define XCLK_GPIO_NUM 5
|
||||
#define Y9_GPIO_NUM 4
|
||||
#define Y8_GPIO_NUM 6
|
||||
#define Y7_GPIO_NUM 7
|
||||
#define Y6_GPIO_NUM 14
|
||||
#define Y5_GPIO_NUM 17
|
||||
#define Y4_GPIO_NUM 21
|
||||
#define Y3_GPIO_NUM 18
|
||||
#define Y2_GPIO_NUM 16
|
||||
#define VSYNC_GPIO_NUM 1
|
||||
#define HREF_GPIO_NUM 2
|
||||
#define PCLK_GPIO_NUM 15
|
||||
#define SIOD_GPIO_NUM 8
|
||||
#define SIOC_GPIO_NUM 9
|
||||
|
||||
/* Camera pins */
|
||||
#define CAMERA_PIN_PWDN PWDN_GPIO_NUM
|
||||
#define CAMERA_PIN_RESET RESET_GPIO_NUM
|
||||
#define CAMERA_PIN_XCLK XCLK_GPIO_NUM
|
||||
#define CAMERA_PIN_SIOD SIOD_GPIO_NUM
|
||||
#define CAMERA_PIN_SIOC SIOC_GPIO_NUM
|
||||
|
||||
#define CAMERA_PIN_D7 Y9_GPIO_NUM
|
||||
#define CAMERA_PIN_D6 Y8_GPIO_NUM
|
||||
#define CAMERA_PIN_D5 Y7_GPIO_NUM
|
||||
#define CAMERA_PIN_D4 Y6_GPIO_NUM
|
||||
#define CAMERA_PIN_D3 Y5_GPIO_NUM
|
||||
#define CAMERA_PIN_D2 Y4_GPIO_NUM
|
||||
#define CAMERA_PIN_D1 Y3_GPIO_NUM
|
||||
#define CAMERA_PIN_D0 Y2_GPIO_NUM
|
||||
#define CAMERA_PIN_VSYNC VSYNC_GPIO_NUM
|
||||
#define CAMERA_PIN_HREF HREF_GPIO_NUM
|
||||
#define CAMERA_PIN_PCLK PCLK_GPIO_NUM
|
||||
|
||||
#define XCLK_FREQ_HZ 20000000
|
||||
|
||||
#endif // _BOARD_CONFIG_H_
|
||||
14
main/boards/df-s3-ai-cam/config.json
Normal file
14
main/boards/df-s3-ai-cam/config.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"target": "esp32s3",
|
||||
"builds": [
|
||||
{
|
||||
"name": "df-s3-ai-cam",
|
||||
"sdkconfig_append": [
|
||||
"CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=10",
|
||||
"CONFIG_ESP_PHY_MAX_TX_POWER=10",
|
||||
"CONFIG_SPIRAM_MODE_OCT=y",
|
||||
"CONFIG_IOT_PROTOCOL_MCP=y"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
102
main/boards/df-s3-ai-cam/df_s3_ai_cam.cc
Normal file
102
main/boards/df-s3-ai-cam/df_s3_ai_cam.cc
Normal file
@@ -0,0 +1,102 @@
|
||||
#include "wifi_board.h"
|
||||
#include "audio_codecs/no_audio_codec.h"
|
||||
#include "system_reset.h"
|
||||
#include "application.h"
|
||||
#include "button.h"
|
||||
#include "config.h"
|
||||
#include "iot/thing_manager.h"
|
||||
#include "esp32_camera.h"
|
||||
|
||||
#include "led/gpio_led.h"
|
||||
#include <wifi_station.h>
|
||||
#include <esp_log.h>
|
||||
#include <driver/i2c_master.h>
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#define TAG "DfrobotEsp32S3AiCam"
|
||||
|
||||
class DfrobotEsp32S3AiCam : public WifiBoard {
|
||||
private:
|
||||
Button boot_button_;
|
||||
Esp32Camera* camera_;
|
||||
|
||||
void InitializeButtons() {
|
||||
boot_button_.OnClick([this]() {
|
||||
auto& app = Application::GetInstance();
|
||||
if (app.GetDeviceState() == kDeviceStateStarting && !WifiStation::GetInstance().IsConnected()) {
|
||||
ResetWifiConfiguration();
|
||||
}
|
||||
app.ToggleChatState();
|
||||
});
|
||||
}
|
||||
|
||||
// 物联网初始化,添加对 AI 可见设备
|
||||
void InitializeIot() {
|
||||
auto& thing_manager = iot::ThingManager::GetInstance();
|
||||
thing_manager.AddThing(iot::CreateThing("Speaker"));
|
||||
}
|
||||
|
||||
void InitializeCamera() {
|
||||
camera_config_t config = {};
|
||||
config.ledc_channel = LEDC_CHANNEL_2; // LEDC通道选择 用于生成XCLK时钟 但是S3不用
|
||||
config.ledc_timer = LEDC_TIMER_2; // LEDC timer选择 用于生成XCLK时钟 但是S3不用
|
||||
config.pin_d0 = CAMERA_PIN_D0;
|
||||
config.pin_d1 = CAMERA_PIN_D1;
|
||||
config.pin_d2 = CAMERA_PIN_D2;
|
||||
config.pin_d3 = CAMERA_PIN_D3;
|
||||
config.pin_d4 = CAMERA_PIN_D4;
|
||||
config.pin_d5 = CAMERA_PIN_D5;
|
||||
config.pin_d6 = CAMERA_PIN_D6;
|
||||
config.pin_d7 = CAMERA_PIN_D7;
|
||||
config.pin_xclk = CAMERA_PIN_XCLK;
|
||||
config.pin_pclk = CAMERA_PIN_PCLK;
|
||||
config.pin_vsync = CAMERA_PIN_VSYNC;
|
||||
config.pin_href = CAMERA_PIN_HREF;
|
||||
config.pin_sccb_sda = CAMERA_PIN_SIOD; // 这里如果写-1 表示使用已经初始化的I2C接口
|
||||
config.pin_sccb_scl = CAMERA_PIN_SIOC;
|
||||
config.sccb_i2c_port = 1; // 这里如果写1 默认使用I2C1
|
||||
config.pin_pwdn = CAMERA_PIN_PWDN;
|
||||
config.pin_reset = CAMERA_PIN_RESET;
|
||||
config.xclk_freq_hz = XCLK_FREQ_HZ;
|
||||
config.pixel_format = PIXFORMAT_RGB565;
|
||||
config.frame_size = FRAMESIZE_VGA;
|
||||
config.jpeg_quality = 12;
|
||||
config.fb_count = 1;
|
||||
config.fb_location = CAMERA_FB_IN_PSRAM;
|
||||
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
|
||||
|
||||
camera_ = new Esp32Camera(config);
|
||||
camera_->SetVFlip(1);
|
||||
}
|
||||
|
||||
public:
|
||||
DfrobotEsp32S3AiCam() :
|
||||
boot_button_(BOOT_BUTTON_GPIO) {
|
||||
InitializeButtons();
|
||||
InitializeIot();
|
||||
InitializeCamera();
|
||||
|
||||
#if CONFIG_IOT_PROTOCOL_XIAOZHI
|
||||
auto& thing_manager = iot::ThingManager::GetInstance();
|
||||
thing_manager.AddThing(iot::CreateThing("Speaker"));
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual Led* GetLed() override {
|
||||
static GpioLed led(BUILTIN_LED_GPIO, 0);
|
||||
return &led;
|
||||
}
|
||||
|
||||
virtual AudioCodec* GetAudioCodec() override {
|
||||
static NoAudioCodecSimplexPdm audio_codec(AUDIO_INPUT_SAMPLE_RATE, AUDIO_OUTPUT_SAMPLE_RATE,
|
||||
AUDIO_I2S_SPK_GPIO_BCLK, AUDIO_I2S_SPK_GPIO_LRCK, AUDIO_I2S_SPK_GPIO_DOUT,
|
||||
AUDIO_I2S_MIC_GPIO_SCK, AUDIO_I2S_MIC_GPIO_DIN);
|
||||
return &audio_codec;
|
||||
}
|
||||
|
||||
virtual Camera* GetCamera() override {
|
||||
return camera_;
|
||||
}
|
||||
};
|
||||
|
||||
DECLARE_BOARD(DfrobotEsp32S3AiCam);
|
||||
Reference in New Issue
Block a user