Camera with Terminal

pull/190/head
Ye Hang Yang 2021-07-29 20:48:55 +08:00
parent fb66247088
commit 5f5eea3ba4
16 changed files with 161 additions and 629 deletions

View File

@ -0,0 +1,5 @@
################################################################################################################################
Camera with Terminal `[中文] <./README_cn.rst>`_
################################################################################################################################

View File

@ -0,0 +1,32 @@
################################################################################################################################
Camera with Terminal `[English] <./README.rst>`_
################################################################################################################################
该示例的输入图片来自摄像头,输出结果打印在终端。该示例演示了以下模型接口在实际项目中的使用情况。
+ `HumanFaceDetectMSR01 <https://github.com/espressif/esp-dl/blob/master/include/model_zoo/human_face_detect_msr01.hpp>`_
+ `HumanFaceDetectMNP01 <https://github.com/espressif/esp-dl/blob/master/include/model_zoo/human_face_detect_mnp01.hpp>`_
+ `CatFaceDetectMN03 <https://github.com/espressif/esp-dl/blob/master/include/model_zoo/cat_face_detect_mn03.hpp>`_
运行示例
************************************************************************************************
1. 参考首页的 `说明文档 <../../>`_ 配置示例。
2. 烧录程序,运行 IDF 监视器获取实时结果:
.. code:: shell
idf.py flash monitor
以选择模型 ``HumanFaceDetectMSR01`` 为例,当人脸凑近摄像头约 50cm 左右,终端打印结果如下所示:
.. figure:: ./img/result_on_terminal.png
:align: center
..
打印结果中包括时间消耗和检测的框选坐标。

View File

@ -1,96 +0,0 @@
# Camera Terminal[[English](./README.md)]
该示例的输入图片来自摄像头,输出结果打印在终端。该示例演示了以下模型接口在实际项目中的使用情况。
- [HumanFaceDetectMSR01](https://github.com/espressif/esp-dl/blob/master/include/model_zoo/human_face_detect_msr01.hpp)
- [HumanFaceDetectMNP01](https://github.com/espressif/esp-dl/blob/master/include/model_zoo/human_face_detect_mnp01.hpp)
- [CatFaceDetectMN03](https://github.com/espressif/esp-dl/blob/master/include/model_zoo/cat_face_detect_mn03.hpp)
## 硬件要求:
芯片: ESP32ESP32-S2ESP32-S3
摄像头: OV2640OV3660
对于新手,我们为您推荐开发套件:[ESP-EYE](https://www.espressif.com/zh-hans/products/devkits/esp-eye/overview)ESP-S3-EYE[ESP32-WROVER-KIT](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-wrover-kit-v3.html)
## 示例演示:
如果您完成了硬件准备并已正确安装好摄像头,那我们可以开始软件演示了。
1. 打开终端,并进入当前示例所在目录路经:
```shell
cd ~/esp-who/examples/camera_terminal
```
2. 设定目标芯片:
```shell
idf.py set-target [SoC]
```
将 [SoC] 替换为您的目标芯片,如 esp32、 esp32s2、esp32s3。
3. 打开 menuconfig设置参数
```shell
idf.py menuconfig
```
1. 选用自定义分区:
![](../../img/menuconfig_custom_partition_table.png)
2. 选择正确的摄像头管脚配置,下图以 ESP-EYE 为例:
![](../../img/menuconfig_select_camera_pinout.png)
如果您使用的是非官方支持的开发组件,请在 Custom Camera Pinout 中配置正确管脚信息。
3. 选择您想要运行的模型接口:
![](./img/menuconfig_dl_config.png)
4. 打开外部 RAM
![](../../img/menuconfig_support_external_ram.png)
注意:
- 每次设定芯片之后,都需要重新设定以上参数。
- 除了以上参数,用户也可以根据应用场景配置 CPU、Flash等的其他参数。
4. 烧录程序,运行 IDF 监视器获取实时结果:
```shell
idf.py flash monitor
```
以步骤 3 中的模型选择为例,打印结果如下所示:
![](./img/result_on_terminal.png)
打印结果中包括时间消耗和检测结果。

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

View File

@ -1,7 +1,6 @@
set(COMPONENT_SRCS
app_main.cpp
app_dl.cpp
app_camera.cpp
)
set(COMPONENT_ADD_INCLUDEDIRS
@ -11,6 +10,7 @@ set(COMPONENT_ADD_INCLUDEDIRS
set(COMPONENT_REQUIRES
esp32-camera
esp-dl
common
)
register_component()

View File

@ -1,178 +0,0 @@
menu "Camera Terminal"
menu "Camera Pins"
choice CAMERA_MODEL
bool "Select Camera Pinout"
default CAMERA_MODEL_WROVER_KIT
help
Select Camera Pinout.
config CAMERA_MODEL_WROVER_KIT
bool "WROVER-KIT With OV2640 Module"
config CAMERA_MODEL_ESP_EYE
bool "ESP_EYE DevKit"
config CAMERA_MODEL_M5STACK_PSRAM
bool "M5Stack Camera With PSRAM"
config CAMERA_MODEL_M5STACK_WIDE
bool "M5Stack Camera F (Wide)"
config CAMERA_MODEL_AI_THINKER
bool "ESP32-CAM by AI-Thinker"
config CAMERA_MODEL_CUSTOM
bool "Custom Camera Pinout"
endchoice
config CAMERA_PIN_PWDN
depends on CAMERA_MODEL_CUSTOM
int "Power Down pin"
range -1 33
default -1
help
Select Power Down pin or -1 for unmanaged.
config CAMERA_PIN_RESET
depends on CAMERA_MODEL_CUSTOM
int "Reset pin"
range -1 33
default -1
help
Select Camera Reset pin or -1 for software reset.
config CAMERA_PIN_XCLK
depends on CAMERA_MODEL_CUSTOM
int "XCLK pin"
range 0 33
default 21
help
Select Camera XCLK pin.
config CAMERA_PIN_SIOD
depends on CAMERA_MODEL_CUSTOM
int "SIOD pin"
range 0 33
default 26
help
Select Camera SIOD pin.
config CAMERA_PIN_SIOC
depends on CAMERA_MODEL_CUSTOM
int "SIOC pin"
range 0 33
default 27
help
Select Camera SIOC pin.
config CAMERA_PIN_VSYNC
depends on CAMERA_MODEL_CUSTOM
int "VSYNC pin"
range 0 39
default 25
help
Select Camera VSYNC pin.
config CAMERA_PIN_HREF
depends on CAMERA_MODEL_CUSTOM
int "HREF pin"
range 0 39
default 23
help
Select Camera HREF pin.
config CAMERA_PIN_PCLK
depends on CAMERA_MODEL_CUSTOM
int "PCLK pin"
range 0 39
default 25
help
Select Camera PCLK pin.
config CAMERA_PIN_Y2
depends on CAMERA_MODEL_CUSTOM
int "Y2 pin"
range 0 39
default 4
help
Select Camera Y2 pin.
config CAMERA_PIN_Y3
depends on CAMERA_MODEL_CUSTOM
int "Y3 pin"
range 0 39
default 5
help
Select Camera Y3 pin.
config CAMERA_PIN_Y4
depends on CAMERA_MODEL_CUSTOM
int "Y4 pin"
range 0 39
default 18
help
Select Camera Y4 pin.
config CAMERA_PIN_Y5
depends on CAMERA_MODEL_CUSTOM
int "Y5 pin"
range 0 39
default 19
help
Select Camera Y5 pin.
config CAMERA_PIN_Y6
depends on CAMERA_MODEL_CUSTOM
int "Y6 pin"
range 0 39
default 36
help
Select Camera Y6 pin.
config CAMERA_PIN_Y7
depends on CAMERA_MODEL_CUSTOM
int "Y7 pin"
range 0 39
default 39
help
Select Camera Y7 pin.
config CAMERA_PIN_Y8
depends on CAMERA_MODEL_CUSTOM
int "Y8 pin"
range 0 39
default 34
help
Select Camera Y8 pin.
config CAMERA_PIN_Y9
depends on CAMERA_MODEL_CUSTOM
int "Y9 pin"
range 0 39
default 35
help
Select Camera Y9 pin.
endmenu
menu "DL Configuration"
choice DL_DETECT_TARGET
bool "Select Detection Model"
default DL_DETECT_HUMAN_FACE
config DL_DETECT_HUMAN_FACE
bool "Human Face Detection Model"
config DL_DETECT_CAT_FACE
bool "Cat Face Detection Model"
endchoice
config DL_DETECT_HUMAN_FACE_WITH_KEYPOINT
bool "Enable Human Face Keypoint Detection"
default n
depends on DL_DETECT_HUMAN_FACE
config DL_RECOGNIZE_HUMAN_FACE
bool "Enable Human Face Recognition"
depends on DL_DETECT_HUMAN_FACE_WITH_KEYPOINT
default n
endmenu
endmenu

View File

@ -1,82 +0,0 @@
/* ESPRESSIF MIT License
*
* Copyright (c) 2018 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
*
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
* it is free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "app_camera.h"
static const char *TAG = "app_camera";
void app_camera_init()
{
#if CONFIG_CAMERA_MODEL_ESP_EYE
/* IO13, IO14 is designed for JTAG by default,
* to use it as generalized input,
* firstly declair it as pullup input */
gpio_config_t conf;
conf.mode = GPIO_MODE_INPUT;
conf.pull_up_en = GPIO_PULLUP_ENABLE;
conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
conf.intr_type = GPIO_INTR_DISABLE;
conf.pin_bit_mask = 1LL << 13;
gpio_config(&conf);
conf.pin_bit_mask = 1LL << 14;
gpio_config(&conf);
#endif
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sscb_sda = SIOD_GPIO_NUM;
config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = -1;//RESET_GPIO_NUM;
config.xclk_freq_hz = XCLK_FREQ;
config.pixel_format = CAMERA_PIXEL_FORMAT;
config.frame_size = CAMERA_FRAME_SIZE;
config.jpeg_quality = 10;
config.fb_count = 1;
// camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Camera init failed with error 0x%x", err);
return;
}
sensor_t * s = esp_camera_sensor_get();
s->set_vflip(s, 1);//flip it back
//initial sensors are flipped vertically and colors are a bit saturated
if (s->id.PID == OV3660_PID) {
s->set_brightness(s, 1);//up the blightness just a bit
s->set_saturation(s, -2);//lower the saturation
}
}

View File

@ -1,63 +1,74 @@
#include "app_dl.hpp"
#include "app_dl.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "sdkconfig.h"
#include "app_camera.h"
#include "app_camera.hpp"
#include <list>
#include "dl_tool.hpp"
#include "dl_image.hpp"
#include "dl_detect_define.hpp"
#include "app_common.hpp"
#if CONFIG_DL_DETECT_HUMAN_FACE
#if CONFIG_DL_HUMAN_FACE_DETECTION_S1_MSR01
#include "human_face_detect_msr01.hpp"
#endif
#if CONFIG_DL_DETECT_HUMAN_FACE_WITH_KEYPOINT
#if CONFIG_DL_HUMAN_FACE_DETECTION_S2_MNP01
#include "human_face_detect_mnp01.hpp"
#endif
#if CONFIG_DL_DETECT_CAT_FACE
#if CONFIG_DL_CAT_FACE_DETECTION_MN03
#include "cat_face_detect_mn03.hpp"
#endif
#if CONFIG_DL_RECOGNIZE_HUMAN_FACE
#if CONFIG_DL_HUMAN_FACE_RECOGNITION_XXX
// TODO: recognize human face
#endif
static const char *TAG = "app_dl";
void task_dl(void *arg)
{
camera_fb_t *fb = NULL;
uint8_t *image_rgb888;
IMAGE_T *image_ptr;
dl::tool::Latency latency_total(24);
dl::tool::Latency latency_fetch;
dl::tool::Latency latency_decode;
dl::tool::Latency latency_detect;
dl::tool::Latency latency_recognize;
/* 1. Load configuration for detection */
#if CONFIG_DL_DETECT_HUMAN_FACE
#if CONFIG_DL_HUMAN_FACE
#if CONFIG_DL_HUMAN_FACE_DETECTION_S1_MSR01
HumanFaceDetectMSR01 detector(0.3F, 0.3F, 10, 0.3F);
#endif
#if CONFIG_DL_DETECT_HUMAN_FACE_WITH_KEYPOINT
#if CONFIG_DL_HUMAN_FACE_DETECTION_S2_MNP01
HumanFaceDetectMNP01 detector2(0.4F, 0.3F, 10);
#endif
#if CONFIG_DL_DETECT_CAT_FACE
CatFaceDetectMN03 detector(0.4F, 0.3F, 10, 0.3F);
#if CONFIG_DL_HUMAN_FACE_RECOGNITION_XXX
// TODO: recognize human face
#endif
#endif
#if CONFIG_DL_RECOGNIZE_HUMAN_FACE
dl::tool::Latency latency_recognize;
// TODO: recognize human face
#if CONFIG_DL_CAT_FACE
#if CONFIG_DL_CAT_FACE_DETECTION_MN03
CatFaceDetectMN03 detector(0.4F, 0.3F, 10, 0.3F);
#endif
#endif
while (true)
{
latency_fetch.clear_period();
latency_decode.clear_period();
latency_detect.clear_period();
latency_recognize.clear_period();
latency_total.start();
/* 2. Get one image with camera */
@ -70,81 +81,80 @@ void task_dl(void *arg)
}
latency_fetch.end();
#if CONFIG_DL_ENABLED
/* 3. Transform image to RGB */
latency_decode.start();
image_rgb888 = (uint8_t *)dl::tool::malloc_aligned(fb->height * fb->width * 3, sizeof(uint8_t));
bool res = fmt2rgb888(fb->buf, fb->len, fb->format, image_rgb888);
if (false == res)
{
ESP_LOGE(TAG, "fmt2rgb888 failed, fb: %d", fb->len);
dl::tool::free_aligned(image_rgb888);
continue;
}
int image_height = fb->height;
int image_width = fb->width;
if (app_camera_decode(fb, &image_ptr) == false)
{
esp_camera_fb_return(fb);
continue;
}
#if !CONFIG_CAMERA_PIXEL_FORMAT_RGB565
esp_camera_fb_return(fb);
#endif
latency_decode.end();
/* 4. Do deep-learning processing */
#if CONFIG_DL_HUMAN_FACE
latency_detect.start();
#if CONFIG_DL_DETECT_HUMAN_FACE_WITH_KEYPOINT
std::list<dl::detect::result_t> &candidates = detector.infer((uint8_t *)image_rgb888, {image_height, image_width, 3});
std::list<dl::detect::result_t> &results = detector2.infer((uint8_t *)image_rgb888, {image_height, image_width, 3}, candidates);
#if CONFIG_DL_HUMAN_FACE_DETECTION_S2_ENABLED
std::list<dl::detect::result_t> &detect_candidates = detector.infer((IMAGE_T *)image_ptr, {(int)image_height, (int)image_width, 3});
std::list<dl::detect::result_t> &detect_results = detector2.infer((IMAGE_T *)image_ptr, {(int)image_height, (int)image_width, 3}, detect_candidates);
#else
std::list<dl::detect::result_t> &results = detector.infer((uint8_t *)image_rgb888, {image_height, image_width, 3});
std::list<dl::detect::result_t> &detect_results = detector.infer((IMAGE_T *)image_ptr, {(int)image_height, (int)image_width, 3});
#endif
latency_detect.end();
#if CONFIG_DL_RECOGNIZE_HUMAN_FACE
latency_recognize.start();
#endif
if (results.size() > 0)
if (detect_results.size() > 0)
{
int i = 0;
for (std::list<dl::detect::result_t>::iterator prediction = results.begin(); prediction != results.end(); prediction++, i++)
{
#if CONFIG_DL_DETECT_HUMAN_FACE_WITH_KEYPOINT
ESP_LOGI(TAG, "[%d]: (%3d, %3d, %3d, %3d) | left eye: (%3d, %3d), right eye: (%3d, %3d), nose: (%3d, %3d), mouth left: (%3d, %3d), mouth right: (%3d, %3d)",
i,
prediction->box[0], prediction->box[1], prediction->box[2], prediction->box[3],
prediction->keypoint[0], prediction->keypoint[1], // left eye
prediction->keypoint[6], prediction->keypoint[7], // right eye
prediction->keypoint[4], prediction->keypoint[5], // nose
prediction->keypoint[2], prediction->keypoint[3], // mouth left corner
prediction->keypoint[8], prediction->keypoint[9]); // mouth right corner
#else
ESP_LOGI(TAG, "[%d]: (%3d, %3d, %3d, %3d)",
i,
prediction->box[0], prediction->box[1], prediction->box[2], prediction->box[3]);
#endif
}
print_detection_result(detect_results);
#if CONFIG_DL_RECOGNIZE_HUMAN_FACE
#if CONFIG_DL_HUMAN_FACE_RECOGNITION_ENABLED
latency_recognize.start();
// TODO: recognize human face
latency_recognize.end();
#endif
}
#if CONFIG_DL_RECOGNIZE_HUMAN_FACE
latency_recognize.end();
#endif
dl::tool::free_aligned(image_rgb888);
latency_total.end();
#endif // CONFIG_DL_HUMAN_FACE
#if CONFIG_DL_CAT_FACE
latency_detect.start();
std::list<dl::detect::result_t> &detect_results = detector.infer((IMAGE_T *)image_ptr, {(int)image_height, (int)image_width, 3});
latency_detect.end();
if (detect_results.size() > 0)
{
is_detected = true;
print_detection_result(image_ptr, fb->height, fb->width, detect_results);
}
#endif // CONFIG_DL_CAT_FACE
#if CONFIG_DL_HUMAN_HAND
latency_detect.start();
// TODO:
latency_detect.end();
#endif // CONFIG_DL_HUMAN_HAND
#if CONFIG_CAMERA_PIXEL_FORMAT_RGB565
esp_camera_fb_return(fb);
#else
dl::tool::free_aligned(image_ptr);
#endif
#else // not CONFIG_DL_ENABLED
esp_camera_fb_return(fb);
#endif // CONFIG_DL_ENABLED
latency_total.end();
uint32_t frame_latency = latency_total.get_period() / 1000;
uint32_t average_frame_latency = latency_total.get_average_period() / 1000;
ESP_LOGI(TAG, "Frame: %4ums (%.1ffps), Average: %4ums (%.1ffps) | fetch: %4ums, decode: %4ums, detect: %4ums"
#if CONFIG_DL_RECOGNIZE_HUMAN_FACE
", recognize: %5ums"
#endif
,
ESP_LOGI(TAG, "Frame: %4ums (%2.1ffps), Average: %4ums (%2.1ffps) | fetch: %4ums, decode: %4ums, detect: %4ums, recognize: %5ums",
frame_latency, 1000.0 / frame_latency, average_frame_latency, 1000.0 / average_frame_latency,
latency_fetch.get_period() / 1000,
latency_decode.get_period() / 1000,
latency_detect.get_period() / 1000
#if CONFIG_DL_RECOGNIZE_HUMAN_FACE
,
latency_recognize.get_period() / 1000
#endif
);
latency_detect.get_period() / 1000,
latency_recognize.get_period() / 1000);
}
}

View File

@ -1,30 +1,8 @@
/* ESPRESSIF MIT License
*
* Copyright (c) 2018 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
*
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
* it is free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "app_camera.h"
#include "app_dl.hpp"
#include "app_camera.hpp"
#include "app_dl.h"
extern "C" void app_main()
{
app_camera_init();
app_camera_init(FRAMESIZE_QVGA, 12, 2);
app_dl_init();
}

View File

@ -1,175 +0,0 @@
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2017 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
*
* Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case,
* it is free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef _APP_CAMERA_H_
#define _APP_CAMERA_H_
#include "esp_log.h"
#include "esp_system.h"
#include "esp_camera.h"
/**
* PIXFORMAT_RGB565, // 2BPP/RGB565
* PIXFORMAT_YUV422, // 2BPP/YUV422
* PIXFORMAT_GRAYSCALE, // 1BPP/GRAYSCALE
* PIXFORMAT_JPEG, // JPEG/COMPRESSED
* PIXFORMAT_RGB888, // 3BPP/RGB888
*/
#define CAMERA_PIXEL_FORMAT PIXFORMAT_JPEG
/*
* FRAMESIZE_QQVGA, // 160x120
* FRAMESIZE_QQVGA2, // 128x160
* FRAMESIZE_QCIF, // 176x144
* FRAMESIZE_HQVGA, // 240x176
* FRAMESIZE_QVGA, // 320x240
* FRAMESIZE_CIF, // 400x296
* FRAMESIZE_VGA, // 640x480
* FRAMESIZE_SVGA, // 800x600
* FRAMESIZE_XGA, // 1024x768
* FRAMESIZE_SXGA, // 1280x1024
* FRAMESIZE_UXGA, // 1600x1200
*/
#define CAMERA_FRAME_SIZE FRAMESIZE_QVGA
#if CONFIG_CAMERA_MODEL_WROVER_KIT
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 21
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 19
#define Y4_GPIO_NUM 18
#define Y3_GPIO_NUM 5
#define Y2_GPIO_NUM 4
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
#elif CONFIG_CAMERA_MODEL_ESP_EYE
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 4
#define SIOD_GPIO_NUM 18
#define SIOC_GPIO_NUM 23
#define Y9_GPIO_NUM 36
#define Y8_GPIO_NUM 37
#define Y7_GPIO_NUM 38
#define Y6_GPIO_NUM 39
#define Y5_GPIO_NUM 35
#define Y4_GPIO_NUM 14
#define Y3_GPIO_NUM 13
#define Y2_GPIO_NUM 34
#define VSYNC_GPIO_NUM 5
#define HREF_GPIO_NUM 27
#define PCLK_GPIO_NUM 25
#elif CONFIG_CAMERA_MODEL_M5STACK_PSRAM
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM 15
#define XCLK_GPIO_NUM 27
#define SIOD_GPIO_NUM 25
#define SIOC_GPIO_NUM 23
#define Y9_GPIO_NUM 19
#define Y8_GPIO_NUM 36
#define Y7_GPIO_NUM 18
#define Y6_GPIO_NUM 39
#define Y5_GPIO_NUM 5
#define Y4_GPIO_NUM 34
#define Y3_GPIO_NUM 35
#define Y2_GPIO_NUM 32
#define VSYNC_GPIO_NUM 22
#define HREF_GPIO_NUM 26
#define PCLK_GPIO_NUM 21
#elif CONFIG_CAMERA_MODEL_M5STACK_WIDE
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM 15
#define XCLK_GPIO_NUM 27
#define SIOD_GPIO_NUM 22
#define SIOC_GPIO_NUM 23
#define Y9_GPIO_NUM 19
#define Y8_GPIO_NUM 36
#define Y7_GPIO_NUM 18
#define Y6_GPIO_NUM 39
#define Y5_GPIO_NUM 5
#define Y4_GPIO_NUM 34
#define Y3_GPIO_NUM 35
#define Y2_GPIO_NUM 32
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 26
#define PCLK_GPIO_NUM 21
#elif CONFIG_CAMERA_MODEL_AI_THINKER
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
#elif CONFIG_CAMERA_MODEL_CUSTOM
#define PWDN_GPIO_NUM CONFIG_CAMERA_PIN_PWDN
#define RESET_GPIO_NUM CONFIG_CAMERA_PIN_RESET
#define XCLK_GPIO_NUM CONFIG_CAMERA_PIN_XCLK
#define SIOD_GPIO_NUM CONFIG_CAMERA_PIN_SIOD
#define SIOC_GPIO_NUM CONFIG_CAMERA_PIN_SIOC
#define Y9_GPIO_NUM CONFIG_CAMERA_PIN_Y9
#define Y8_GPIO_NUM CONFIG_CAMERA_PIN_Y8
#define Y7_GPIO_NUM CONFIG_CAMERA_PIN_Y7
#define Y6_GPIO_NUM CONFIG_CAMERA_PIN_Y6
#define Y5_GPIO_NUM CONFIG_CAMERA_PIN_Y5
#define Y4_GPIO_NUM CONFIG_CAMERA_PIN_Y4
#define Y3_GPIO_NUM CONFIG_CAMERA_PIN_Y3
#define Y2_GPIO_NUM CONFIG_CAMERA_PIN_Y2
#define VSYNC_GPIO_NUM CONFIG_CAMERA_PIN_VSYNC
#define HREF_GPIO_NUM CONFIG_CAMERA_PIN_HREF
#define PCLK_GPIO_NUM CONFIG_CAMERA_PIN_PCLK
#endif
#define XCLK_FREQ 20000000
void app_camera_init();
#endif

View File

@ -0,0 +1,16 @@
#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @brief Initialize deep-learning application task.
*
*/
void app_dl_init();
#ifdef __cplusplus
}
#endif

View File

@ -1,7 +0,0 @@
#pragma once
/**
* @brief Initialize deep-learning application task.
*
*/
void app_dl_init();

View File

@ -0,0 +1,17 @@
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_ESP_TASK_WDT=n
# Wait for esp-idf stable
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF=y
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
CONFIG_SPIRAM_MEMTEST=n

View File

@ -0,0 +1,4 @@
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP32_SPIRAM_SUPPORT=y
CONFIG_CAMERA_MODULE_ESP_EYE=y

View File

@ -0,0 +1,2 @@
CONFIG_ESP32S2_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP32S2_SPIRAM_SUPPORT=y

View File

@ -0,0 +1,6 @@
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
CONFIG_CAMERA_MODULE_ESP_S3_EYE=y
CONFIG_ESPTOOLPY_NO_STUB=y
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y