├── ObjectDetection_ESP32cam ├── ObjectDetection_ESP32cam.vcxproj.user ├── ObjectDetection_ESP32cam.vcxproj.filters ├── ObjectDetection_ESP32cam.vcxproj ├── CppProperties.json ├── ObjectDetection_ESP32cam.ino └── __vm │ ├── Configuration.Release.vmps.xml │ ├── Compile.vmps.xml │ └── Upload.vmps.xml ├── LICENSE └── README.md /ObjectDetection_ESP32cam/ObjectDetection_ESP32cam.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 CiferTech 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ObjectDetection_ESP32cam/ObjectDetection_ESP32cam.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | -------------------------------------------------------------------------------- /ObjectDetection_ESP32cam/ObjectDetection_ESP32cam.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Release 6 | Win32 7 | 8 | 9 | Debug 10 | Win32 11 | 12 | 13 | 14 | {C5F80730-F44F-4478-BDAE-6634EFC2CA88} 15 | 16 | 17 | ObjectDetection_ESP32cam 18 | 19 | 20 | 21 | Application 22 | true 23 | MultiByte 24 | 25 | 26 | 27 | 28 | Application 29 | false 30 | true 31 | MultiByte 32 | 33 | 34 | 35 | 36 | Application 37 | true 38 | MultiByte 39 | 40 | 41 | 42 | 43 | Application 44 | false 45 | true 46 | MultiByte 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | Level3 72 | MaxSpeed 73 | true 74 | true 75 | true 76 | 77 | 78 | true 79 | true 80 | true 81 | 82 | 83 | 84 | 85 | Level3 86 | Disabled 87 | true 88 | $(ProjectDir)..\ObjectDetection_ESP32cam;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\avr;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\libb64;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\spiffs;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\variants\nodemcu;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\tools\sdk\include;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\tools\sdk\lwip2\include;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\tools\sdk\libc\xtensa-lx106-elf\include;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\xtensa-lx106-elf;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\lib\gcc\xtensa-lx106-elf\4.8.2\include;$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\tools\sdk\include;%(AdditionalIncludeDirectories) 89 | $(ProjectDir)__vm\.ObjectDetection_ESP32cam.vsarduino.h;%(ForcedIncludeFiles) 90 | true 91 | __ESP8266_esp8266__;__ESP8266_ESP8266__;__ets__;ICACHE_FLASH;NONOSDK22x_190703=1;F_CPU=80000000L;LWIP_OPEN_SRC;TCP_MSS=536;LWIP_FEATURES=1;LWIP_IPV6=0;ARDUINO=108010;ARDUINO_ESP8266_NODEMCU;ARDUINO_ARCH_ESP8266;LED_BUILTIN=2;FLASHMODE_DIO;ESP8266;__cplusplus=201103L;_VMICRO_INTELLISENSE;%(PreprocessorDefinitions) 92 | 93 | 94 | true 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | VisualMicroDebugger 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | logo 4 |

ObjectDetection ESP32cam

5 | 6 |

7 | Using ESP32-CAM for the Object Detection system 8 |

9 | 10 | 11 | 12 | 13 |

14 | cifertech - ObjectDetection_ESP32cam 15 | stars - ObjectDetection_ESP32cam 16 | forks - ObjectDetection_ESP32cam 17 | 18 |

19 | TWITTER 20 | · 21 | INSTAGRAM 22 | · 23 | YOUTUBE 24 | · 25 | WEBSITE 26 |

27 |
28 | 29 |
30 | 31 | 32 | # :notebook_with_decorative_cover: Table of Contents 33 | 34 | - [About the Project](#star2-about-the-project) 35 | * [Pictures](#camera-Pictures) 36 | * [Features](#dart-features) 37 | - [Getting Started](#toolbox-getting-started) 38 | * [Schematic](#electric_plug-Schematic) 39 | * [Installation](#gear-installation) 40 | - [Usage](#eyes-usage) 41 | - [Contributing](#wave-contributing) 42 | - [License](#warning-license) 43 | - [Contact](#handshake-contact) 44 | 45 | 46 | 47 | 48 | ## :star2: About the Project 49 | In the this tutorials of the ESP32-CAM series, we saw that using the original code, we will be able to process face image from face recognition to face separation, but in cases where we need to recognize different objects, different models must be introduced to our code. To be able to identify the objects we want with self-learning. But no matter how high the processing power of ESP chips, we can not leave all this complex processing to this small chip, so we will use Tensorflow.JS to combine it with the video sent from ESP32-CAM. Note that in this tutorial, Tensorflow.JS runs in the computer browser and therefore the machine learning model runs inside your browser. 50 | 51 | 52 | ### :camera: Pictures 53 | 54 |
55 | 56 |
57 | 58 | 59 | ### :dart: Features 60 | 61 | - Selection of the desired objects in the web server 62 | - Real-time object detection 63 | - No need to run the second code on the computer 64 | 65 | 66 | ## :toolbox: Getting Started 67 | 68 | In this project, by streaming images using the ESP32-CAM board and receiving and displaying them in the browser, we will also use Tensorflow.JS to process images using the default models applied. 69 | 70 | - ESP32-CAM 71 | - USB-To-TTL 72 | 73 | 74 | ### :electric_plug: Schematic 75 | 76 | To program the ESP-CAM board, we need Arduino-IDE software, and of course, download the relevant board in the software environment, as well as install the required libraries. For information on these cases, you can refer to this tutorial. Make the connections according to the schematic below according to the USB TO TTL used. Note that when programming code, ie after compiling the code, the two pins GPIO 0 and GND are connected to each other, and after successfully compiling the code, you must disconnect this connection to run the project. 77 | 78 | Make the connections according to the table and schematic below. 79 | 80 | | ESP32CAM | USB-To-TTL | 81 | | ---- | -----| 82 | | U0T | RXD | 83 | | U0R | TXD | 84 | | 5v | VCC | 85 | | GND | GND | 86 | 87 | 88 | * Complete Schematic 89 | 90 | screenshot 91 | 92 | 93 | 94 | ### :gear: Installation 95 | 96 | In this part of the action code, we will introduce Tensorflow.js to analyze the received images in the browser. In the next line, we will also import COCO-SSD models along with Tensorflow.js. 97 | ```c++ 98 | 99 | 100 | 101 | ``` 102 | 103 | In the next section, we will load the introduced models so that they can be recognized as a result of processing the received image for our machine. 104 | ```c++ 105 | function ObjectDetect() { 106 | result.innerHTML = "Please wait for loading model."; 107 | cocoSsd.load().then(cocoSsd_Model => { 108 | Model = cocoSsd_Model; 109 | result.innerHTML = ""; 110 | getStill.style.display = "block"; 111 | }); 112 | } 113 | ``` 114 | 115 | After our machine detects an object in the image, it should now be visible to the user in the form that squares around the detected image are usually used in image processing, the following code is for this. 116 | ```c++ 117 | if (Predictions.length>0) { 118 | result.innerHTML = ""; 119 | for (var i=0;i 138 | ## :eyes: Usage 139 | 140 | After uploading the desired code, I reset the board in the serial ip of the web server will be displayed for us, such as 192.168.1.103, which we will search for in the browser to enter the web server page, we have to wait for a while until Load the related models, then click on the StartDetect icon to display the images and recognize the defined items. Also, if there is a problem with the image processing or other parts, click on the Restart option. 141 | 142 | screenshot 143 | 144 | - In the web server, it is possible to count it by specifying the desired item. By selecting the desired object, the number of detected items will be displayed in front of it. 145 | screenshot 146 | 147 | - In this section you adjust the output video settings. For example, it is possible to change the resolution or mirror the image in this section. 148 | screenshot 149 | 150 | - In this section, the contrast, quality and brightness of the received image can be adjusted. 151 | screenshot 152 | 153 | - If the object is detected, its name will be displayed in this section, and also the percentage of probability that our machine analysis is correct, as well as the coordinates and number of detected objects can be displayed in this section. 154 | screenshot 155 | 156 | - Finally, we have the received image, which will inform the user if he detects an object with a square and also enters its name. 157 | screenshot 158 | 159 | 160 | 161 | 162 | ## :wave: Contributing 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | ## :warning: License 171 | 172 | Distributed under the MIT License. See LICENSE.txt for more information. 173 | 174 | 175 | 176 | ## :handshake: Contact 177 | 178 | CiferTech - [@twitter](https://twitter.com/cifertech1) - CiferTech@gmali.com 179 | 180 | Project Link: [https://github.com/cifertech/ObjectDetection_ESP32cam](https://github.com/cifertech/ObjectDetection_ESP32cam) 181 | -------------------------------------------------------------------------------- /ObjectDetection_ESP32cam/CppProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Visual Micro", 5 | "intelliSenseMode": "windows-msvc-x86", 6 | "includePath": [ 7 | "${projectRoot}..\\ObjectDetection_ESP32cam", 8 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\libraries\\WiFi\\src", 9 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\libraries\\WiFiClientSecure\\src", 10 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\cores\\esp32", 11 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\cores\\esp32\\apps", 12 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\cores\\esp32\\libb64", 13 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\variants\\esp32", 14 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\config", 15 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\app_trace", 16 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\app_update", 17 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\asio", 18 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\bootloader_support", 19 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\bt", 20 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\coap", 21 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\console", 22 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\driver", 23 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\efuse", 24 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\esp-tls", 25 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\esp32", 26 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\esp_adc_cal", 27 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\esp_event", 28 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\esp_http_client", 29 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\esp_http_server", 30 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\esp_https_ota", 31 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\esp_https_server", 32 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\esp_ringbuf", 33 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\esp_websocket_client", 34 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\espcoredump", 35 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\ethernet", 36 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\expat", 37 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\fatfs", 38 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\freemodbus", 39 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\freertos", 40 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\heap", 41 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\idf_test", 42 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\jsmn", 43 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\json", 44 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\libsodium", 45 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\log", 46 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\lwip", 47 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\mbedtls", 48 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\mdns", 49 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\micro-ecc", 50 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\mqtt", 51 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\newlib", 52 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\nghttp", 53 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\nimble", 54 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\nvs_flash", 55 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\openssl", 56 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\protobuf-c", 57 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\protocomm", 58 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\pthread", 59 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\sdmmc", 60 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\smartconfig_ack", 61 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\soc", 62 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\spi_flash", 63 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\spiffs", 64 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\tcp_transport", 65 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\tcpip_adapter", 66 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\ulp", 67 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\unity", 68 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\vfs", 69 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\wear_levelling", 70 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\wifi_provisioning", 71 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\wpa_supplicant", 72 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\xtensa-debug-module", 73 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\esp-face", 74 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\esp32-camera", 75 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include\\fb_gfx", 76 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-97-gc752ad5-5.2.0\\lib\\gcc\\xtensa-esp32-elf\\5.2.0\\include", 77 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-97-gc752ad5-5.2.0\\xtensa-esp32-elf\\include\\c++\\5.2.0\\xtensa-esp32-elf", 78 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-97-gc752ad5-5.2.0\\xtensa-esp32-elf\\include", 79 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-97-gc752ad5-5.2.0\\xtensa-esp32-elf\\include\\c++\\5.2.0", 80 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-97-gc752ad5-5.2.0\\include\\c++\\5.2.0", 81 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-97-gc752ad5-5.2.0\\include", 82 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506\\xtensa-lx106-elf\\include\\c++\\4.8.2", 83 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506\\xtensa-lx106-elf\\include\\c++\\4.8.2\\xtensa-lx106-elf", 84 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506\\xtensa-lx106-elf\\include", 85 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506\\lib\\gcc\\xtensa-lx106-elf\\4.8.2\\include", 86 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\hardware\\esp32\\1.0.5\\tools\\sdk\\include", 87 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-97-gc752ad5-5.2.0\\lib\\gcc\\xtensa-esp32-elf\\5.2.0\\new", 88 | "${projectRoot}..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-97-gc752ad5-5.2.0\\lib\\gcc\\xtensa-esp32-elf\\5.2.0\\bits" 89 | ], 90 | "defines": [ 91 | "__ESP32_esp32__", 92 | "__ESP32_ESP32__", 93 | "ESP_PLATFORM", 94 | "HAVE_CONFIG_H", 95 | "GCC_NOT_5_2_0=0", 96 | "WITH_POSIX", 97 | "F_CPU=240000000L", 98 | "ARDUINO=108013", 99 | "ARDUINO_ESP32_DEV", 100 | "ARDUINO_ARCH_ESP32", 101 | "ESP32", 102 | "CORE_DEBUG_LEVEL=0", 103 | "BOARD_HAS_PSRAM", 104 | "__cplusplus=201103L", 105 | "_VMICRO_INTELLISENSE" 106 | ] 107 | } 108 | ] 109 | } -------------------------------------------------------------------------------- /ObjectDetection_ESP32cam/ObjectDetection_ESP32cam.ino: -------------------------------------------------------------------------------- 1 | const char* ssid = "CiferTech"; 2 | const char* password = "1234567891"; 3 | 4 | const char* apssid = "ESP32-CAM"; 5 | const char* appassword = "12345678"; 6 | 7 | #include 8 | #include 9 | #include "esp_camera.h" 10 | #include "soc/soc.h" 11 | #include "soc/rtc_cntl_reg.h" 12 | 13 | String Feedback=""; 14 | 15 | String Command="",cmd="",P1="",P2="",P3="",P4="",P5="",P6="",P7="",P8="",P9=""; 16 | 17 | byte ReceiveState=0,cmdState=1,strState=1,questionstate=0,equalstate=0,semicolonstate=0; 18 | 19 | 20 | #define PWDN_GPIO_NUM 32 21 | #define RESET_GPIO_NUM -1 22 | #define XCLK_GPIO_NUM 0 23 | #define SIOD_GPIO_NUM 26 24 | #define SIOC_GPIO_NUM 27 25 | 26 | #define Y9_GPIO_NUM 35 27 | #define Y8_GPIO_NUM 34 28 | #define Y7_GPIO_NUM 39 29 | #define Y6_GPIO_NUM 36 30 | #define Y5_GPIO_NUM 21 31 | #define Y4_GPIO_NUM 19 32 | #define Y3_GPIO_NUM 18 33 | #define Y2_GPIO_NUM 5 34 | #define VSYNC_GPIO_NUM 25 35 | #define HREF_GPIO_NUM 23 36 | #define PCLK_GPIO_NUM 22 37 | 38 | WiFiServer server(80); 39 | 40 | void ExecuteCommand() 41 | { 42 | //Serial.println(""); 43 | //Serial.println("Command: "+Command); 44 | if (cmd!="getstill") { 45 | Serial.println("cmd= "+cmd+" ,P1= "+P1+" ,P2= "+P2+" ,P3= "+P3+" ,P4= "+P4+" ,P5= "+P5+" ,P6= "+P6+" ,P7= "+P7+" ,P8= "+P8+" ,P9= "+P9); 46 | Serial.println(""); 47 | } 48 | 49 | if (cmd=="your cmd") { 50 | // You can do anything. 51 | // Feedback="Hello World"; 52 | } 53 | else if (cmd=="ip") { 54 | Feedback="AP IP: "+WiFi.softAPIP().toString(); 55 | Feedback+=", "; 56 | Feedback+="STA IP: "+WiFi.localIP().toString(); 57 | } 58 | else if (cmd=="mac") { 59 | Feedback="STA MAC: "+WiFi.macAddress(); 60 | } 61 | else if (cmd=="resetwifi") { 62 | WiFi.begin(P1.c_str(), P2.c_str()); 63 | Serial.print("Connecting to "); 64 | Serial.println(P1); 65 | long int StartTime=millis(); 66 | while (WiFi.status() != WL_CONNECTED) 67 | { 68 | delay(500); 69 | if ((StartTime+5000) < millis()) break; 70 | } 71 | Serial.println(""); 72 | Serial.println("STAIP: "+WiFi.localIP().toString()); 73 | Feedback="STAIP: "+WiFi.localIP().toString(); 74 | } 75 | else if (cmd=="restart") { 76 | ESP.restart(); 77 | } 78 | else if (cmd=="digitalwrite") { 79 | ledcDetachPin(P1.toInt()); 80 | pinMode(P1.toInt(), OUTPUT); 81 | digitalWrite(P1.toInt(), P2.toInt()); 82 | } 83 | else if (cmd=="analogwrite") { 84 | if (P1="4") { 85 | ledcAttachPin(4, 4); 86 | ledcSetup(4, 5000, 8); 87 | ledcWrite(4,P2.toInt()); 88 | } 89 | else { 90 | ledcAttachPin(P1.toInt(), 5); 91 | ledcSetup(5, 5000, 8); 92 | ledcWrite(5,P2.toInt()); 93 | } 94 | } 95 | else if (cmd=="flash") { 96 | ledcAttachPin(4, 4); 97 | ledcSetup(4, 5000, 8); 98 | 99 | int val = P1.toInt(); 100 | ledcWrite(4,val); 101 | } 102 | else if (cmd=="framesize") { 103 | sensor_t * s = esp_camera_sensor_get(); 104 | if (P1=="QQVGA") 105 | s->set_framesize(s, FRAMESIZE_QQVGA); 106 | else if (P1=="HQVGA") 107 | s->set_framesize(s, FRAMESIZE_HQVGA); 108 | else if (P1=="QVGA") 109 | s->set_framesize(s, FRAMESIZE_QVGA); 110 | else if (P1=="CIF") 111 | s->set_framesize(s, FRAMESIZE_CIF); 112 | else if (P1=="VGA") 113 | s->set_framesize(s, FRAMESIZE_VGA); 114 | else if (P1=="SVGA") 115 | s->set_framesize(s, FRAMESIZE_SVGA); 116 | else if (P1=="XGA") 117 | s->set_framesize(s, FRAMESIZE_XGA); 118 | else if (P1=="SXGA") 119 | s->set_framesize(s, FRAMESIZE_SXGA); 120 | else if (P1=="UXGA") 121 | s->set_framesize(s, FRAMESIZE_UXGA); 122 | else 123 | s->set_framesize(s, FRAMESIZE_QVGA); 124 | } 125 | else if (cmd=="quality") { 126 | sensor_t * s = esp_camera_sensor_get(); 127 | int val = P1.toInt(); 128 | s->set_quality(s, val); 129 | } 130 | else if (cmd=="contrast") { 131 | sensor_t * s = esp_camera_sensor_get(); 132 | int val = P1.toInt(); 133 | s->set_contrast(s, val); 134 | } 135 | else if (cmd=="brightness") { 136 | sensor_t * s = esp_camera_sensor_get(); 137 | int val = P1.toInt(); 138 | s->set_brightness(s, val); 139 | } 140 | else if (cmd=="serial") { 141 | Serial.println(P1); 142 | } 143 | else if (cmd=="detectCount") { 144 | Serial.println(P1+" = "+P2); 145 | } 146 | else if (cmd=="tcp") { 147 | String domain=P1; 148 | int port=P2.toInt(); 149 | String request=P3; 150 | int wait=P4.toInt(); // wait = 0 or 1 151 | 152 | if ((port==443)||(domain.indexOf("https")==0)||(domain.indexOf("HTTPS")==0)) 153 | Feedback=tcp_https(domain,request,port,wait); 154 | else 155 | Feedback=tcp_http(domain,request,port,wait); 156 | } 157 | else if (cmd=="linenotify") { //message=xxx&stickerPackageId=xxx&stickerId=xxx 158 | String token = P1; 159 | String request = P2; 160 | Feedback=LineNotify(token,request,1); 161 | if (Feedback.indexOf("status")!=-1) { 162 | int s=Feedback.indexOf("{"); 163 | Feedback=Feedback.substring(s); 164 | int e=Feedback.indexOf("}"); 165 | Feedback=Feedback.substring(0,e); 166 | Feedback.replace("\"",""); 167 | Feedback.replace("{",""); 168 | Feedback.replace("}",""); 169 | } 170 | } 171 | else if (cmd=="sendCapturedImageToLineNotify") { 172 | Feedback=sendCapturedImageToLineNotify(P1); 173 | if (Feedback=="") Feedback="The image failed to send.
The framesize may be too large."; 174 | } 175 | else { 176 | Feedback="Command is not defined."; 177 | } 178 | if (Feedback=="") Feedback=Command; 179 | } 180 | 181 | void setup() { 182 | WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); 183 | 184 | Serial.begin(115200); 185 | Serial.setDebugOutput(true); 186 | Serial.println(); 187 | 188 | 189 | camera_config_t config; 190 | config.ledc_channel = LEDC_CHANNEL_0; 191 | config.ledc_timer = LEDC_TIMER_0; 192 | config.pin_d0 = Y2_GPIO_NUM; 193 | config.pin_d1 = Y3_GPIO_NUM; 194 | config.pin_d2 = Y4_GPIO_NUM; 195 | config.pin_d3 = Y5_GPIO_NUM; 196 | config.pin_d4 = Y6_GPIO_NUM; 197 | config.pin_d5 = Y7_GPIO_NUM; 198 | config.pin_d6 = Y8_GPIO_NUM; 199 | config.pin_d7 = Y9_GPIO_NUM; 200 | config.pin_xclk = XCLK_GPIO_NUM; 201 | config.pin_pclk = PCLK_GPIO_NUM; 202 | config.pin_vsync = VSYNC_GPIO_NUM; 203 | config.pin_href = HREF_GPIO_NUM; 204 | config.pin_sscb_sda = SIOD_GPIO_NUM; 205 | config.pin_sscb_scl = SIOC_GPIO_NUM; 206 | config.pin_pwdn = PWDN_GPIO_NUM; 207 | config.pin_reset = RESET_GPIO_NUM; 208 | config.xclk_freq_hz = 20000000; 209 | config.pixel_format = PIXFORMAT_JPEG; 210 | //init with high specs to pre-allocate larger buffers 211 | if(psramFound()){ 212 | config.frame_size = FRAMESIZE_UXGA; 213 | config.jpeg_quality = 10; //0-63 lower number means higher quality 214 | config.fb_count = 2; 215 | } else { 216 | config.frame_size = FRAMESIZE_SVGA; 217 | config.jpeg_quality = 12; //0-63 lower number means higher quality 218 | config.fb_count = 1; 219 | } 220 | 221 | // camera init 222 | esp_err_t err = esp_camera_init(&config); 223 | if (err != ESP_OK) { 224 | Serial.printf("Camera init failed with error 0x%x", err); 225 | delay(1000); 226 | ESP.restart(); 227 | } 228 | 229 | //drop down frame size for higher initial frame rate 230 | sensor_t * s = esp_camera_sensor_get(); 231 | s->set_framesize(s, FRAMESIZE_QVGA); //UXGA|SXGA|XGA|SVGA|VGA|CIF|QVGA|HQVGA|QQVGA 232 | 233 | ledcAttachPin(4, 4); 234 | ledcSetup(4, 5000, 8); 235 | 236 | WiFi.mode(WIFI_AP_STA); 237 | 238 | //WiFi.config(IPAddress(192, 168, 201, 100), IPAddress(192, 168, 201, 2), IPAddress(255, 255, 255, 0)); 239 | 240 | WiFi.begin(ssid, password); 241 | 242 | delay(1000); 243 | Serial.println(""); 244 | Serial.print("Connecting to "); 245 | Serial.println(ssid); 246 | 247 | long int StartTime=millis(); 248 | while (WiFi.status() != WL_CONNECTED) 249 | { 250 | delay(500); 251 | if ((StartTime+10000) < millis()) break; 252 | } 253 | 254 | if (WiFi.status() == WL_CONNECTED) { 255 | WiFi.softAP((WiFi.localIP().toString()+"_"+(String)apssid).c_str(), appassword); 256 | Serial.println(""); 257 | Serial.println("STAIP address: "); 258 | Serial.println(WiFi.localIP()); 259 | 260 | for (int i=0;i<5;i++) { 261 | ledcWrite(4,10); 262 | delay(200); 263 | ledcWrite(4,0); 264 | delay(200); 265 | } 266 | } 267 | else { 268 | WiFi.softAP((WiFi.softAPIP().toString()+"_"+(String)apssid).c_str(), appassword); 269 | 270 | for (int i=0;i<2;i++) { 271 | ledcWrite(4,10); 272 | delay(1000); 273 | ledcWrite(4,0); 274 | delay(1000); 275 | } 276 | } 277 | 278 | 279 | //WiFi.softAPConfig(IPAddress(192, 168, 4, 1), IPAddress(192, 168, 4, 1), IPAddress(255, 255, 255, 0)); 280 | Serial.println(""); 281 | Serial.println("APIP address: "); 282 | Serial.println(WiFi.softAPIP()); 283 | 284 | pinMode(4, OUTPUT); 285 | digitalWrite(4, LOW); 286 | 287 | server.begin(); 288 | } 289 | 290 | static const char PROGMEM INDEX_HTML[] = R"rawliteral( 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 392 | 393 | 394 | 395 | 396 | 411 | 412 | 413 | 414 | 420 | 421 | 422 | 423 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 462 | 463 |
Object 309 | 391 |
ScoreLimit 397 | 410 |
MirrorImage 415 | 419 |
Resolution 424 | 435 |
Flash
Quality
Brightness
Contrast
Rotate 455 | 461 |
464 |
465 | 466 | 467 | 468 | 613 | )rawliteral"; 614 | 615 | 616 | 617 | void loop() { 618 | Feedback="";Command="";cmd="";P1="";P2="";P3="";P4="";P5="";P6="";P7="";P8="";P9=""; 619 | ReceiveState=0,cmdState=1,strState=1,questionstate=0,equalstate=0,semicolonstate=0; 620 | 621 | WiFiClient client = server.available(); 622 | 623 | if (client) { 624 | String currentLine = ""; 625 | 626 | while (client.connected()) { 627 | if (client.available()) { 628 | char c = client.read(); 629 | 630 | getCommand(c); 631 | 632 | if (c == '\n') { 633 | if (currentLine.length() == 0) { 634 | 635 | if (cmd=="getstill") { 636 | 637 | camera_fb_t * fb = NULL; 638 | fb = esp_camera_fb_get(); 639 | if(!fb) { 640 | Serial.println("Camera capture failed"); 641 | delay(1000); 642 | ESP.restart(); 643 | } 644 | 645 | client.println("HTTP/1.1 200 OK"); 646 | client.println("Access-Control-Allow-Origin: *"); 647 | client.println("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); 648 | client.println("Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS"); 649 | client.println("Content-Type: image/jpeg"); 650 | client.println("Content-Disposition: form-data; name=\"imageFile\"; filename=\"picture.jpg\""); 651 | client.println("Content-Length: " + String(fb->len)); 652 | client.println("Connection: close"); 653 | client.println(); 654 | 655 | uint8_t *fbBuf = fb->buf; 656 | size_t fbLen = fb->len; 657 | for (size_t n=0;n0) { 663 | size_t remainder = fbLen%1024; 664 | client.write(fbBuf, remainder); 665 | } 666 | } 667 | 668 | esp_camera_fb_return(fb); 669 | 670 | pinMode(4, OUTPUT); 671 | digitalWrite(4, LOW); 672 | } 673 | else { 674 | 675 | client.println("HTTP/1.1 200 OK"); 676 | client.println("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); 677 | client.println("Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS"); 678 | client.println("Content-Type: text/html; charset=utf-8"); 679 | client.println("Access-Control-Allow-Origin: *"); 680 | client.println("Connection: close"); 681 | client.println(); 682 | 683 | String Data=""; 684 | if (cmd!="") 685 | Data = Feedback; 686 | else { 687 | Data = String((const char *)INDEX_HTML); 688 | } 689 | int Index; 690 | for (Index = 0; Index < Data.length(); Index = Index+1000) { 691 | client.print(Data.substring(Index, Index+1000)); 692 | } 693 | 694 | client.println(); 695 | } 696 | 697 | Feedback=""; 698 | break; 699 | } else { 700 | currentLine = ""; 701 | } 702 | } 703 | else if (c != '\r') { 704 | currentLine += c; 705 | } 706 | 707 | if ((currentLine.indexOf("/?")!=-1)&&(currentLine.indexOf(" HTTP")!=-1)) { 708 | if (Command.indexOf("stop")!=-1) { http://192.168.xxx.xxx/?cmd=aaa;bbb;ccc;stop 709 | client.println(); 710 | client.println(); 711 | client.stop(); 712 | } 713 | currentLine=""; 714 | Feedback=""; 715 | ExecuteCommand(); 716 | } 717 | } 718 | } 719 | delay(1); 720 | client.stop(); 721 | } 722 | } 723 | 724 | 725 | void getCommand(char c) 726 | { 727 | if (c=='?') ReceiveState=1; 728 | if ((c==' ')||(c=='\r')||(c=='\n')) ReceiveState=0; 729 | 730 | if (ReceiveState==1) 731 | { 732 | Command=Command+String(c); 733 | 734 | if (c=='=') cmdState=0; 735 | if (c==';') strState++; 736 | 737 | if ((cmdState==1)&&((c!='?')||(questionstate==1))) cmd=cmd+String(c); 738 | if ((cmdState==0)&&(strState==1)&&((c!='=')||(equalstate==1))) P1=P1+String(c); 739 | if ((cmdState==0)&&(strState==2)&&(c!=';')) P2=P2+String(c); 740 | if ((cmdState==0)&&(strState==3)&&(c!=';')) P3=P3+String(c); 741 | if ((cmdState==0)&&(strState==4)&&(c!=';')) P4=P4+String(c); 742 | if ((cmdState==0)&&(strState==5)&&(c!=';')) P5=P5+String(c); 743 | if ((cmdState==0)&&(strState==6)&&(c!=';')) P6=P6+String(c); 744 | if ((cmdState==0)&&(strState==7)&&(c!=';')) P7=P7+String(c); 745 | if ((cmdState==0)&&(strState==8)&&(c!=';')) P8=P8+String(c); 746 | if ((cmdState==0)&&(strState>=9)&&((c!=';')||(semicolonstate==1))) P9=P9+String(c); 747 | 748 | if (c=='?') questionstate=1; 749 | if (c=='=') equalstate=1; 750 | if ((strState>=9)&&(c==';')) semicolonstate=1; 751 | } 752 | } 753 | 754 | String tcp_http(String domain,String request,int port,byte wait) 755 | { 756 | WiFiClient client_tcp; 757 | 758 | if (client_tcp.connect(domain.c_str(), port)) 759 | { 760 | Serial.println("GET " + request); 761 | client_tcp.println("GET " + request + " HTTP/1.1"); 762 | client_tcp.println("Host: " + domain); 763 | client_tcp.println("Connection: close"); 764 | client_tcp.println(); 765 | 766 | String getResponse="",Feedback=""; 767 | boolean state = false; 768 | int waitTime = 3000; // timeout 3 seconds 769 | long startTime = millis(); 770 | while ((startTime + waitTime) > millis()) 771 | { 772 | while (client_tcp.available()) 773 | { 774 | char c = client_tcp.read(); 775 | if (state==true) Feedback += String(c); 776 | if (c == '\n') 777 | { 778 | if (getResponse.length()==0) state=true; 779 | getResponse = ""; 780 | } 781 | else if (c != '\r') 782 | getResponse += String(c); 783 | if (wait==1) 784 | startTime = millis(); 785 | } 786 | if (wait==0) 787 | if ((state==true)&&(Feedback.length()!= 0)) break; 788 | } 789 | client_tcp.stop(); 790 | return Feedback; 791 | } 792 | else 793 | return "Connection failed"; 794 | } 795 | 796 | String tcp_https(String domain,String request,int port,byte wait) 797 | { 798 | WiFiClientSecure client_tcp; 799 | client_tcp.setInsecure(); //run version 1.0.5 or above 800 | 801 | if (client_tcp.connect(domain.c_str(), port)) 802 | { 803 | Serial.println("GET " + request); 804 | client_tcp.println("GET " + request + " HTTP/1.1"); 805 | client_tcp.println("Host: " + domain); 806 | client_tcp.println("Connection: close"); 807 | client_tcp.println(); 808 | 809 | String getResponse="",Feedback=""; 810 | boolean state = false; 811 | int waitTime = 3000; // timeout 3 seconds 812 | long startTime = millis(); 813 | while ((startTime + waitTime) > millis()) 814 | { 815 | while (client_tcp.available()) 816 | { 817 | char c = client_tcp.read(); 818 | if (state==true) Feedback += String(c); 819 | if (c == '\n') 820 | { 821 | if (getResponse.length()==0) state=true; 822 | getResponse = ""; 823 | } 824 | else if (c != '\r') 825 | getResponse += String(c); 826 | if (wait==1) 827 | startTime = millis(); 828 | } 829 | if (wait==0) 830 | if ((state==true)&&(Feedback.length()!= 0)) break; 831 | } 832 | client_tcp.stop(); 833 | return Feedback; 834 | } 835 | else 836 | return "Connection failed"; 837 | } 838 | 839 | String LineNotify(String token, String request, byte wait) 840 | { 841 | request.replace("%","%25"); 842 | request.replace(" ","%20"); 843 | request.replace("&","%20"); 844 | request.replace("#","%20"); 845 | //request.replace("\'","%27"); 846 | request.replace("\"","%22"); 847 | request.replace("\n","%0D%0A"); 848 | request.replace("%3Cbr%3E","%0D%0A"); 849 | request.replace("%3Cbr/%3E","%0D%0A"); 850 | request.replace("%3Cbr%20/%3E","%0D%0A"); 851 | request.replace("%3CBR%3E","%0D%0A"); 852 | request.replace("%3CBR/%3E","%0D%0A"); 853 | request.replace("%3CBR%20/%3E","%0D%0A"); 854 | request.replace("%20stickerPackageId","&stickerPackageId"); 855 | request.replace("%20stickerId","&stickerId"); 856 | 857 | WiFiClientSecure client_tcp; 858 | client_tcp.setInsecure(); //run version 1.0.5 or above 859 | 860 | if (client_tcp.connect("notify-api.line.me", 443)) 861 | { 862 | client_tcp.println("POST /api/notify HTTP/1.1"); 863 | client_tcp.println("Connection: close"); 864 | client_tcp.println("Host: notify-api.line.me"); 865 | client_tcp.println("User-Agent: ESP8266/1.0"); 866 | client_tcp.println("Authorization: Bearer " + token); 867 | client_tcp.println("Content-Type: application/x-www-form-urlencoded"); 868 | client_tcp.println("Content-Length: " + String(request.length())); 869 | client_tcp.println(); 870 | client_tcp.println(request); 871 | client_tcp.println(); 872 | 873 | String getResponse="",Feedback=""; 874 | boolean state = false; 875 | int waitTime = 3000; // timeout 3 seconds 876 | long startTime = millis(); 877 | while ((startTime + waitTime) > millis()) 878 | { 879 | while (client_tcp.available()) 880 | { 881 | char c = client_tcp.read(); 882 | if (state==true) Feedback += String(c); 883 | if (c == '\n') 884 | { 885 | if (getResponse.length()==0) state=true; 886 | getResponse = ""; 887 | } 888 | else if (c != '\r') 889 | getResponse += String(c); 890 | if (wait==1) 891 | startTime = millis(); 892 | } 893 | if (wait==0) 894 | if ((state==true)&&(Feedback.length()!= 0)) break; 895 | } 896 | client_tcp.stop(); 897 | return Feedback; 898 | } 899 | else 900 | return "Connection failed"; 901 | } 902 | 903 | String sendCapturedImageToLineNotify(String token) 904 | { 905 | String getAll="", getBody = ""; 906 | 907 | camera_fb_t * fb = NULL; 908 | fb = esp_camera_fb_get(); 909 | if(!fb) { 910 | Serial.println("Camera capture failed"); 911 | delay(1000); 912 | ESP.restart(); 913 | return ""; 914 | } 915 | 916 | WiFiClientSecure client_tcp; 917 | client_tcp.setInsecure(); //run version 1.0.5 or above 918 | 919 | Serial.println("Connect to notify-api.line.me"); 920 | 921 | if (client_tcp.connect("notify-api.line.me", 443)) { 922 | Serial.println("Connection successful"); 923 | 924 | String message = "Welcome to Taiwan."; 925 | String head = "--Taiwan\r\nContent-Disposition: form-data; name=\"message\"; \r\n\r\n" + message + "\r\n--Taiwan\r\nContent-Disposition: form-data; name=\"imageFile\"; filename=\"esp32-cam.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n"; 926 | String tail = "\r\n--Taiwan--\r\n"; 927 | 928 | uint16_t imageLen = fb->len; 929 | uint16_t extraLen = head.length() + tail.length(); 930 | uint16_t totalLen = imageLen + extraLen; 931 | 932 | client_tcp.println("POST /api/notify HTTP/1.1"); 933 | client_tcp.println("Connection: close"); 934 | client_tcp.println("Host: notify-api.line.me"); 935 | client_tcp.println("Authorization: Bearer " + token); 936 | client_tcp.println("Content-Length: " + String(totalLen)); 937 | client_tcp.println("Content-Type: multipart/form-data; boundary=Taiwan"); 938 | client_tcp.println(); 939 | client_tcp.print(head); 940 | 941 | uint8_t *fbBuf = fb->buf; 942 | size_t fbLen = fb->len; 943 | for (size_t n=0;n0) { 949 | size_t remainder = fbLen%1024; 950 | client_tcp.write(fbBuf, remainder); 951 | } 952 | } 953 | 954 | client_tcp.print(tail); 955 | esp_camera_fb_return(fb); 956 | 957 | int waitTime = 10000; // timeout 10 seconds 958 | long startTime = millis(); 959 | boolean state = false; 960 | while ((startTime + waitTime) > millis()) 961 | { 962 | Serial.print("."); 963 | delay(100); 964 | while (client_tcp.available()) 965 | { 966 | char c = client_tcp.read(); 967 | if (state==true) getBody += String(c); 968 | if (c == '\n') 969 | { 970 | if (getAll.length()==0) state=true; 971 | getAll = ""; 972 | } 973 | else if (c != '\r') 974 | getAll += String(c); 975 | startTime = millis(); 976 | } 977 | if (getBody.length()>0) break; 978 | } 979 | client_tcp.stop(); 980 | //Serial.println(getAll); 981 | Serial.println(getBody); 982 | } 983 | else { 984 | getAll="Connected to notify-api.line.me failed."; 985 | getBody="Connected to notify-api.line.me failed."; 986 | Serial.println("Connected to notify-api.line.me failed."); 987 | } 988 | 989 | //return getAll; 990 | return getBody; 991 | } 992 | -------------------------------------------------------------------------------- /ObjectDetection_ESP32cam/__vm/Configuration.Release.vmps.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ObjectDetection_ESP32cam/__vm/Compile.vmps.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ObjectDetection_ESP32cam/__vm/Upload.vmps.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | --------------------------------------------------------------------------------