💡 README_zh_CN for camera_terminal

pull/190/head
Ye Hang Yang 2021-07-16 16:21:44 +08:00
parent fdd940ffb9
commit 35ef71e585
7 changed files with 405 additions and 288 deletions

@ -1 +1 @@
Subproject commit 420fc7e219ba98e40a5493b9d4be270db2f2d724
Subproject commit 11b38828ea2b46b4ca0a30ec6711900ab9604cd1

View File

@ -143,108 +143,108 @@ const uint8_t FreeMonoBold12pt7bBitmaps[] = {
0x39, 0xE3, 0xC0, 0xC1, 0x83, 0x06, 0x0C, 0x18, 0x3C, 0x38, 0xFF, 0xFF,
0xFF, 0xFF, 0xF0, 0xE1, 0xC0, 0xC1, 0x83, 0x06, 0x0C, 0x18, 0x30, 0x3C,
0x79, 0x83, 0x06, 0x0C, 0x18, 0x31, 0xE3, 0x80, 0x3C, 0x37, 0xE7, 0x67,
0xE6, 0x1C };
0xE6, 0x1C};
const GFXglyph FreeMonoBold12pt7bGlyphs[] = {
{ 0, 0, 0, 14, 0, 1 }, // 0x20 ' '
{ 0, 4, 15, 14, 5, -14 }, // 0x21 '!'
{ 8, 8, 7, 14, 3, -13 }, // 0x22 '"'
{ 15, 11, 18, 14, 2, -15 }, // 0x23 '#'
{ 40, 10, 20, 14, 2, -16 }, // 0x24 '$'
{ 65, 10, 15, 14, 2, -14 }, // 0x25 '%'
{ 84, 10, 13, 14, 2, -12 }, // 0x26 '&'
{ 101, 3, 7, 14, 5, -13 }, // 0x27 '''
{ 104, 5, 19, 14, 6, -14 }, // 0x28 '('
{ 116, 5, 19, 14, 3, -14 }, // 0x29 ')'
{ 128, 10, 10, 14, 2, -14 }, // 0x2A '*'
{ 141, 12, 13, 14, 1, -12 }, // 0x2B '+'
{ 161, 5, 7, 14, 4, -2 }, // 0x2C ','
{ 166, 12, 2, 14, 1, -7 }, // 0x2D '-'
{ 169, 3, 3, 14, 5, -2 }, // 0x2E '.'
{ 171, 10, 20, 14, 2, -16 }, // 0x2F '/'
{ 196, 10, 15, 14, 2, -14 }, // 0x30 '0'
{ 215, 10, 15, 14, 2, -14 }, // 0x31 '1'
{ 234, 10, 15, 14, 2, -14 }, // 0x32 '2'
{ 253, 11, 15, 14, 1, -14 }, // 0x33 '3'
{ 274, 9, 14, 14, 2, -13 }, // 0x34 '4'
{ 290, 10, 15, 14, 2, -14 }, // 0x35 '5'
{ 309, 10, 15, 14, 2, -14 }, // 0x36 '6'
{ 328, 10, 15, 14, 2, -14 }, // 0x37 '7'
{ 347, 10, 15, 14, 2, -14 }, // 0x38 '8'
{ 366, 10, 15, 14, 3, -14 }, // 0x39 '9'
{ 385, 3, 11, 14, 5, -10 }, // 0x3A ':'
{ 390, 4, 15, 14, 4, -10 }, // 0x3B ';'
{ 398, 12, 11, 14, 1, -11 }, // 0x3C '<'
{ 415, 12, 7, 14, 1, -9 }, // 0x3D '='
{ 426, 12, 11, 14, 1, -11 }, // 0x3E '>'
{ 443, 9, 14, 14, 3, -13 }, // 0x3F '?'
{ 459, 11, 19, 14, 2, -14 }, // 0x40 '@'
{ 486, 15, 14, 14, -1, -13 }, // 0x41 'A'
{ 513, 13, 14, 14, 0, -13 }, // 0x42 'B'
{ 536, 12, 14, 14, 1, -13 }, // 0x43 'C'
{ 557, 12, 14, 14, 1, -13 }, // 0x44 'D'
{ 578, 13, 14, 14, 0, -13 }, // 0x45 'E'
{ 601, 13, 14, 14, 0, -13 }, // 0x46 'F'
{ 624, 13, 14, 14, 1, -13 }, // 0x47 'G'
{ 647, 14, 14, 14, 0, -13 }, // 0x48 'H'
{ 672, 10, 14, 14, 2, -13 }, // 0x49 'I'
{ 690, 13, 14, 14, 1, -13 }, // 0x4A 'J'
{ 713, 14, 14, 14, 0, -13 }, // 0x4B 'K'
{ 738, 12, 14, 14, 1, -13 }, // 0x4C 'L'
{ 759, 14, 14, 14, 0, -13 }, // 0x4D 'M'
{ 784, 13, 14, 14, 0, -13 }, // 0x4E 'N'
{ 807, 12, 14, 14, 1, -13 }, // 0x4F 'O'
{ 828, 12, 14, 14, 0, -13 }, // 0x50 'P'
{ 849, 12, 17, 14, 1, -13 }, // 0x51 'Q'
{ 875, 14, 14, 14, 0, -13 }, // 0x52 'R'
{ 900, 10, 14, 14, 2, -13 }, // 0x53 'S'
{ 918, 12, 14, 14, 1, -13 }, // 0x54 'T'
{ 939, 12, 14, 14, 1, -13 }, // 0x55 'U'
{ 960, 16, 14, 14, -1, -13 }, // 0x56 'V'
{ 988, 14, 14, 14, 0, -13 }, // 0x57 'W'
{ 1013, 14, 14, 14, 0, -13 }, // 0x58 'X'
{ 1038, 12, 14, 14, 1, -13 }, // 0x59 'Y'
{ 1059, 10, 14, 14, 2, -13 }, // 0x5A 'Z'
{ 1077, 5, 19, 14, 6, -14 }, // 0x5B '['
{ 1089, 10, 20, 14, 2, -16 }, // 0x5C '\'
{ 1114, 5, 19, 14, 3, -14 }, // 0x5D ']'
{ 1126, 10, 8, 14, 2, -15 }, // 0x5E '^'
{ 1136, 14, 2, 14, 0, 4 }, // 0x5F '_'
{ 1140, 4, 4, 14, 4, -15 }, // 0x60 '`'
{ 1142, 12, 11, 14, 1, -10 }, // 0x61 'a'
{ 1159, 13, 15, 14, 0, -14 }, // 0x62 'b'
{ 1184, 12, 11, 14, 1, -10 }, // 0x63 'c'
{ 1201, 13, 15, 14, 1, -14 }, // 0x64 'd'
{ 1226, 12, 11, 14, 1, -10 }, // 0x65 'e'
{ 1243, 11, 15, 14, 2, -14 }, // 0x66 'f'
{ 1264, 13, 16, 14, 1, -10 }, // 0x67 'g'
{ 1290, 14, 15, 14, 0, -14 }, // 0x68 'h'
{ 1317, 11, 14, 14, 1, -13 }, // 0x69 'i'
{ 1337, 8, 19, 15, 3, -13 }, // 0x6A 'j'
{ 1356, 13, 15, 14, 1, -14 }, // 0x6B 'k'
{ 1381, 11, 15, 14, 1, -14 }, // 0x6C 'l'
{ 1402, 15, 11, 14, 0, -10 }, // 0x6D 'm'
{ 1423, 14, 11, 14, 0, -10 }, // 0x6E 'n'
{ 1443, 12, 11, 14, 1, -10 }, // 0x6F 'o'
{ 1460, 14, 16, 14, 0, -10 }, // 0x70 'p'
{ 1488, 14, 16, 14, 0, -10 }, // 0x71 'q'
{ 1516, 12, 11, 14, 1, -10 }, // 0x72 'r'
{ 1533, 10, 11, 14, 2, -10 }, // 0x73 's'
{ 1547, 11, 14, 14, 1, -13 }, // 0x74 't'
{ 1567, 13, 11, 14, 0, -10 }, // 0x75 'u'
{ 1585, 14, 11, 14, 0, -10 }, // 0x76 'v'
{ 1605, 14, 11, 14, 0, -10 }, // 0x77 'w'
{ 1625, 14, 11, 14, 0, -10 }, // 0x78 'x'
{ 1645, 12, 16, 14, 1, -10 }, // 0x79 'y'
{ 1669, 11, 11, 14, 1, -10 }, // 0x7A 'z'
{ 1685, 7, 19, 14, 3, -14 }, // 0x7B '{'
{ 1702, 2, 19, 14, 6, -14 }, // 0x7C '|'
{ 1707, 7, 19, 14, 4, -14 }, // 0x7D '}'
{ 1724, 12, 4, 14, 1, -7 } }; // 0x7E '~'
{0, 0, 0, 14, 0, 1}, // 0x20 ' '
{0, 4, 15, 14, 5, -14}, // 0x21 '!'
{8, 8, 7, 14, 3, -13}, // 0x22 '"'
{15, 11, 18, 14, 2, -15}, // 0x23 '#'
{40, 10, 20, 14, 2, -16}, // 0x24 '$'
{65, 10, 15, 14, 2, -14}, // 0x25 '%'
{84, 10, 13, 14, 2, -12}, // 0x26 '&'
{101, 3, 7, 14, 5, -13}, // 0x27 '''
{104, 5, 19, 14, 6, -14}, // 0x28 '('
{116, 5, 19, 14, 3, -14}, // 0x29 ')'
{128, 10, 10, 14, 2, -14}, // 0x2A '*'
{141, 12, 13, 14, 1, -12}, // 0x2B '+'
{161, 5, 7, 14, 4, -2}, // 0x2C ','
{166, 12, 2, 14, 1, -7}, // 0x2D '-'
{169, 3, 3, 14, 5, -2}, // 0x2E '.'
{171, 10, 20, 14, 2, -16}, // 0x2F '/'
{196, 10, 15, 14, 2, -14}, // 0x30 '0'
{215, 10, 15, 14, 2, -14}, // 0x31 '1'
{234, 10, 15, 14, 2, -14}, // 0x32 '2'
{253, 11, 15, 14, 1, -14}, // 0x33 '3'
{274, 9, 14, 14, 2, -13}, // 0x34 '4'
{290, 10, 15, 14, 2, -14}, // 0x35 '5'
{309, 10, 15, 14, 2, -14}, // 0x36 '6'
{328, 10, 15, 14, 2, -14}, // 0x37 '7'
{347, 10, 15, 14, 2, -14}, // 0x38 '8'
{366, 10, 15, 14, 3, -14}, // 0x39 '9'
{385, 3, 11, 14, 5, -10}, // 0x3A ':'
{390, 4, 15, 14, 4, -10}, // 0x3B ';'
{398, 12, 11, 14, 1, -11}, // 0x3C '<'
{415, 12, 7, 14, 1, -9}, // 0x3D '='
{426, 12, 11, 14, 1, -11}, // 0x3E '>'
{443, 9, 14, 14, 3, -13}, // 0x3F '?'
{459, 11, 19, 14, 2, -14}, // 0x40 '@'
{486, 15, 14, 14, -1, -13}, // 0x41 'A'
{513, 13, 14, 14, 0, -13}, // 0x42 'B'
{536, 12, 14, 14, 1, -13}, // 0x43 'C'
{557, 12, 14, 14, 1, -13}, // 0x44 'D'
{578, 13, 14, 14, 0, -13}, // 0x45 'E'
{601, 13, 14, 14, 0, -13}, // 0x46 'F'
{624, 13, 14, 14, 1, -13}, // 0x47 'G'
{647, 14, 14, 14, 0, -13}, // 0x48 'H'
{672, 10, 14, 14, 2, -13}, // 0x49 'I'
{690, 13, 14, 14, 1, -13}, // 0x4A 'J'
{713, 14, 14, 14, 0, -13}, // 0x4B 'K'
{738, 12, 14, 14, 1, -13}, // 0x4C 'L'
{759, 14, 14, 14, 0, -13}, // 0x4D 'M'
{784, 13, 14, 14, 0, -13}, // 0x4E 'N'
{807, 12, 14, 14, 1, -13}, // 0x4F 'O'
{828, 12, 14, 14, 0, -13}, // 0x50 'P'
{849, 12, 17, 14, 1, -13}, // 0x51 'Q'
{875, 14, 14, 14, 0, -13}, // 0x52 'R'
{900, 10, 14, 14, 2, -13}, // 0x53 'S'
{918, 12, 14, 14, 1, -13}, // 0x54 'T'
{939, 12, 14, 14, 1, -13}, // 0x55 'U'
{960, 16, 14, 14, -1, -13}, // 0x56 'V'
{988, 14, 14, 14, 0, -13}, // 0x57 'W'
{1013, 14, 14, 14, 0, -13}, // 0x58 'X'
{1038, 12, 14, 14, 1, -13}, // 0x59 'Y'
{1059, 10, 14, 14, 2, -13}, // 0x5A 'Z'
{1077, 5, 19, 14, 6, -14}, // 0x5B '['
{1089, 10, 20, 14, 2, -16}, // 0x5C '\'
{1114, 5, 19, 14, 3, -14}, // 0x5D ']'
{1126, 10, 8, 14, 2, -15}, // 0x5E '^'
{1136, 14, 2, 14, 0, 4}, // 0x5F '_'
{1140, 4, 4, 14, 4, -15}, // 0x60 '`'
{1142, 12, 11, 14, 1, -10}, // 0x61 'a'
{1159, 13, 15, 14, 0, -14}, // 0x62 'b'
{1184, 12, 11, 14, 1, -10}, // 0x63 'c'
{1201, 13, 15, 14, 1, -14}, // 0x64 'd'
{1226, 12, 11, 14, 1, -10}, // 0x65 'e'
{1243, 11, 15, 14, 2, -14}, // 0x66 'f'
{1264, 13, 16, 14, 1, -10}, // 0x67 'g'
{1290, 14, 15, 14, 0, -14}, // 0x68 'h'
{1317, 11, 14, 14, 1, -13}, // 0x69 'i'
{1337, 8, 19, 15, 3, -13}, // 0x6A 'j'
{1356, 13, 15, 14, 1, -14}, // 0x6B 'k'
{1381, 11, 15, 14, 1, -14}, // 0x6C 'l'
{1402, 15, 11, 14, 0, -10}, // 0x6D 'm'
{1423, 14, 11, 14, 0, -10}, // 0x6E 'n'
{1443, 12, 11, 14, 1, -10}, // 0x6F 'o'
{1460, 14, 16, 14, 0, -10}, // 0x70 'p'
{1488, 14, 16, 14, 0, -10}, // 0x71 'q'
{1516, 12, 11, 14, 1, -10}, // 0x72 'r'
{1533, 10, 11, 14, 2, -10}, // 0x73 's'
{1547, 11, 14, 14, 1, -13}, // 0x74 't'
{1567, 13, 11, 14, 0, -10}, // 0x75 'u'
{1585, 14, 11, 14, 0, -10}, // 0x76 'v'
{1605, 14, 11, 14, 0, -10}, // 0x77 'w'
{1625, 14, 11, 14, 0, -10}, // 0x78 'x'
{1645, 12, 16, 14, 1, -10}, // 0x79 'y'
{1669, 11, 11, 14, 1, -10}, // 0x7A 'z'
{1685, 7, 19, 14, 3, -14}, // 0x7B '{'
{1702, 2, 19, 14, 6, -14}, // 0x7C '|'
{1707, 7, 19, 14, 4, -14}, // 0x7D '}'
{1724, 12, 4, 14, 1, -7}}; // 0x7E '~'
const GFXfont FreeMonoBold12pt7b = {
(uint8_t *)FreeMonoBold12pt7bBitmaps,
(GFXglyph *)FreeMonoBold12pt7bGlyphs,
0x20, 0x7E, 24, 17 };
0x20, 0x7E, 24, 17};
// Approx. 2402 bytes

View File

@ -18,14 +18,16 @@
#include "stdlib.h"
#include "fb_gfx.h"
typedef struct { // Data stored PER GLYPH
typedef struct
{ // Data stored PER GLYPH
uint16_t bitmapOffset; // Pointer into GFXfont->bitmap
uint8_t width, height; // Bitmap dimensions in pixels
uint8_t xAdvance; // Distance to advance cursor (x axis)
int8_t xOffset, yOffset; // Dist from cursor pos to UL corner
} GFXglyph;
typedef struct { // Data stored for FONT AS A WHOLE:
typedef struct
{ // Data stored for FONT AS A WHOLE:
uint8_t *bitmap; // Glyph bitmaps, concatenated
GFXglyph *glyph; // Glyph array
uint8_t first, last; // ASCII extents
@ -33,8 +35,8 @@ typedef struct { // Data stored for FONT AS A WHOLE:
uint8_t yOffset; // Y offset of the font zero line (y axis)
} GFXfont;
#include "FreeMonoBold12pt7b.h"//14x24
#define gfxFont ((GFXfont*)(&FreeMonoBold12pt7b))
#include "FreeMonoBold12pt7b.h" //14x24
#define gfxFont ((GFXfont *)(&FreeMonoBold12pt7b))
void fb_gfx_fillRect(fb_data_t *fb, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
{
@ -43,12 +45,14 @@ void fb_gfx_fillRect(fb_data_t *fb, int32_t x, int32_t y, int32_t w, int32_t h,
uint8_t c0 = color >> 16;
uint8_t c1 = color >> 8;
uint8_t c2 = color;
for (int i=0; i<h; i++){
for (int j=0; j<w; j++){
for (int i = 0; i < h; i++)
{
for (int j = 0; j < w; j++)
{
data[0] = c0;
data[1] = c1;
data[2] = c2;
data+=3;
data += 3;
}
data += line_step;
}
@ -71,7 +75,8 @@ uint8_t fb_gfx_putc(fb_data_t *fb, int32_t x, int32_t y, uint32_t color, unsigne
uint8_t *bitmap;
GFXglyph *glyph;
if ((c < 32) || (c < gfxFont->first) || (c > gfxFont->last)) {
if ((c < 32) || (c < gfxFont->first) || (c > gfxFont->last))
{
return xa;
}
@ -86,41 +91,54 @@ uint8_t fb_gfx_putc(fb_data_t *fb, int32_t x, int32_t y, uint32_t color, unsigne
y += gfxFont->yOffset;
line_width = 0;
for(yy=0; yy<glyph->height; yy++) {
for(xx=0; xx<glyph->width; xx++) {
if(bit == 0) {
for (yy = 0; yy < glyph->height; yy++)
{
for (xx = 0; xx < glyph->width; xx++)
{
if (bit == 0)
{
bits = *bitmap++;
bit = 0x80;
}
if(bits & bit) {
if (bits & bit)
{
line_width++;
} else if (line_width) {
fb_gfx_drawFastHLine(fb, x+xx-line_width, y+yy, line_width, color);
line_width=0;
}
else if (line_width)
{
fb_gfx_drawFastHLine(fb, x + xx - line_width, y + yy, line_width, color);
line_width = 0;
}
bit >>= 1;
}
if (line_width) {
fb_gfx_drawFastHLine(fb, x+xx-line_width, y+yy, line_width, color);
line_width=0;
if (line_width)
{
fb_gfx_drawFastHLine(fb, x + xx - line_width, y + yy, line_width, color);
line_width = 0;
}
}
return xa;
}
uint32_t fb_gfx_print(fb_data_t *fb, int x, int y, uint32_t color, const char * str)
uint32_t fb_gfx_print(fb_data_t *fb, int x, int y, uint32_t color, const char *str)
{
uint32_t l = 0;
int xc = x, yc = y, lc = fb->width - gfxFont->glyph[0].xAdvance;
uint8_t fh = gfxFont->yAdvance;
char c = *str++;
while(c){
if(c != '\r'){
if(c == '\n'){
while (c)
{
if (c != '\r')
{
if (c == '\n')
{
yc += fh;
xc = x;
} else {
if(xc > lc){
}
else
{
if (xc > lc)
{
yc += fh;
xc = x;
}
@ -136,7 +154,7 @@ uint32_t fb_gfx_print(fb_data_t *fb, int x, int y, uint32_t color, const char *
uint32_t fb_gfx_printf(fb_data_t *fb, int32_t x, int32_t y, uint32_t color, const char *format, ...)
{
char loc_buf[64];
char * temp = loc_buf;
char *temp = loc_buf;
int len;
va_list arg;
va_list copy;
@ -144,16 +162,19 @@ uint32_t fb_gfx_printf(fb_data_t *fb, int32_t x, int32_t y, uint32_t color, cons
va_copy(copy, arg);
len = vsnprintf(loc_buf, sizeof(loc_buf), format, arg);
va_end(copy);
if(len >= sizeof(loc_buf)){
temp = (char*)malloc(len+1);
if(temp == NULL) {
if (len >= sizeof(loc_buf))
{
temp = (char *)malloc(len + 1);
if (temp == NULL)
{
return 0;
}
}
vsnprintf(temp, len+1, format, arg);
vsnprintf(temp, len + 1, format, arg);
va_end(arg);
fb_gfx_print(fb, x, y, color, temp);
if(len > 64){
if (len > 64)
{
free(temp);
}
return len;

View File

@ -0,0 +1,96 @@
# 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.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB