✨ camera_terminal
parent
d502c86b71
commit
fdd940ffb9
|
@ -0,0 +1,7 @@
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
set(EXTRA_COMPONENT_DIRS ../../components)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
|
||||||
|
project(camera_terminal)
|
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
Binary file not shown.
After Width: | Height: | Size: 129 KiB |
|
@ -0,0 +1,16 @@
|
||||||
|
set(COMPONENT_SRCS
|
||||||
|
app_main.cpp
|
||||||
|
app_dl.cpp
|
||||||
|
app_camera.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(COMPONENT_ADD_INCLUDEDIRS
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
set(COMPONENT_REQUIRES
|
||||||
|
esp32-camera
|
||||||
|
esp-dl
|
||||||
|
)
|
||||||
|
|
||||||
|
register_component()
|
|
@ -0,0 +1,178 @@
|
||||||
|
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
|
|
@ -0,0 +1,82 @@
|
||||||
|
/* 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
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,154 @@
|
||||||
|
#include "app_dl.hpp"
|
||||||
|
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
#include "app_camera.h"
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include "dl_tool.hpp"
|
||||||
|
#include "dl_image.hpp"
|
||||||
|
#include "dl_detect_define.hpp"
|
||||||
|
|
||||||
|
#if CONFIG_DL_DETECT_HUMAN_FACE
|
||||||
|
#include "human_face_detect_msr01.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_DL_DETECT_HUMAN_FACE_WITH_KEYPOINT
|
||||||
|
#include "human_face_detect_mnp01.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_DL_DETECT_CAT_FACE
|
||||||
|
#include "cat_face_detect_mn03.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_DL_RECOGNIZE_HUMAN_FACE
|
||||||
|
// 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;
|
||||||
|
dl::tool::Latency latency_total(24);
|
||||||
|
dl::tool::Latency latency_fetch;
|
||||||
|
dl::tool::Latency latency_decode;
|
||||||
|
dl::tool::Latency latency_detect;
|
||||||
|
|
||||||
|
/* 1. Load configuration for detection */
|
||||||
|
#if CONFIG_DL_DETECT_HUMAN_FACE
|
||||||
|
HumanFaceDetectMSR01 detector(0.3F, 0.3F, 10, 0.3F);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_DL_DETECT_HUMAN_FACE_WITH_KEYPOINT
|
||||||
|
HumanFaceDetectMNP01 detector2(0.4F, 0.3F, 10);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_DL_DETECT_CAT_FACE
|
||||||
|
CatFaceDetectMN03 detector(0.4F, 0.3F, 10, 0.3F);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_DL_RECOGNIZE_HUMAN_FACE
|
||||||
|
dl::tool::Latency latency_recognize;
|
||||||
|
// TODO: recognize human face
|
||||||
|
#endif
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
latency_total.start();
|
||||||
|
|
||||||
|
/* 2. Get one image with camera */
|
||||||
|
latency_fetch.start();
|
||||||
|
fb = esp_camera_fb_get();
|
||||||
|
if (!fb)
|
||||||
|
{
|
||||||
|
ESP_LOGE(TAG, "Camera capture failed");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
latency_fetch.end();
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
esp_camera_fb_return(fb);
|
||||||
|
latency_decode.end();
|
||||||
|
|
||||||
|
/* 4. Do deep-learning processing */
|
||||||
|
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);
|
||||||
|
#else
|
||||||
|
std::list<dl::detect::result_t> &results = detector.infer((uint8_t *)image_rgb888, {image_height, image_width, 3});
|
||||||
|
#endif
|
||||||
|
latency_detect.end();
|
||||||
|
|
||||||
|
#if CONFIG_DL_RECOGNIZE_HUMAN_FACE
|
||||||
|
latency_recognize.start();
|
||||||
|
#endif
|
||||||
|
if (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
|
||||||
|
}
|
||||||
|
|
||||||
|
#if CONFIG_DL_RECOGNIZE_HUMAN_FACE
|
||||||
|
latency_recognize.start();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if CONFIG_DL_RECOGNIZE_HUMAN_FACE
|
||||||
|
latency_recognize.end();
|
||||||
|
#endif
|
||||||
|
dl::tool::free_aligned(image_rgb888);
|
||||||
|
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
|
||||||
|
,
|
||||||
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_dl_init()
|
||||||
|
{
|
||||||
|
xTaskCreatePinnedToCore(task_dl, "dl", 4 * 1024, NULL, 5, NULL, 1);
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
/* 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"
|
||||||
|
|
||||||
|
extern "C" void app_main()
|
||||||
|
{
|
||||||
|
app_camera_init();
|
||||||
|
app_dl_init();
|
||||||
|
}
|
|
@ -0,0 +1,175 @@
|
||||||
|
/*
|
||||||
|
* 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
|
|
@ -0,0 +1,7 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize deep-learning application task.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void app_dl_init();
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Espressif ESP32 Partition Table
|
||||||
|
# Name, Type, SubType, Offset, Size
|
||||||
|
factory, app, factory, 0x010000, 2M
|
||||||
|
nvs, data, nvs, 0x310000, 16K
|
|
Loading…
Reference in New Issue