From 788ef126ccf93c99099a925fdd3c78ac652aca59 Mon Sep 17 00:00:00 2001 From: fustyles <34397289+fustyles@users.noreply.github.com> Date: Thu, 30 Jul 2020 23:34:41 +0800 Subject: [PATCH] Add files via upload --- .../ESP32-CAM_HandPose/ESP32-CAM_HandPose.ino | 515 +++------- .../ESP32-CAM_MultiPersonPose.ino | 956 +++++++----------- .../ESP32-CAM_blazeface.ino | 512 +++------- .../ESP32-CAM_bodypix/ESP32-CAM_bodypix.ino | 653 +++++------- .../ESP32-CAM_bodypix2/ESP32-CAM_bodypix2.ino | 618 ++++------- .../ESP32-CAM_coco-ssd/ESP32-CAM_coco-ssd.ino | 504 +++------ .../ESP32-CAM_deeplabV3.ino | 487 +++------ .../ESP32-CAM_facemesh/ESP32-CAM_facemesh.ino | 540 +++------- .../ESP32-CAM_knn-classifier.ino | 525 +++------- .../ESP32-CAM_mobilenet.ino | 478 +++------ .../ESP32-CAM_teachablemachine.ino | 537 ++++------ 11 files changed, 2049 insertions(+), 4276 deletions(-) diff --git a/ESP32-CAM_Tensorflow.js/ESP32-CAM_HandPose/ESP32-CAM_HandPose.ino b/ESP32-CAM_Tensorflow.js/ESP32-CAM_HandPose/ESP32-CAM_HandPose.ino index 4fd5f0f77..d646daf91 100644 --- a/ESP32-CAM_Tensorflow.js/ESP32-CAM_HandPose/ESP32-CAM_HandPose.ino +++ b/ESP32-CAM_Tensorflow.js/ESP32-CAM_HandPose/ESP32-CAM_HandPose.ino @@ -1,58 +1,46 @@ /* -ESP32-CAM HAND POSE -Open the page in Chrome. -Author : ChungYi Fu (Kaohsiung, Taiwan) 2020-7-1 00:00 +Author : ChungYi Fu (Kaohsiung, Taiwan) 2020-7-30 22:00 https://www.facebook.com/francefu +http://192.168.xxx.xxx //網頁首頁管理介面 +http://192.168.xxx.xxx:81/stream //取得串流影像 +http://192.168.xxx.xxx/capture //取得影像 +http://192.168.xxx.xxx/status //取得視訊參數值 + 自訂指令格式 : http://APIP/control?cmd=P1;P2;P3;P4;P5;P6;P7;P8;P9 http://STAIP/control?cmd=P1;P2;P3;P4;P5;P6;P7;P8;P9 預設AP端IP: 192.168.4.1 -http://192.168.xxx.xxx/control?ip -http://192.168.xxx.xxx/control?mac -http://192.168.xxx.xxx/control?restart -http://192.168.xxx.xxx/control?flash=value //value= 0~255 - + +自訂指令格式 http://192.168.xxx.xxx/control?cmd=P1;P2;P3;P4;P5;P6;P7;P8;P9 +http://192.168.xxx.xxx/control?ip //取得APIP, STAIP +http://192.168.xxx.xxx/control?mac //取得MAC位址 +http://192.168.xxx.xxx/control?restart //重啟ESP32-CAM +http://192.168.xxx.xxx/control?digitalwrite=pin;value //數位輸出 +http://192.168.xxx.xxx/control?analogwrite=pin;value //類比輸出 +http://192.168.xxx.xxx/control?digitalread=pin //數位讀取 +http://192.168.xxx.xxx/control?analogread=pin //類比讀取 +http://192.168.xxx.xxx/control?touchread=pin //觸碰讀取 +http://192.168.xxx.xxx/control?flash=value //內建閃光燈 value= 0~255 + +官方指令格式 http://192.168.xxx.xxx/control?var=***&val=*** +http://192.168.xxx.xxx/control?var=framesize&val=value // value = 10->UXGA(1600x1200), 9->SXGA(1280x1024), 8->XGA(1024x768) ,7->SVGA(800x600), 6->VGA(640x480), 5 selected=selected->CIF(400x296), 4->QVGA(320x240), 3->HQVGA(240x176), 0->QQVGA(160x120) +http://192.168.xxx.xxx/control?var=quality&val=value // value = 10 ~ 63 +http://192.168.xxx.xxx/control?var=brightness&val=value // value = -2 ~ 2 +http://192.168.xxx.xxx/control?var=contrast&val=value // value = -2 ~ 2 +http://192.168.xxx.xxx/control?var=hmirror&val=value // value = 0 or 1 +http://192.168.xxx.xxx/control?var=vflip&val=value // value = 0 or 1 +http://192.168.xxx.xxx/control?var=flash&val=value // value = 0 ~ 255 + 查詢Client端IP: 查詢IP:http://192.168.4.1/?ip 重設網路:http://192.168.4.1/?resetwifi=ssid;password - -http://192.168.xxx.xxx //網頁首頁管理介面 -http://192.168.xxx.xxx:81/stream //取得串流影像 -http://192.168.xxx.xxx/capture //取得影像 -http://192.168.xxx.xxx/status //取得視訊參數值 - -設定視訊參數(官方指令格式) -http://192.168.xxx.xxx/control?var=framesize&val=value // value = 10->UXGA(1600x1200), 9->SXGA(1280x1024), 8->XGA(1024x768) ,7->SVGA(800x600), 6->VGA(640x480), 5 selected=selected->CIF(400x296), 4->QVGA(320x240), 3->HQVGA(240x176), 0->QQVGA(160x120) -http://192.168.xxx.xxx/control?var=quality&val=value // value = 10 ~ 63 -http://192.168.xxx.xxx/control?var=brightness&val=value // value = -2 ~ 2 -http://192.168.xxx.xxx/control?var=contrast&val=value // value = -2 ~ 2 -http://192.168.xxx.xxx/control?var=saturation&val=value // value = -2 ~ 2 -http://192.168.xxx.xxx/control?var=gainceiling&val=value // value = 0 ~ 6 -http://192.168.xxx.xxx/control?var=colorbar&val=value // value = 0 or 1 -http://192.168.xxx.xxx/control?var=awb&val=value // value = 0 or 1 -http://192.168.xxx.xxx/control?var=agc&val=value // value = 0 or 1 -http://192.168.xxx.xxx/control?var=aec&val=value // value = 0 or 1 -http://192.168.xxx.xxx/control?var=hmirror&val=value // value = 0 or 1 -http://192.168.xxx.xxx/control?var=vflip&val=value // value = 0 or 1 -http://192.168.xxx.xxx/control?var=awb_gain&val=value // value = 0 or 1 -http://192.168.xxx.xxx/control?var=agc_gain&val=value // value = 0 ~ 30 -http://192.168.xxx.xxx/control?var=aec_value&val=value // value = 0 ~ 1200 -http://192.168.xxx.xxx/control?var=aec2&val=value // value = 0 or 1 -http://192.168.xxx.xxx/control?var=dcw&val=value // value = 0 or 1 -http://192.168.xxx.xxx/control?var=bpc&val=value // value = 0 or 1 -http://192.168.xxx.xxx/control?var=wpc&val=value // value = 0 or 1 -http://192.168.xxx.xxx/control?var=raw_gma&val=value // value = 0 or 1 -http://192.168.xxx.xxx/control?var=lenc&val=value // value = 0 or 1 -http://192.168.xxx.xxx/control?var=special_effect&val=value // value = 0 ~ 6 -http://192.168.xxx.xxx/control?var=wb_mode&val=value // value = 0 ~ 4 -http://192.168.xxx.xxx/control?var=ae_level&val=value // value = -2 ~ 2 */ //輸入WIFI連線帳號密碼 -const char* ssid = "xxxxx"; //your network SSID -const char* password = "xxxxx"; //your network password +const char* ssid = "*****"; //your network SSID +const char* password = "*****"; //your network password //輸入AP端連線帳號密碼 const char* apssid = "ESP32-CAM"; @@ -60,23 +48,20 @@ const char* appassword = "12345678"; //AP密碼至少要8個字元以上 #include #include //用於控制伺服馬達 -#include "esp_camera.h" //視訊 -#include "Base64.h" //用於轉換視訊影像格式為base64格式,易於上傳google雲端硬碟或資料庫 #include "soc/soc.h" //用於電源不穩不重開機 -#include "soc/rtc_cntl_reg.h" //用於電源不穩不重開機 +#include "soc/rtc_cntl_reg.h" //用於電源不穩不重開機 //官方函式庫 -#include "esp_http_server.h" -#include "esp_timer.h" -#include "esp_camera.h" -#include "img_converters.h" -#include "fb_gfx.h" -#include "fd_forward.h" -#include "fr_forward.h" +#include "esp_camera.h" //視訊函式庫 +#include "esp_http_server.h" //HTTP Server函式庫 +#include "esp_timer.h" //計時器函式庫 +#include "img_converters.h" //影像格式轉換函式庫 +#include "fb_gfx.h" //影像繪圖函式庫 +#include "fd_forward.h" //人臉偵測函式庫 -String Feedback=""; //回傳客戶端訊息 +String Feedback=""; //自訂指令回傳客戶端訊息 -//指令參數值 +//自訂指令參數值 String Command=""; String cmd=""; String P1=""; @@ -89,7 +74,7 @@ String P7=""; String P8=""; String P9=""; -//指令拆解狀態值 +//自訂指令拆解狀態值 byte ReceiveState=0; byte cmdState=1; byte strState=1; @@ -119,8 +104,6 @@ static ra_filter_t ra_filter; httpd_handle_t stream_httpd = NULL; httpd_handle_t camera_httpd = NULL; -static mtmn_config_t mtmn_config = {0}; - static ra_filter_t * ra_filter_init(ra_filter_t * filter, size_t sample_size){ memset(filter, 0, sizeof(ra_filter_t)); @@ -152,7 +135,7 @@ static int ra_filter_run(ra_filter_t * filter, int value){ // WARNING!!! Make sure that you have either selected ESP32 Wrover Module, // or another board which has PSRAM enabled -//安可信ESP32-CAM模組腳位設定 +//ESP32-CAM模組腳位設定 #define PWDN_GPIO_NUM 32 #define RESET_GPIO_NUM -1 #define XCLK_GPIO_NUM 0 @@ -314,7 +297,8 @@ static esp_err_t capture_handler(httpd_req_t *req){ httpd_resp_set_type(req, "image/jpeg"); httpd_resp_set_hdr(req, "Content-Disposition", "inline; filename=capture.jpg"); - + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); + size_t out_len, out_width, out_height; uint8_t * out_buf; bool s; @@ -482,10 +466,10 @@ static esp_err_t stream_handler(httpd_req_t *req){ //指令參數控制 static esp_err_t cmd_handler(httpd_req_t *req){ - char* buf; //存取網址後帶的參數字串 + char* buf; //存取網址後帶的參數字串 size_t buf_len; char variable[128] = {0,}; //存取參數var值 - char value[128] = {0,}; //存取參數val值 + char value[128] = {0,}; //存取參數val值 String myCmd = ""; buf_len = httpd_req_get_url_query_len(req) + 1; @@ -501,7 +485,7 @@ static esp_err_t cmd_handler(httpd_req_t *req){ httpd_query_key_value(buf, "val", value, sizeof(value)) == ESP_OK) { } else { - myCmd = String(buf); + myCmd = String(buf); //如果非官方格式不含var, val,則為自訂指令格式 } } } else { @@ -512,9 +496,9 @@ static esp_err_t cmd_handler(httpd_req_t *req){ Feedback="";Command="";cmd="";P1="";P2="";P3="";P4="";P5="";P6="";P7="";P8="";P9=""; ReceiveState=0,cmdState=1,strState=1,questionstate=0,equalstate=0,semicolonstate=0; if (myCmd.length()>0) { - myCmd = "?"+myCmd; //網址後帶的參數字串轉換成自訂參數格式 + myCmd = "?"+myCmd; //網址後帶的參數字串轉換成自訂指令格式 for (int i=0;iHello World"; //可為一般文字或HTML語法 } - else if (cmd=="ip") { //查詢IP + else if (cmd=="ip") { //查詢APIP, STAIP Feedback="AP IP: "+WiFi.softAPIP().toString(); - Feedback+=", "; + Feedback+=""; Feedback+="STA IP: "+WiFi.localIP().toString(); } - else if (cmd=="mac") { //查詢MAC + else if (cmd=="mac") { //查詢MAC位址 Feedback="STA MAC: "+WiFi.macAddress(); } else if (cmd=="restart") { //重設WIFI連線 ESP.restart(); - } + } + else if (cmd=="digitalwrite") { + ledcDetachPin(P1.toInt()); + pinMode(P1.toInt(), OUTPUT); + digitalWrite(P1.toInt(), P2.toInt()); + } + else if (cmd=="digitalread") { + Feedback=String(digitalRead(P1.toInt())); + } + else if (cmd=="analogwrite") { + if (P1=="4") { + ledcAttachPin(4, 4); + ledcSetup(4, 5000, 8); + ledcWrite(4,P2.toInt()); + } + else { + ledcAttachPin(P1.toInt(), 9); + ledcSetup(9, 5000, 8); + ledcWrite(9,P2.toInt()); + } + } + else if (cmd=="analogread") { + Feedback=String(analogRead(P1.toInt())); + } + else if (cmd=="touchread") { + Feedback=String(touchRead(P1.toInt())); + } else if (cmd=="flash") { //控制內建閃光燈 ledcAttachPin(4, 4); ledcSetup(4, 5000, 8); - int val = P1.toInt(); ledcWrite(4,val); - } + } else { Feedback="Command is not defined"; } @@ -559,11 +568,11 @@ static esp_err_t cmd_handler(httpd_req_t *req){ return httpd_resp_send(req, resp, strlen(resp)); } else { + //官方指令區塊,也可在此自訂指令 http://192.168.xxx.xxx/control?var=xxx&val=xxx int val = atoi(value); sensor_t * s = esp_camera_sensor_get(); int res = 0; - //官方指令區塊,也可在此自訂指令 http://192.168.xxx.xxx/control?var=xxx&val=xxx if(!strcmp(variable, "framesize")) { if(s->pixformat == PIXFORMAT_JPEG) res = s->set_framesize(s, (framesize_t)val); @@ -571,26 +580,13 @@ static esp_err_t cmd_handler(httpd_req_t *req){ else if(!strcmp(variable, "quality")) res = s->set_quality(s, val); else if(!strcmp(variable, "contrast")) res = s->set_contrast(s, val); else if(!strcmp(variable, "brightness")) res = s->set_brightness(s, val); - else if(!strcmp(variable, "saturation")) res = s->set_saturation(s, val); - else if(!strcmp(variable, "gainceiling")) res = s->set_gainceiling(s, (gainceiling_t)val); - else if(!strcmp(variable, "colorbar")) res = s->set_colorbar(s, val); - else if(!strcmp(variable, "awb")) res = s->set_whitebal(s, val); - else if(!strcmp(variable, "agc")) res = s->set_gain_ctrl(s, val); - else if(!strcmp(variable, "aec")) res = s->set_exposure_ctrl(s, val); else if(!strcmp(variable, "hmirror")) res = s->set_hmirror(s, val); else if(!strcmp(variable, "vflip")) res = s->set_vflip(s, val); - else if(!strcmp(variable, "awb_gain")) res = s->set_awb_gain(s, val); - else if(!strcmp(variable, "agc_gain")) res = s->set_agc_gain(s, val); - else if(!strcmp(variable, "aec_value")) res = s->set_aec_value(s, val); - else if(!strcmp(variable, "aec2")) res = s->set_aec2(s, val); - else if(!strcmp(variable, "dcw")) res = s->set_dcw(s, val); - else if(!strcmp(variable, "bpc")) res = s->set_bpc(s, val); - else if(!strcmp(variable, "wpc")) res = s->set_wpc(s, val); - else if(!strcmp(variable, "raw_gma")) res = s->set_raw_gma(s, val); - else if(!strcmp(variable, "lenc")) res = s->set_lenc(s, val); - else if(!strcmp(variable, "special_effect")) res = s->set_special_effect(s, val); - else if(!strcmp(variable, "wb_mode")) res = s->set_wb_mode(s, val); - else if(!strcmp(variable, "ae_level")) res = s->set_ae_level(s, val); + else if(!strcmp(variable, "flash")) { + ledcAttachPin(4, 4); + ledcSetup(4, 5000, 8); + ledcWrite(4,val); + } else { res = -1; } @@ -613,39 +609,20 @@ static esp_err_t cmd_handler(httpd_req_t *req){ } } -//顯示視訊參數狀態(須回傳json格式) +//顯示視訊參數狀態(須回傳json格式載入初始設定) static esp_err_t status_handler(httpd_req_t *req){ static char json_response[1024]; sensor_t * s = esp_camera_sensor_get(); char * p = json_response; *p++ = '{'; - + p+=sprintf(p, "\"flash\":%d,", 0); p+=sprintf(p, "\"framesize\":%u,", s->status.framesize); p+=sprintf(p, "\"quality\":%u,", s->status.quality); p+=sprintf(p, "\"brightness\":%d,", s->status.brightness); p+=sprintf(p, "\"contrast\":%d,", s->status.contrast); - p+=sprintf(p, "\"saturation\":%d,", s->status.saturation); - p+=sprintf(p, "\"sharpness\":%d,", s->status.sharpness); - p+=sprintf(p, "\"special_effect\":%u,", s->status.special_effect); - p+=sprintf(p, "\"wb_mode\":%u,", s->status.wb_mode); - p+=sprintf(p, "\"awb\":%u,", s->status.awb); - p+=sprintf(p, "\"awb_gain\":%u,", s->status.awb_gain); - p+=sprintf(p, "\"aec\":%u,", s->status.aec); - p+=sprintf(p, "\"aec2\":%u,", s->status.aec2); - p+=sprintf(p, "\"ae_level\":%d,", s->status.ae_level); - p+=sprintf(p, "\"aec_value\":%u,", s->status.aec_value); - p+=sprintf(p, "\"agc\":%u,", s->status.agc); - p+=sprintf(p, "\"agc_gain\":%u,", s->status.agc_gain); - p+=sprintf(p, "\"gainceiling\":%u,", s->status.gainceiling); - p+=sprintf(p, "\"bpc\":%u,", s->status.bpc); - p+=sprintf(p, "\"wpc\":%u,", s->status.wpc); - p+=sprintf(p, "\"raw_gma\":%u,", s->status.raw_gma); - p+=sprintf(p, "\"lenc\":%u,", s->status.lenc); - p+=sprintf(p, "\"vflip\":%u,", s->status.vflip); - p+=sprintf(p, "\"hmirror\":%u,", s->status.hmirror); - p+=sprintf(p, "\"dcw\":%u,", s->status.dcw); - p+=sprintf(p, "\"colorbar\":%u", s->status.colorbar); + p+=sprintf(p, "\"hmirror\":%u,", s->status.hmirror); + p+=sprintf(p, "\"vflip\":%u", s->status.vflip); *p++ = '}'; *p++ = 0; httpd_resp_set_type(req, "application/json"); @@ -662,26 +639,25 @@ static const char PROGMEM INDEX_HTML[] = R"rawliteral( - ESP32 OV2460 + HandPose - - + + + - Get Still - Flash - - + + RestartGet Still - × + × @@ -692,6 +668,12 @@ static const char PROGMEM INDEX_HTML[] = R"rawliteral( + + Flash + 0 + + 255 + Resolution @@ -724,121 +706,6 @@ static const char PROGMEM INDEX_HTML[] = R"rawliteral( 2 - - Saturation - -2 - - 2 - - - Special Effect - - No Effect - Negative - Grayscale - Red Tint - Green Tint - Blue Tint - Sepia - - - - AWB - - - - - - - AWB Gain - - - - - - - WB Mode - - Auto - Sunny - Cloudy - Office - Home - - - - AEC SENSOR - - - - - - - AEC DSP - - - - - - - AE Level - -2 - - 2 - - - Exposure - 0 - - 1200 - - - AGC - - - - - - - Gain - 1x - - 31x - - - Gain Ceiling - 2x - - 128x - - - BPC - - - - - - - WPC - - - - - - - Raw GMA - - - - - - - Lens Correction - - - - - H-Mirror @@ -853,32 +720,12 @@ static const char PROGMEM INDEX_HTML[] = R"rawliteral( - - DCW (Downsize EN) - - - - - - - Color Bar - - - - - - MirrorImage - - Y - N - - - Please wait for loading model. + Please wait for loading model. - -