├── .gitignore ├── .gitlab-ci.yml ├── .gitmodules ├── CHANGELOG.md ├── LICENSE ├── README.md ├── components ├── component_conf.mk ├── esp-sr │ ├── CMakeLists.txt │ ├── Makefile │ ├── acoustic_algorithm │ │ ├── component.mk │ │ ├── include │ │ │ ├── esp_aec.h │ │ │ ├── esp_agc.h │ │ │ ├── esp_ns.h │ │ │ └── esp_vad.h │ │ └── libesp_audio_processor.a │ ├── component.mk │ ├── dummy.c │ ├── lib │ │ ├── component.mk │ │ ├── include │ │ │ ├── dl_lib.h │ │ │ ├── dl_lib_coefgetter_if.h │ │ │ ├── dl_lib_conv_queue.h │ │ │ ├── dl_lib_convq_queue.h │ │ │ ├── dl_lib_matrix.h │ │ │ └── dl_lib_matrixq.h │ │ ├── libc_speech_features.a │ │ ├── libdl_lib_sr.a │ │ └── libwakenet.a │ └── wake_word_engine │ │ ├── component.mk │ │ ├── include │ │ ├── esp_wn_iface.h │ │ ├── esp_wn_models.h │ │ └── hilexin_wn5.h │ │ └── libhilexin_wn5.a ├── esp32-camera │ ├── .gitignore │ ├── CMakeLists.txt │ ├── Kconfig │ ├── LICENSE │ ├── README.md │ ├── component.mk │ ├── conversions │ │ ├── esp_jpg_decode.c │ │ ├── include │ │ │ ├── esp_jpg_decode.h │ │ │ └── img_converters.h │ │ ├── jpge.cpp │ │ ├── private_include │ │ │ ├── jpge.h │ │ │ └── yuv.h │ │ ├── to_bmp.c │ │ ├── to_jpg.cpp │ │ └── yuv.c │ ├── driver │ │ ├── camera.c │ │ ├── include │ │ │ ├── esp_camera.h │ │ │ └── sensor.h │ │ ├── private_include │ │ │ ├── camera_common.h │ │ │ ├── sccb.h │ │ │ ├── twi.h │ │ │ └── xclk.h │ │ ├── sccb.c │ │ ├── sensor.c │ │ ├── twi.c │ │ └── xclk.c │ └── sensors │ │ ├── ov2640.c │ │ ├── ov3660.c │ │ ├── ov5640.c │ │ ├── ov7725.c │ │ └── private_include │ │ ├── ov2640.h │ │ ├── ov2640_regs.h │ │ ├── ov2640_settings.h │ │ ├── ov3660.h │ │ ├── ov3660_regs.h │ │ ├── ov3660_settings.h │ │ ├── ov5640.h │ │ ├── ov5640_regs.h │ │ ├── ov5640_settings.h │ │ ├── ov7725.h │ │ └── ov7725_regs.h └── fb_gfx │ ├── CMakeLists.txt │ ├── FreeMonoBold12pt7b.h │ ├── component.mk │ ├── fb_gfx.c │ └── include │ └── fb_gfx.h ├── docs ├── _static │ └── get-started │ │ ├── esp-eye_callout.png │ │ ├── face_id_enrollment_cn.jpg │ │ ├── face_id_enrollment_en.png │ │ ├── wifi_connection.jpeg │ │ ├── work_flow_cn.jpg │ │ └── work_flow_en.png ├── docs.png ├── en │ ├── Camera_connections.md │ └── get-started │ │ └── ESP-EYE_Getting_Started_Guide.md ├── zh_CN │ └── get-started │ │ └── ESP-EYE_Getting_Started_Guide.md └── 使用指南.docx ├── examples └── single_chip │ └── camera_web_server │ ├── 1.sh │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── main │ ├── CMakeLists.txt │ ├── Kconfig.projbuild │ ├── app_board.c │ ├── app_camera.c │ ├── app_httpd.c │ ├── app_main.c │ ├── app_mdns.c │ ├── app_sd.c │ ├── app_smart_wifi.c │ ├── app_uart.c │ ├── app_wifi.c │ ├── component.mk │ ├── include │ │ ├── app_at.h │ │ ├── app_board.h │ │ ├── app_camera.h │ │ ├── app_httpd.h │ │ ├── app_mdns.h │ │ ├── app_sd.h │ │ ├── app_smart_wifi.h │ │ ├── app_uart.h │ │ └── app_wifi.h │ └── www │ │ ├── compress_pages.sh │ │ ├── index_ov2640.html │ │ ├── index_ov2640.html.gz │ │ ├── index_ov3660.html │ │ ├── index_ov3660.html.gz │ │ ├── index_ov5640.html │ │ ├── index_ov5640.html.gz │ │ ├── monitor.html │ │ └── monitor.html.gz │ ├── partitions.csv │ └── sdkconfig.defaults ├── img ├── CAM5.jpg ├── cam.jpg ├── cam2.jpg ├── cam_uart.jpg ├── detected.png ├── enrollment.png ├── esp-wrover-kit.jpg ├── esp_eye_Wechat_cross.jpeg ├── esp_eye_Wechat_list.jpg ├── esp_eye_Wechat_network_configuration.jpg ├── esp_eye_wechat.jpg ├── esp_eye_wechat_qr.jpg ├── esp_wrover_kit_with_ov2640.png ├── no_matched.png ├── ov2640.jpg ├── overview.jpg ├── recognized.png ├── start_login.png └── start_recognition.png ├── os └── tools └── ci ├── build_examples.sh └── build_examples_cmake.sh /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | 3 | sdkconfig 4 | sdkconfig.old 5 | .DS_Store 6 | 7 | .vscode 8 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - build 3 | - deploy 4 | 5 | variables: 6 | # System environment 7 | 8 | # Common parameters for the 'make' during CI tests 9 | MAKEFLAGS: "-j5 --no-keep-going" 10 | 11 | # GitLab-CI environment 12 | 13 | # more attempts for more robust 14 | GET_SOURCES_ATTEMPTS: "10" 15 | ARTIFACT_DOWNLOAD_ATTEMPTS: "10" 16 | 17 | # We use get_sources.sh script to fetch the submodules and/or re-fetch the repo 18 | # if it was corrupted (if submodule update fails this can happen) 19 | GIT_STRATEGY: clone 20 | GIT_SUBMODULE_STRATEGY: none 21 | IDF_PATH: "$CI_PROJECT_DIR/esp-idf" 22 | 23 | before_script: 24 | # add gitlab ssh key 25 | - mkdir -p ~/.ssh 26 | - chmod 700 ~/.ssh 27 | - echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64 28 | - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa 29 | - chmod 600 ~/.ssh/id_rsa 30 | - echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config 31 | # replace submodule esp-idf to internal repository to speedup cloning 32 | - sed -i "s%https://github.com/espressif/esp-idf%${GITLAB_SSH_SERVER}/idf/esp-idf.git%" .gitmodules 33 | - sed -i "s%https://github.com/espressif/esp-face%${GITLAB_SSH_SERVER}/face-recognition-framework/esp-face.git%" .gitmodules 34 | - git submodule update --init 35 | # (the same regular expressions are used to set these are used in 'only:' sections below 36 | - source esp-idf/tools/ci/configure_ci_environment.sh 37 | 38 | # fetch the submodules (& if necessary re-fetch repo) from gitlab 39 | - time git submodule update --init --recursive 40 | 41 | - ./esp-idf/install.sh 42 | - . ./esp-idf/export.sh 43 | 44 | 45 | .add_gitlab_key_before: 46 | before_script: &add_gitlab_key_before 47 | - echo "Not fetching submodules" 48 | - source ${IDF_PATH}/tools/ci/configure_ci_environment.sh 49 | # add gitlab ssh key 50 | - mkdir -p ~/.ssh 51 | - chmod 700 ~/.ssh 52 | - echo -n $AUTO_KEY > ~/.ssh/id_rsa_base64 53 | - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa 54 | - chmod 600 ~/.ssh/id_rsa 55 | - echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config 56 | 57 | .build_template: &build_template 58 | stage: build 59 | image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG 60 | tags: 61 | - build 62 | variables: 63 | BATCH_BUILD: "1" 64 | V: "0" 65 | 66 | .build_examples_make_template: &build_examples_make_template 67 | <<: *build_template 68 | retry: 1 69 | artifacts: 70 | when: always 71 | paths: 72 | - build_examples_make/*/*/build/*.bin 73 | - build_examples_make/*/*/build/*.elf 74 | - build_examples_make/*/*/build/*.map 75 | - build_examples_make/*/*/build/bootloader/*.bin 76 | - ${LOG_PATH} 77 | - ${IDF_PATH}/tools/ci 78 | expire_in: 1 week 79 | variables: 80 | LOG_PATH: "$CI_PROJECT_DIR/log_examples_make" 81 | script: 82 | # it's not possible to build 100% out-of-tree and have the "artifacts" 83 | # mechanism work, but this is the next best thing 84 | - rm -rf build_examples_make 85 | - mkdir build_examples_make 86 | - cd build_examples_make 87 | - mkdir -p ${LOG_PATH} 88 | - ${CI_PROJECT_DIR}/tools/ci/build_examples.sh 89 | 90 | .build_examples_cmake_template: &build_examples_cmake_template 91 | <<: *build_template 92 | retry: 1 93 | artifacts: 94 | when: always 95 | paths: 96 | - build_examples_cmake/*/*/build/*.bin 97 | - build_examples_cmake/*/*/build/*.elf 98 | - build_examples_cmake/*/*/build/*.map 99 | - build_examples_cmake/*/*/*/build/flasher_args.json 100 | - build_examples_cmake/*/*/build/bootloader/*.bin 101 | - build_examples_cmake/*/*/build/partition_table/*.bin 102 | - ${LOG_PATH} 103 | - ${IDF_PATH}/tools/ci 104 | expire_in: 1 week 105 | variables: 106 | LOG_PATH: "$CI_PROJECT_DIR/log_examples_cmake" 107 | script: 108 | # it's not possible to build 100% out-of-tree and have the "artifacts" 109 | # mechanism work, but this is the next best thing 110 | - rm -rf build_examples_cmake 111 | - mkdir build_examples_cmake 112 | - cd build_examples_cmake 113 | - mkdir -p ${LOG_PATH} 114 | - ${CI_PROJECT_DIR}/tools/ci/build_examples_cmake.sh 115 | 116 | build_examples_make_00: 117 | <<: *build_examples_make_template 118 | 119 | build_examples_make_01: 120 | <<: *build_examples_make_template 121 | 122 | build_examples_cmake_00: 123 | <<: *build_examples_cmake_template 124 | 125 | build_examples_cmake_01: 126 | <<: *build_examples_cmake_template 127 | 128 | push_to_github: 129 | stage: deploy 130 | image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG 131 | tags: 132 | - deploy 133 | only: 134 | - master 135 | - /^release\/v/ 136 | when: on_success 137 | dependencies: 138 | - build_examples_make_00 139 | - build_examples_make_01 140 | - build_examples_cmake_00 141 | - build_examples_cmake_01 142 | before_script: 143 | - echo "skip default before_script" 144 | script: 145 | - mkdir -p ~/.ssh 146 | - chmod 700 ~/.ssh 147 | - echo -n $GH_PUSH_KEY > ~/.ssh/id_rsa_base64 148 | - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa 149 | - chmod 600 ~/.ssh/id_rsa 150 | - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config 151 | - git remote remove github &>/dev/null || true 152 | - git remote add github git@github.com:espressif/esp-who.git 153 | - ${IDF_PATH}/tools/ci/push_to_github.sh 154 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "esp-idf"] 2 | path = esp-idf 3 | url = https://github.com/espressif/esp-idf 4 | [submodule "components/esp-face"] 5 | path = components/esp-face 6 | url = https://github.com/espressif/esp-face 7 | [submodule "components/esp32-camera"] 8 | path = components/esp32-camera 9 | url = https://github.com/espressif/esp32-camera.git 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change log for esp-who 2 | 3 | ## 1.0.0 4 | - Feature of deep learning and image 5 | - Basic CNN 6 | - PRELU 7 | - Softmax 8 | - Global pool 9 | - Batch normalization 10 | - Depthwise convolution 11 | - Mobilenet 12 | - Quantization 13 | - Resize 14 | - Crop 15 | - NMS 16 | - Known issues 17 | - Recognition the same person while in different background 18 | 19 | 20 | ## 0.9.1 21 | - Add ip configuration 22 | - Minor bugfix 23 | 24 | ## 0.9.0 25 | Recognition solution for ESP-EYE 26 | - Support speech wake up 27 | - Support enrollment face id in flash 28 | - Bugfix: adjust for AI-Thinker 29 | 30 | ## 0.6.1 31 | Open source face detection and recognition forward process 32 | - Move forward process in the esp-face repository 33 | - Update readme 34 | 35 | ## 0.6.0 36 | Display images via Http 37 | - Add web server for camera and facial recognition 38 | - Add some documents for API reference and guide 39 | 40 | ## 0.5.0 41 | Initial commit, esp-who appear in the world. 42 | - Elementry functions such as image processing and matrix computing 43 | - Face detection 44 | - Face recognition 45 | - Components such as camera 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ESPRESSIF MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case, 6 | it is free of charge, to any person obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished 10 | to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all copies or 13 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/README.md -------------------------------------------------------------------------------- /components/component_conf.mk: -------------------------------------------------------------------------------- 1 | EXTRA_COMPONENT_DIRS += $(SOLUTION_PATH)/components 2 | EXTRA_COMPONENT_DIRS += $(SOLUTION_PATH)/components/esp-face/lib 3 | EXTRA_COMPONENT_DIRS += $(SOLUTION_PATH)/components/esp-face/image_util 4 | EXTRA_COMPONENT_DIRS += $(SOLUTION_PATH)/components/esp-face/face_detection 5 | EXTRA_COMPONENT_DIRS += $(SOLUTION_PATH)/components/esp-face/face_recognition 6 | EXTRA_COMPONENT_DIRS += $(SOLUTION_PATH)/components/esp-face/object_detection 7 | EXTRA_COMPONENT_DIRS += $(SOLUTION_PATH)/components/esp-sr/lib 8 | EXTRA_COMPONENT_DIRS += $(SOLUTION_PATH)/components/esp-sr/wake_word_engine 9 | EXTRA_COMPONENT_DIRS += $(SOLUTION_PATH)/components/esp-sr/acoustic_algorithm 10 | 11 | -------------------------------------------------------------------------------- /components/esp-sr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_SRCS dummy.c) 2 | set(COMPONENT_ADD_INCLUDEDIRS 3 | lib/include 4 | wake_word_engine/include 5 | acoustic_algorithm/include 6 | ) 7 | 8 | 9 | register_component() 10 | 11 | target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib") 12 | target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/wake_word_engine") 13 | target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/acoustic_algorithm") 14 | target_link_libraries(${COMPONENT_TARGET} 15 | esp_audio_processor 16 | hilexin_wn5 17 | wakenet 18 | c_speech_features 19 | dl_lib_sr 20 | ) 21 | -------------------------------------------------------------------------------- /components/esp-sr/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT_NAME := esp_sr 2 | 3 | MODULE_PATH := $(abspath $(shell pwd)) 4 | 5 | EXTRA_COMPONENT_DIRS += $(MODULE_PATH)/lib 6 | EXTRA_COMPONENT_DIRS += $(MODULE_PATH)/wake_word_engine 7 | EXTRA_COMPONENT_DIRS += $(MODULE_PATH)/acoustic_algorithm 8 | 9 | include $(IDF_PATH)/make/project.mk 10 | 11 | -------------------------------------------------------------------------------- /components/esp-sr/acoustic_algorithm/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS := include 2 | 3 | COMPONENT_SRCDIRS := . 4 | 5 | LIB_FILES := $(shell ls $(COMPONENT_PATH)/lib*.a) 6 | 7 | LIBS := $(patsubst lib%.a,-l%,$(notdir $(LIB_FILES))) 8 | 9 | COMPONENT_ADD_LDFLAGS += -L$(COMPONENT_PATH)/ $(LIBS) 10 | 11 | ALL_LIB_FILES += $(LIB_FILES) 12 | -------------------------------------------------------------------------------- /components/esp-sr/acoustic_algorithm/include/esp_aec.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License 14 | #ifndef _ESP_AEC_H_ 15 | #define _ESP_AEC_H_ 16 | 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #define USE_AEC_FFT // Not kiss_fft 24 | #define AEC_SAMPLE_RATE 16000 // Only Support 16000Hz 25 | #define AEC_FRAME_LENGTH_MS 16 // Only support 16ms 26 | #define AEC_FILTER_LENGTH 1200 // Number of samples of echo to cancel 27 | 28 | typedef void* aec_handle_t; 29 | 30 | /** 31 | * @brief Creates an instance to the AEC structure. 32 | * 33 | * @param sample_rate The Sampling frequency (Hz) can be 8000, 16000. 34 | * 35 | * @param frame_length The length of the audio processing can be 10ms, 20ms, 30ms, default: 30. 36 | * 37 | * @param filter_length Number of samples of echo to cancel. 38 | * 39 | * @return 40 | * - NULL: Create failed 41 | * - Others: The instance of AEC 42 | */ 43 | aec_handle_t aec_create(int sample_rate, int frame_length, int filter_length); 44 | 45 | 46 | /** 47 | * @brief Performs echo cancellation a frame, based on the audio sent to the speaker and frame from mic. 48 | * 49 | * @param inst The instance of AEC. 50 | * 51 | * @param indata An array of 16-bit signed audio samples from mic. 52 | * 53 | * @param refdata An array of 16-bit signed audio samples sent to the speaker. 54 | * 55 | * @param outdata Returns near-end signal with echo removed. 56 | * 57 | * @return None 58 | * 59 | */ 60 | void aec_process(aec_handle_t inst, int16_t *indata, int16_t *refdata, int16_t *outdata); 61 | 62 | /** 63 | * @brief Free the AEC instance 64 | * 65 | * @param inst The instance of AEC. 66 | * 67 | * @return None 68 | * 69 | */ 70 | void aec_destroy(aec_handle_t inst); 71 | 72 | #ifdef __cplusplus 73 | extern "C" { 74 | #endif 75 | 76 | #endif //_ESP_AEC_H_ 77 | -------------------------------------------------------------------------------- /components/esp-sr/acoustic_algorithm/include/esp_agc.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License 14 | #ifndef _ESP_AGC_H_ 15 | #define _ESP_AGC_H_ 16 | 17 | ////all positive value is valid, negective is error 18 | typedef enum { 19 | ESP_AGC_SUCCESS = 0, ////success 20 | ESP_AGC_FAIL = -1, ////agc fail 21 | ESP_AGC_SAMPLE_RATE_ERROR = -2, ///sample rate can be only 8khz, 16khz, 32khz 22 | ESP_AGC_FRAME_SIZE_ERROR = -3, ////the input frame size should be only 10ms, so should together with sample-rate to get the frame size 23 | } ESP_AGE_ERR; 24 | 25 | 26 | void *esp_agc_open(int agc_mode, int sample_rate); 27 | void set_agc_config(void *agc_handle, int gain_dB, int limiter_enable, int target_level_dbfs); 28 | int esp_agc_process(void *agc_handle, short *in_pcm, short *out_pcm, int frame_size, int sample_rate); 29 | void esp_agc_clse(void *agc_handle); 30 | 31 | #endif // _ESP_AGC_H_ 32 | -------------------------------------------------------------------------------- /components/esp-sr/acoustic_algorithm/include/esp_ns.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License 14 | #ifndef _ESP_NS_H_ 15 | #define _ESP_NS_H_ 16 | 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #define NS_FRAME_LENGTH_MS 30 //Supports 10ms, 20ms, 30ms 24 | 25 | /** 26 | * The Sampling frequency (Hz) must be 16000Hz 27 | */ 28 | 29 | typedef void* ns_handle_t; 30 | 31 | /** 32 | * @brief Creates an instance to the NS structure. 33 | * 34 | * @param frame_length_ms The length of the audio processing can be 10ms, 20ms, 30ms. 35 | * 36 | * @return 37 | * - NULL: Create failed 38 | * - Others: The instance of NS 39 | */ 40 | ns_handle_t ns_create(int frame_length_ms); 41 | 42 | /** 43 | * @brief Feed samples of an audio stream to the NS and get the audio stream after Noise suppression. 44 | * 45 | * @param inst The instance of NS. 46 | * 47 | * @param indata An array of 16-bit signed audio samples. 48 | * 49 | * @param outdata An array of 16-bit signed audio samples after noise suppression. 50 | * 51 | * @return None 52 | * 53 | */ 54 | void ns_process(ns_handle_t inst, int16_t *indata, int16_t *outdata); 55 | 56 | /** 57 | * @brief Free the NS instance 58 | * 59 | * @param inst The instance of NS. 60 | * 61 | * @return None 62 | * 63 | */ 64 | void ns_destroy(ns_handle_t inst); 65 | 66 | #ifdef __cplusplus 67 | extern "C" { 68 | #endif 69 | 70 | #endif //_ESP_NS_H_ 71 | -------------------------------------------------------------------------------- /components/esp-sr/acoustic_algorithm/include/esp_vad.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License 14 | #ifndef _ESP_VAD_H_ 15 | #define _ESP_VAD_H_ 16 | 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #define SAMPLE_RATE_HZ 16000 //Supports 32000, 16000, 8000 24 | #define VAD_FRAME_LENGTH_MS 30 //Supports 10ms, 20ms, 30ms 25 | 26 | /** 27 | * @brief Sets the VAD operating mode. A more aggressive (higher mode) VAD is more 28 | * restrictive in reporting speech. 29 | */ 30 | typedef enum { 31 | VAD_MODE_0 = 0, 32 | VAD_MODE_1, 33 | VAD_MODE_2, 34 | VAD_MODE_3, 35 | VAD_MODE_4 36 | } vad_mode_t; 37 | 38 | typedef enum { 39 | VAD_SILENCE = 0, 40 | VAD_SPEECH 41 | } vad_state_t; 42 | 43 | typedef void* vad_handle_t; 44 | 45 | /** 46 | * @brief Creates an instance to the VAD structure. 47 | * 48 | * @param vad_mode Sets the VAD operating mode. 49 | * 50 | * @param sample_rate_hz The Sampling frequency (Hz) can be 32000, 16000, 8000, default: 16000. 51 | * 52 | * @param one_frame_ms The length of the audio processing can be 10ms, 20ms, 30ms, default: 30. 53 | * 54 | * @return 55 | * - NULL: Create failed 56 | * - Others: The instance of VAD 57 | */ 58 | vad_handle_t vad_create(vad_mode_t vad_mode, int sample_rate_hz, int one_frame_ms); 59 | 60 | /** 61 | * @brief Feed samples of an audio stream to the VAD and check if there is someone speaking. 62 | * 63 | * @param inst The instance of VAD. 64 | * 65 | * @param data An array of 16-bit signed audio samples. 66 | * 67 | * @return 68 | * - VAD_SILENCE if no voice 69 | * - VAD_SPEECH if voice is detected 70 | * 71 | */ 72 | vad_state_t vad_process(vad_handle_t inst, int16_t *data); 73 | 74 | /** 75 | * @brief Free the VAD instance 76 | * 77 | * @param inst The instance of VAD. 78 | * 79 | * @return None 80 | * 81 | */ 82 | void vad_destroy(vad_handle_t inst); 83 | 84 | /* 85 | * Programming Guide: 86 | * 87 | * @code{c} 88 | * vad_handle_t vad_inst = vad_create(VAD_MODE_3, SAMPLE_RATE_HZ, VAD_FRAME_LENGTH_MS); // Creates an instance to the VAD structure. 89 | * 90 | * while (1) { 91 | * //Use buffer to receive the audio data from MIC. 92 | * vad_state_t vad_state = vad_process(vad_inst, buffer); // Feed samples to the VAD process and get the result. 93 | * } 94 | * 95 | * vad_destroy(vad_inst); // Free the VAD instance at the end of whole VAD process 96 | * 97 | * @endcode 98 | */ 99 | 100 | #ifdef __cplusplus 101 | extern "C" { 102 | #endif 103 | 104 | #endif //_ESP_VAD_H_ 105 | -------------------------------------------------------------------------------- /components/esp-sr/acoustic_algorithm/libesp_audio_processor.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/components/esp-sr/acoustic_algorithm/libesp_audio_processor.a -------------------------------------------------------------------------------- /components/esp-sr/component.mk: -------------------------------------------------------------------------------- 1 | 2 | COMPONENT_ADD_INCLUDEDIRS := lib/include \ 3 | wake_word_engine/include \ 4 | acoustic_algorithm/include \ 5 | 6 | 7 | LIB_FILES := $(shell ls $(COMPONENT_PATH)/wake_word_engine/lib*.a) \ 8 | $(shell ls $(COMPONENT_PATH)/lib/lib*.a) \ 9 | $(shell ls $(COMPONENT_PATH)/acoustic_algorithm/lib*.a) \ 10 | 11 | LIBS := $(patsubst lib%.a,-l%,$(LIB_FILES)) 12 | 13 | COMPONENT_ADD_LDFLAGS += -L$(COMPONENT_PATH)/lib \ 14 | -L$(COMPONENT_PATH)/wake_word_engine \ 15 | -L$(COMPONENT_PATH)/acoustic_algorithm \ 16 | $(LIBS) 17 | -------------------------------------------------------------------------------- /components/esp-sr/dummy.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/components/esp-sr/dummy.c -------------------------------------------------------------------------------- /components/esp-sr/lib/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS := include 2 | 3 | COMPONENT_SRCDIRS := . 4 | 5 | LIB_FILES := $(shell ls $(COMPONENT_PATH)/lib*.a) 6 | 7 | LIBS := $(patsubst lib%.a,-l%,$(notdir $(LIB_FILES))) 8 | 9 | COMPONENT_ADD_LDFLAGS += -L$(COMPONENT_PATH)/ $(LIBS) 10 | 11 | ALL_LIB_FILES += $(LIB_FILES) 12 | -------------------------------------------------------------------------------- /components/esp-sr/lib/include/dl_lib_coefgetter_if.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef DL_LIB_COEFGETTER_IF_H 15 | #define DL_LIB_COEFGETTER_IF_H 16 | 17 | #include "dl_lib_matrix.h" 18 | #include "dl_lib_matrixq.h" 19 | 20 | //Set this if the coefficient requested is a batch-normalization popvar matrix which needs to be preprocessed by 21 | //dl_batch_normalize_get_sqrtvar first. 22 | #define COEF_GETTER_HINT_BNVAR (1<<0) 23 | 24 | /* 25 | This struct describes the basic information of model data: 26 | word_num: the number of wake words or speech commands 27 | word_list: the name list of wake words or speech commands 28 | thres_list: the threshold list of wake words or speech commands 29 | info_str: the string used to reflect the version and information of model data 30 | which consist of the architecture of network, the version of model data, wake words and their threshold 31 | */ 32 | typedef struct { 33 | int word_num; 34 | char **word_list; 35 | int *win_list; 36 | float *thresh_list; 37 | char *info_str; 38 | } model_info_t; 39 | 40 | /* 41 | Alphabet struct describes the basic grapheme or phoneme. 42 | item_num: the number of baisc item(grapheme or phonemr) 43 | items: the list of basic item 44 | */ 45 | typedef struct { 46 | int item_num; 47 | char **items; 48 | }alphabet_t; 49 | 50 | /* 51 | This struct describes a generic coefficient getter: a way to get the constant coefficients needed for a neural network. 52 | For the two getters, the name describes the name of the coefficient matrix, usually the same as the Numpy filename the 53 | coefficient was originally stored in. The arg argument can be used to optionally pass an additional user-defined argument 54 | to the getter (e.g. the directory to look for files in the case of the Numpy file loader getter). The hint argument 55 | is a bitwise OR of the COEF_GETTER_HINT_* flags or 0 when none is needed. Use the free_f/free_q functions to release the 56 | memory for the returned matrices, when applicable. 57 | */ 58 | typedef struct { 59 | const dl_matrix2d_t* (*getter_f)(const char *name, void *arg, int hint); 60 | const dl_matrix2dq_t* (*getter_q)(const char *name, void *arg, int hint); 61 | void (*free_f)(const dl_matrix2d_t *m); 62 | void (*free_q)(const dl_matrix2dq_t *m); 63 | const model_info_t* (*getter_info)(void *arg); 64 | const alphabet_t* (*getter_alphabet)(void *arg); 65 | } model_coeff_getter_t; 66 | 67 | #endif -------------------------------------------------------------------------------- /components/esp-sr/lib/include/dl_lib_conv_queue.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef DL_LIB_CONV_QUEUE_H 15 | #define DL_LIB_CONV_QUEUE_H 16 | 17 | 18 | #include "dl_lib_matrix.h" 19 | typedef float fptp_t; 20 | 21 | 22 | //Flags for matrices 23 | #define DL_MF_FOREIGNDATA (1<<0) /*< Matrix *item data actually points to another matrix and should not be freed */ 24 | 25 | //Float convolution FIFO queue. 26 | typedef struct { 27 | int n; /*< the length of queue */ 28 | int c; /*< the channel number of queue element*/ 29 | int front; /*< the front(top) position of queue */ 30 | int flag; /*< not used*/ 31 | fptp_t *item; /*< Pointer to item array */ 32 | } dl_conv_queue_t; 33 | 34 | /** 35 | * @brief Allocate a convolution queue 36 | * 37 | * @param n The length of queue 38 | * @param c The channel number of elements in the queue 39 | * @return The convolution queue, or NULL if out of memory 40 | */ 41 | dl_conv_queue_t *dl_conv_queue_alloc(int n, int c); 42 | 43 | /** 44 | * @brief Free a convolution queue 45 | * 46 | * @param cq The convolution queue to free 47 | */ 48 | void dl_conv_queue_free(dl_conv_queue_t *cq); 49 | 50 | void dl_conv_to_matrix2d(dl_conv_queue_t *cq, dl_matrix2d_t* out); 51 | 52 | /** 53 | * @brief Move the front pointer of queue forward, 54 | the First(oldest) element become the last(newest) element, 55 | * 56 | * @param cq Input convolution queue 57 | * @return Pointer of oldest element 58 | */ 59 | fptp_t *dl_conv_queue_pop(dl_conv_queue_t *cq); 60 | 61 | /** 62 | * @brief Remove the oldest element, then insert the input element at the end of queue 63 | * 64 | * @param cq Input convolution queue 65 | * @param item The new element 66 | */ 67 | void dl_conv_queue_push(dl_conv_queue_t *cq, fptp_t* item); 68 | 69 | 70 | /** 71 | * @brief Get the pointer of element in the queue by offset 72 | * 73 | * @param cq Input convolution queue 74 | * @param offset Offset from the front of the queue 75 | * @return Pointer of the element 76 | */ 77 | fptp_t *dl_get_queue_item(dl_conv_queue_t *cq, int offset); 78 | 79 | /** 80 | * @brief Does a sigmoid operation on the one of element in the convolution queue. 81 | * Gets the pointer of element in the convolution queue by offset, and does a sigmoid operation 82 | * by this pointer, then return the pointer 83 | * 84 | * @param cq Input convolution queue 85 | * @param offset Offset from the front of the queue 86 | * @return Pointer of the element 87 | */ 88 | fptp_t *dl_sigmoid_step(dl_conv_queue_t *cq, int offset); 89 | 90 | /** 91 | * @brief Does a tanh operation on the one of element in the convolution queue. 92 | * Gets the pointer of element in the convolution queue by offset, and does a tanh operation 93 | * by this pointer, then return the pointer 94 | * 95 | * @param cq Input convolution queue 96 | * @param offset Offset from the front of the queue 97 | * @return Pointer of the element 98 | */ 99 | fptp_t *dl_tanh_step(dl_conv_queue_t *cq, int offset); 100 | 101 | /** 102 | * @brief Does a softmax operation on the one of element in the convolution queue. 103 | * Gets the pointer of element in the convolution queue by offset, and does a softmax operation 104 | * by this pointer, then return the pointer 105 | * 106 | * @param cq Input convolution queue 107 | * @param offset Offset from the front of the queue 108 | * @return Pointer of the element 109 | */ 110 | fptp_t *dl_softmax_step(dl_conv_queue_t *cq, int offset); 111 | 112 | fptp_t *dl_relu_step(dl_conv_queue_t *cq, int offset); 113 | fptp_t *dl_relu_look(dl_matrix2d_t *cq, int offset); 114 | dl_matrix2d_t *dl_matrix_concat1(const dl_conv_queue_t *a, const dl_matrix2d_t *b); 115 | dl_matrix2d_t *dl_basic_lstm_layer1(const dl_conv_queue_t *in, dl_matrix2d_t *state_c, dl_matrix2d_t *state_h, 116 | const dl_matrix2d_t *weight, const dl_matrix2d_t *bias); 117 | /** 118 | * @brief Fast implement for 1D atrous convolution (a.k.a. convolution with holes or dilated convolution) 119 | * based on convolution queue. 120 | * 121 | * @Warning All input and output convolution queue and matrix should be allocated. The return pointer 122 | * is first element of output queue and should not be freed separately. 123 | * 124 | * @param in Input convolution queue 125 | * @param out Output convolution queue 126 | * @param rate A positive int, the stride with which we sample input value 127 | * @param size A positive int, the size of 1D-filter 128 | * @param kernel The kernel matrix of filter 129 | * @param bias The bias matrix of filter. Can be NULL if a bias of 0 is required. 130 | * @return The result of atrous convolution 131 | */ 132 | fptp_t *dl_atrous_conv1d_step(dl_conv_queue_t *in, dl_conv_queue_t *out, int rate, int size, 133 | dl_matrix2d_t* kernel, dl_matrix2d_t* bias); 134 | fptp_t *dl_look_conv_step(dl_conv_queue_t *in, dl_matrix2d_t *out, int rate, int size, 135 | dl_matrix2d_t* kernel, dl_matrix2d_t* bias); 136 | 137 | /** 138 | * @brief Fast implement of dilation layer as follows 139 | * 140 | * |-> [gate(sigmoid)] -| 141 | * input - | |-> (*) - output 142 | * |-> [filter(tanh)] -| 143 | * 144 | * @Warning All input and output convolution queue and matrix should be allocated. The return pointer 145 | * is first element of output queue and should not be freed separately. 146 | * 147 | * @param in Input convolution queue 148 | * @param out Output convolution queue 149 | * @param rate A positive int, the stride with which we sample input value 150 | * @param size A positive int, the size of 1D-filter 151 | * @param filter_kernel The kernel matrix of filter 152 | * @param filter_bias The bias matrix of filter. Can be NULL if a bias of 0 is required. 153 | * @param gate_kernel The kernel matrix of gate 154 | * @param gate_bias The bias matrix of gate. Can be NULL if a bias of 0 is required. 155 | * @return The result of dilation layer 156 | */ 157 | fptp_t *dl_dilation_layer(dl_conv_queue_t *in, dl_conv_queue_t *out, int rate, int size, 158 | dl_matrix2d_t* filter_kernel, dl_matrix2d_t* filter_bias, 159 | dl_matrix2d_t* gate_kernel, dl_matrix2d_t* gate_bias); 160 | 161 | 162 | void test_atrous_conv(int size, int rate, int in_channel, int out_channel); 163 | 164 | #endif -------------------------------------------------------------------------------- /components/esp-sr/lib/include/dl_lib_convq_queue.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef DL_LIB_CONVQ_QUEUE_H 15 | #define DL_LIB_CONVQ_QUEUE_H 16 | 17 | 18 | #include "dl_lib_matrixq.h" 19 | #include "dl_lib_conv_queue.h" 20 | 21 | //fixed-point convolution FIFO queue. 22 | typedef struct { 23 | int n; /*< the length of queue */ 24 | int c; /*< the channel number of queue element*/ 25 | int front; /*< the front(top) position of queue */ 26 | int flag; /*< not used */ 27 | int exponent; /*< The values in items should be multiplied by pow(2,exponent) 28 | to get the real values */ 29 | qtp_t *itemq; /*< Pointer to item array */ 30 | } dl_convq_queue_t; 31 | 32 | /** 33 | * @brief Allocate a fixed-point convolution queue 34 | * 35 | * @param n The length of queue 36 | * @param c The channel number of elements in the queue 37 | * @return The convolution queue, or NULL if out of memory 38 | */ 39 | dl_convq_queue_t *dl_convq_queue_alloc(int n, int c); 40 | 41 | void dl_convq_to_matrix2dq(dl_convq_queue_t *cq, dl_matrix2dq_t* out, int row); 42 | 43 | /** 44 | * @brief Free a fixed-point convolution queue 45 | * 46 | * @param cq The fixed-point convolution queue to free 47 | */ 48 | void dl_convq_queue_free(dl_convq_queue_t *cq); 49 | 50 | /** 51 | * @brief Move the front pointer of queue forward, 52 | the First(oldest) element become the last(newest) element, 53 | * 54 | * @param cq Input fixed-point convolution queue 55 | * @return Pointer of oldest element 56 | */ 57 | qtp_t *dl_convq_queue_pop(dl_convq_queue_t *cq); 58 | 59 | /** 60 | * @brief Remove the oldest element, then insert the input element at the end of queue 61 | * 62 | * @param cq Input fixed-point convolution queue 63 | * @param item The new element 64 | */ 65 | void dl_convq_queue_push(dl_convq_queue_t *cq, dl_matrix2dq_t *a, int shift); 66 | 67 | /** 68 | * @brief Insert the float-point element at the end of queue. 69 | * The precision of fixed-point numbers is described by the Qm.f notation, 70 | * 71 | * @param cq Input fixed-point convolution queue 72 | * @param item The float-point element 73 | * @param m_bit The number of integer bits including the sign bits 74 | * @param f_bit The number of fractional bits 75 | */ 76 | void dl_convq_queue_push_by_qmf(dl_convq_queue_t *cq, fptp_t* item, int m_bit, int f_bit); 77 | 78 | /** 79 | * @brief Get the pointer of element in the queue by offset 80 | * 81 | * @param cq Input fixed-point convolution queue 82 | * @param offset Offset from the front of the queue 83 | * @return Pointer of the element 84 | */ 85 | qtp_t *dl_get_queue_itemq(dl_convq_queue_t *cq, int offset); 86 | 87 | /** 88 | * @brief Does a tanh operation on the one of element in the convolution queue. 89 | * Gets the pointer of element in the convolution queue by offset, and does a 90 | * tanh operation by this pointer, then return the pointer 91 | * 92 | * @param cq Input fixed-point convolution queue 93 | * @param offset Offset from the front of the queue 94 | * @return Pointer of the element 95 | */ 96 | void dl_tanh_convq(dl_convq_queue_t *cq, int last_num); 97 | 98 | /** 99 | * @brief Does a relu operation on the one of element in the convolution queue. 100 | * Gets the pointer of element in the convolution queue by offset, and does a 101 | * relu operation by this pointer, then return the pointer 102 | * 103 | * @param cq Input fixed-point convolution queue 104 | * @param offset Offset from the front of the queue 105 | * @return Pointer of the element 106 | */ 107 | void dl_relu_convq(dl_convq_queue_t *cq, fptp_t clip, int last_num); 108 | 109 | /** 110 | * @brief Does a softmax operation on the one of element in the convolution queue. 111 | * Gets the pointer of element in the convolution queue by offset, input data 112 | stay as it is. Results are saved into the *out* array. 113 | * 114 | * @param cq Input fixed-point convolution queue 115 | * @param offset Offset from the front of the queue 116 | * @param out Old array to re-use. Passing NULL will allocate a new matrix. 117 | * @return softmax results 118 | */ 119 | fptp_t * dl_softmax_step_q(dl_convq_queue_t *cq, int offset, fptp_t *out); 120 | 121 | /** 122 | * @brief Fast and quantised implement for 1D atrous convolution (a.k.a. convolution with holes or dilated convolution) 123 | * based on convolution queue. 124 | * 125 | * @Warning All input and output convolution queue and matrix should be allocated. The return pointer 126 | * is last element of output queue and should not be freed separately. 127 | * 128 | * @param in Input fixed-point convolution queue 129 | * @param out Output fixed-point convolution queue 130 | * @param rate A positive int, the stride with which we sample input value 131 | * @param size A positive int, the size of 1D-filter 132 | * @param kernel The kernel matrix of filter 133 | * @param bias The bias matrix of filter. Can be NULL if a bias of 0 is required. 134 | * @param shift Shift ratio used in dot operation between two 16-bit fixed point vector 135 | * @return The result of atrous convolution 136 | */ 137 | qtp_t *dl_atrous_conv1dq(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size, 138 | dl_matrix2dq_t* kernel, dl_matrix2dq_t* bias, int shift); 139 | qtp_t *dl_atrous_conv1dq_steps(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size, 140 | dl_matrix2dq_t* kernel, dl_matrix2dq_t* bias, int shift, int offset); 141 | /** 142 | * @brief Fast implement of dilation layer as follows 143 | * 144 | * |-> [gate(sigmoid)] -| 145 | * input - | |-> (*) - output 146 | * |-> [filter(tanh)] -| 147 | * 148 | * @Warning All input and output convolution queue and matrix should be allocated. The return pointer 149 | * is last element of output queue and should not be freed separately. 150 | * 151 | * @param in Input fixed-point convolution queue 152 | * @param out Output fixed-point convolution queue 153 | * @param rate A positive int, the stride with which we sample input value 154 | * @param size A positive int, the size of 1D-filter 155 | * @param filter_kernel The kernel matrix of filter 156 | * @param filter_bias The bias matrix of filter. Can be NULL if a bias of 0 is required. 157 | * @param gate_kernel The kernel matrix of gate 158 | * @param gate_bias The bias matrix of gate. Can be NULL if a bias of 0 is required. 159 | * @filter_shift Shift ratio used in filter operation between two 16-bit fixed point vector 160 | * @gate_shift Shift ratio used in gate operation between two 16-bit fixed point vector 161 | * @return The result of dilation layer 162 | */ 163 | qtp_t *dl_dilation_layerq(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size, 164 | dl_matrix2dq_t* filter_kernel, dl_matrix2dq_t* filter_bias, 165 | dl_matrix2dq_t* gate_kernel, dl_matrix2dq_t* gate_bias, 166 | int filter_shift, int gate_shift); 167 | 168 | dl_matrix2dq_t *dl_basic_lstm_layer1_q(const dl_convq_queue_t *in, dl_matrix2dq_t *state_c, dl_matrix2dq_t *state_h, 169 | const dl_matrix2dq_t *weight, const dl_matrix2dq_t *bias, int step, int shift); 170 | void test_atrous_convq(int size, int rate, int in_channel, int out_channel); 171 | 172 | dl_conv_queue_t *dl_convq_queue_add(dl_convq_queue_t *cq1, dl_convq_queue_t *cq2); 173 | 174 | #endif -------------------------------------------------------------------------------- /components/esp-sr/lib/libc_speech_features.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/components/esp-sr/lib/libc_speech_features.a -------------------------------------------------------------------------------- /components/esp-sr/lib/libdl_lib_sr.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/components/esp-sr/lib/libdl_lib_sr.a -------------------------------------------------------------------------------- /components/esp-sr/lib/libwakenet.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/components/esp-sr/lib/libwakenet.a -------------------------------------------------------------------------------- /components/esp-sr/wake_word_engine/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS := include 2 | 3 | COMPONENT_SRCDIRS := . 4 | 5 | LIB_FILES := $(shell ls $(COMPONENT_PATH)/lib*.a) 6 | 7 | LIBS := $(patsubst lib%.a,-l%,$(notdir $(LIB_FILES))) 8 | 9 | COMPONENT_ADD_LDFLAGS += -L$(COMPONENT_PATH)/ $(LIBS) 10 | 11 | ALL_LIB_FILES += $(LIB_FILES) 12 | -------------------------------------------------------------------------------- /components/esp-sr/wake_word_engine/include/esp_wn_iface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "stdint.h" 3 | #include "dl_lib_coefgetter_if.h" 4 | 5 | //Opaque model data container 6 | typedef struct model_iface_data_t model_iface_data_t; 7 | 8 | //Set wake words recognition operating mode 9 | //The probability of being wake words is increased with increasing mode, 10 | //As a consequence also the false alarm rate goes up 11 | typedef enum { 12 | DET_MODE_90 = 0, //Normal, response accuracy rate about 90% 13 | DET_MODE_95 //Aggressive, response accuracy rate about 95% 14 | } det_mode_t; 15 | 16 | typedef struct { 17 | int wake_word_num; //The number of all wake words 18 | char **wake_word_list; //The name list of wake words 19 | } wake_word_info_t; 20 | 21 | /** 22 | * @brief Easy function type to initialze a model instance with a detection mode and specified wake word coefficient 23 | * 24 | * @param det_mode The wake words detection mode to trigger wake words, DET_MODE_90 or DET_MODE_95 25 | * @param model_coeff The specified wake word model coefficient 26 | * @returns Handle to the model data 27 | */ 28 | typedef model_iface_data_t* (*esp_wn_iface_op_create_t)(const model_coeff_getter_t *model_coeff, det_mode_t det_mode); 29 | 30 | 31 | /** 32 | * @brief Callback function type to fetch the amount of samples that need to be passed to the detect function 33 | * 34 | * Every speech recognition model processes a certain number of samples at the same time. This function 35 | * can be used to query that amount. Note that the returned amount is in 16-bit samples, not in bytes. 36 | * 37 | * @param model The model object to query 38 | * @return The amount of samples to feed the detect function 39 | */ 40 | typedef int (*esp_wn_iface_op_get_samp_chunksize_t)(model_iface_data_t *model); 41 | 42 | 43 | /** 44 | * @brief Get the sample rate of the samples to feed to the detect function 45 | * 46 | * @param model The model object to query 47 | * @return The sample rate, in hz 48 | */ 49 | typedef int (*esp_wn_iface_op_get_samp_rate_t)(model_iface_data_t *model); 50 | 51 | /** 52 | * @brief Get the number of wake words 53 | * 54 | * @param model The model object to query 55 | * @returns the number of wake words 56 | */ 57 | typedef int (*esp_wn_iface_op_get_word_num_t)(model_iface_data_t *model); 58 | 59 | /** 60 | * @brief Get the name of wake word by index 61 | * 62 | * @Warning The index of wake word start with 1 63 | 64 | * @param model The model object to query 65 | * @param word_index The index of wake word 66 | * @returns the detection threshold 67 | */ 68 | typedef char* (*esp_wn_iface_op_get_word_name_t)(model_iface_data_t *model, int word_index); 69 | 70 | /** 71 | * @brief Set the detection threshold to manually abjust the probability 72 | * 73 | * @param model The model object to query 74 | * @param det_treshold The threshold to trigger wake words, the range of det_threshold is 0.5~0.9999 75 | * @param word_index The index of wake word 76 | * @return 0: setting failed, 1: setting success 77 | */ 78 | typedef int (*esp_wn_iface_op_set_det_threshold_t)(model_iface_data_t *model, float det_threshold, int word_index); 79 | 80 | /** 81 | * @brief Get the wake word detection threshold of different modes 82 | * 83 | * @param model The model object to query 84 | * @param word_index The index of wake word 85 | * @returns the detection threshold 86 | */ 87 | typedef float (*esp_wn_iface_op_get_det_threshold_t)(model_iface_data_t *model, int word_index); 88 | 89 | /** 90 | * @brief Feed samples of an audio stream to the keyword detection model and detect if there is a keyword found. 91 | * 92 | * @Warning The index of wake word start with 1, 0 means no wake words is detected. 93 | * 94 | * @param model The model object to query 95 | * @param samples An array of 16-bit signed audio samples. The array size used can be queried by the 96 | * get_samp_chunksize function. 97 | * @return The index of wake words, return 0 if no wake word is detected, else the index of the wake words. 98 | */ 99 | typedef int (*esp_wn_iface_op_detect_t)(model_iface_data_t *model, int16_t *samples); 100 | 101 | /** 102 | * @brief Destroy a speech recognition model 103 | * 104 | * @param model Model object to destroy 105 | */ 106 | typedef void (*esp_wn_iface_op_destroy_t)(model_iface_data_t *model); 107 | 108 | 109 | /** 110 | * This structure contains the functions used to do operations on a wake word detection model. 111 | */ 112 | typedef struct { 113 | esp_wn_iface_op_create_t create; 114 | esp_wn_iface_op_get_samp_chunksize_t get_samp_chunksize; 115 | esp_wn_iface_op_get_samp_rate_t get_samp_rate; 116 | esp_wn_iface_op_get_word_num_t get_word_num; 117 | esp_wn_iface_op_get_word_name_t get_word_name; 118 | esp_wn_iface_op_set_det_threshold_t set_det_threshold; 119 | esp_wn_iface_op_get_det_threshold_t get_det_threshold; 120 | esp_wn_iface_op_detect_t detect; 121 | esp_wn_iface_op_destroy_t destroy; 122 | } esp_wn_iface_t; 123 | -------------------------------------------------------------------------------- /components/esp-sr/wake_word_engine/include/esp_wn_models.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "esp_wn_iface.h" 3 | 4 | //Contains declarations of all available speech recognion models. Pair this up with the right coefficients and you have a model that can recognize 5 | //a specific phrase or word. 6 | 7 | extern const esp_wn_iface_t esp_sr_wakenet5_quantized; 8 | 9 | 10 | /* 11 | Configure network to use based on what's selected in menuconfig. 12 | */ 13 | #define WAKENET_MODEL esp_sr_wakenet5_quantized 14 | 15 | /* 16 | Configure wake word to use based on what's selected in menuconfig. 17 | */ 18 | 19 | #include "hilexin_wn5.h" 20 | #define WAKENET_COEFF get_coeff_hilexin_wn5 21 | 22 | 23 | 24 | /* example 25 | 26 | static const sr_model_iface_t *model = &WAKENET_MODEL; 27 | 28 | //Initialize wakeNet model data 29 | static model_iface_data_t *model_data=model->create(DET_MODE_90); 30 | 31 | //Set parameters of buffer 32 | int audio_chunksize=model->get_samp_chunksize(model_data); 33 | int frequency = model->get_samp_rate(model_data); 34 | int16_t *buffer=malloc(audio_chunksize*sizeof(int16_t)); 35 | 36 | //Detect 37 | int r=model->detect(model_data, buffer); 38 | if (r>0) { 39 | printf("Detection triggered output %d.\n", r); 40 | } 41 | 42 | //Destroy model 43 | model->destroy(model_data) 44 | 45 | */ 46 | -------------------------------------------------------------------------------- /components/esp-sr/wake_word_engine/include/hilexin_wn5.h: -------------------------------------------------------------------------------- 1 | //Generated by mkmodel 2 | #pragma once 3 | #include 4 | #include "dl_lib_coefgetter_if.h" 5 | #include "dl_lib_matrix.h" 6 | #include "dl_lib_matrixq.h" 7 | 8 | extern const model_coeff_getter_t get_coeff_hilexin_wn5; 9 | -------------------------------------------------------------------------------- /components/esp-sr/wake_word_engine/libhilexin_wn5.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/components/esp-sr/wake_word_engine/libhilexin_wn5.a -------------------------------------------------------------------------------- /components/esp32-camera/.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | -------------------------------------------------------------------------------- /components/esp32-camera/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_SRCS 2 | driver/camera.c 3 | driver/sccb.c 4 | driver/sensor.c 5 | driver/twi.c 6 | driver/xclk.c 7 | sensors/ov2640.c 8 | sensors/ov3660.c 9 | sensors/ov5640.c 10 | sensors/ov7725.c 11 | conversions/yuv.c 12 | conversions/to_jpg.cpp 13 | conversions/to_bmp.c 14 | conversions/jpge.cpp 15 | conversions/esp_jpg_decode.c 16 | ) 17 | 18 | set(COMPONENT_ADD_INCLUDEDIRS 19 | driver/include 20 | conversions/include 21 | ) 22 | 23 | set(COMPONENT_PRIV_INCLUDEDIRS 24 | driver/private_include 25 | sensors/private_include 26 | conversions/private_include 27 | ) 28 | 29 | set(COMPONENT_REQUIRES driver) 30 | set(COMPONENT_PRIV_REQUIRES freertos nvs_flash) 31 | 32 | register_component() 33 | -------------------------------------------------------------------------------- /components/esp32-camera/Kconfig: -------------------------------------------------------------------------------- 1 | menu "Camera configuration" 2 | 3 | config OV2640_SUPPORT 4 | bool "OV2640 Support" 5 | default y 6 | help 7 | Enable this option if you want to use the OV2640. 8 | Disable this option to save memory. 9 | 10 | config OV7725_SUPPORT 11 | bool "OV7725 Support" 12 | default n 13 | help 14 | Enable this option if you want to use the OV7725. 15 | Disable this option to save memory. 16 | 17 | config OV3660_SUPPORT 18 | bool "OV3660 Support" 19 | default y 20 | help 21 | Enable this option if you want to use the OV3360. 22 | Disable this option to save memory. 23 | 24 | config OV5640_SUPPORT 25 | bool "OV5640 Support" 26 | default y 27 | help 28 | Enable this option if you want to use the OV5640. 29 | Disable this option to save memory. 30 | 31 | config SCCB_HARDWARE_I2C 32 | bool "Use hardware I2C for SCCB" 33 | default y 34 | help 35 | Enable this option if you want to use hardware I2C to control the camera. 36 | Disable this option to use software I2C. 37 | 38 | choice SCCB_HARDWARE_I2C_PORT 39 | bool "I2C peripheral to use for SCCB" 40 | depends on SCCB_HARDWARE_I2C 41 | default SCCB_HARDWARE_I2C_PORT1 42 | 43 | config SCCB_HARDWARE_I2C_PORT0 44 | bool "I2C0" 45 | config SCCB_HARDWARE_I2C_PORT1 46 | bool "I2C1" 47 | 48 | endchoice 49 | 50 | choice CAMERA_TASK_PINNED_TO_CORE 51 | bool "Camera task pinned to core" 52 | default CAMERA_CORE0 53 | help 54 | Pin the camera handle task to a certain core(0/1). It can also be done automatically choosing NO_AFFINITY. 55 | 56 | config CAMERA_CORE0 57 | bool "CORE0" 58 | config CAMERA_CORE1 59 | bool "CORE1" 60 | config CAMERA_NO_AFFINITY 61 | bool "NO_AFFINITY" 62 | 63 | endchoice 64 | 65 | endmenu 66 | -------------------------------------------------------------------------------- /components/esp32-camera/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS := driver/include conversions/include 2 | COMPONENT_PRIV_INCLUDEDIRS := driver/private_include conversions/private_include sensors/private_include 3 | COMPONENT_SRCDIRS := driver conversions sensors 4 | CXXFLAGS += -fno-rtti 5 | -------------------------------------------------------------------------------- /components/esp32-camera/conversions/esp_jpg_decode.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #include "esp_jpg_decode.h" 15 | 16 | #include "esp_system.h" 17 | #if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+ 18 | #if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 19 | #include "esp32/rom/tjpgd.h" 20 | #else 21 | #error Target CONFIG_IDF_TARGET is not supported 22 | #endif 23 | #else // ESP32 Before IDF 4.0 24 | #include "rom/tjpgd.h" 25 | #endif 26 | 27 | #if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) 28 | #include "esp32-hal-log.h" 29 | #define TAG "" 30 | #else 31 | #include "esp_log.h" 32 | static const char* TAG = "esp_jpg_decode"; 33 | #endif 34 | 35 | typedef struct { 36 | jpg_scale_t scale; 37 | jpg_reader_cb reader; 38 | jpg_writer_cb writer; 39 | void * arg; 40 | size_t len; 41 | size_t index; 42 | } esp_jpg_decoder_t; 43 | 44 | static const char * jd_errors[] = { 45 | "Succeeded", 46 | "Interrupted by output function", 47 | "Device error or wrong termination of input stream", 48 | "Insufficient memory pool for the image", 49 | "Insufficient stream input buffer", 50 | "Parameter error", 51 | "Data format error", 52 | "Right format but not supported", 53 | "Not supported JPEG standard" 54 | }; 55 | 56 | static uint32_t _jpg_write(JDEC *decoder, void *bitmap, JRECT *rect) 57 | { 58 | uint16_t x = rect->left; 59 | uint16_t y = rect->top; 60 | uint16_t w = rect->right + 1 - x; 61 | uint16_t h = rect->bottom + 1 - y; 62 | uint8_t *data = (uint8_t *)bitmap; 63 | 64 | esp_jpg_decoder_t * jpeg = (esp_jpg_decoder_t *)decoder->device; 65 | 66 | if (jpeg->writer) { 67 | return jpeg->writer(jpeg->arg, x, y, w, h, data); 68 | } 69 | return 0; 70 | } 71 | 72 | static uint32_t _jpg_read(JDEC *decoder, uint8_t *buf, uint32_t len) 73 | { 74 | esp_jpg_decoder_t * jpeg = (esp_jpg_decoder_t *)decoder->device; 75 | if (jpeg->len && len > (jpeg->len - jpeg->index)) { 76 | len = jpeg->len - jpeg->index; 77 | } 78 | if (len) { 79 | len = jpeg->reader(jpeg->arg, jpeg->index, buf, len); 80 | if (!len) { 81 | ESP_LOGE(TAG, "Read Fail at %u/%u", jpeg->index, jpeg->len); 82 | } 83 | jpeg->index += len; 84 | } 85 | return len; 86 | } 87 | 88 | esp_err_t esp_jpg_decode(size_t len, jpg_scale_t scale, jpg_reader_cb reader, jpg_writer_cb writer, void * arg) 89 | { 90 | static uint8_t work[3100]; 91 | JDEC decoder; 92 | esp_jpg_decoder_t jpeg; 93 | 94 | jpeg.len = len; 95 | jpeg.reader = reader; 96 | jpeg.writer = writer; 97 | jpeg.arg = arg; 98 | jpeg.scale = scale; 99 | jpeg.index = 0; 100 | 101 | JRESULT jres = jd_prepare(&decoder, _jpg_read, work, 3100, &jpeg); 102 | if(jres != JDR_OK){ 103 | ESP_LOGE(TAG, "JPG Header Parse Failed! %s", jd_errors[jres]); 104 | return ESP_FAIL; 105 | } 106 | 107 | uint16_t output_width = decoder.width / (1 << (uint8_t)(jpeg.scale)); 108 | uint16_t output_height = decoder.height / (1 << (uint8_t)(jpeg.scale)); 109 | 110 | //output start 111 | writer(arg, 0, 0, output_width, output_height, NULL); 112 | //output write 113 | jres = jd_decomp(&decoder, _jpg_write, (uint8_t)jpeg.scale); 114 | //output end 115 | writer(arg, output_width, output_height, output_width, output_height, NULL); 116 | 117 | if (jres != JDR_OK) { 118 | ESP_LOGE(TAG, "JPG Decompression Failed! %s", jd_errors[jres]); 119 | return ESP_FAIL; 120 | } 121 | //check if all data has been consumed. 122 | if (len && jpeg.index < len) { 123 | _jpg_read(&decoder, NULL, len - jpeg.index); 124 | } 125 | 126 | return ESP_OK; 127 | } 128 | 129 | -------------------------------------------------------------------------------- /components/esp32-camera/conversions/include/esp_jpg_decode.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef _ESP_JPG_DECODE_H_ 15 | #define _ESP_JPG_DECODE_H_ 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include 22 | #include 23 | #include 24 | #include "esp_err.h" 25 | 26 | typedef enum { 27 | JPG_SCALE_NONE, 28 | JPG_SCALE_2X, 29 | JPG_SCALE_4X, 30 | JPG_SCALE_8X, 31 | JPG_SCALE_MAX = JPG_SCALE_8X 32 | } jpg_scale_t; 33 | 34 | typedef size_t (* jpg_reader_cb)(void * arg, size_t index, uint8_t *buf, size_t len); 35 | typedef bool (* jpg_writer_cb)(void * arg, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t *data); 36 | 37 | esp_err_t esp_jpg_decode(size_t len, jpg_scale_t scale, jpg_reader_cb reader, jpg_writer_cb writer, void * arg); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif /* _ESP_JPG_DECODE_H_ */ 44 | -------------------------------------------------------------------------------- /components/esp32-camera/conversions/include/img_converters.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef _IMG_CONVERTERS_H_ 15 | #define _IMG_CONVERTERS_H_ 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include 22 | #include 23 | #include 24 | #include "esp_camera.h" 25 | 26 | typedef size_t (* jpg_out_cb)(void * arg, size_t index, const void* data, size_t len); 27 | 28 | /** 29 | * @brief Convert image buffer to JPEG 30 | * 31 | * @param src Source buffer in RGB565, RGB888, YUYV or GRAYSCALE format 32 | * @param src_len Length in bytes of the source buffer 33 | * @param width Width in pixels of the source image 34 | * @param height Height in pixels of the source image 35 | * @param format Format of the source image 36 | * @param quality JPEG quality of the resulting image 37 | * @param cp Callback to be called to write the bytes of the output JPEG 38 | * @param arg Pointer to be passed to the callback 39 | * 40 | * @return true on success 41 | */ 42 | bool fmt2jpg_cb(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, jpg_out_cb cb, void * arg); 43 | 44 | /** 45 | * @brief Convert camera frame buffer to JPEG 46 | * 47 | * @param fb Source camera frame buffer 48 | * @param quality JPEG quality of the resulting image 49 | * @param cp Callback to be called to write the bytes of the output JPEG 50 | * @param arg Pointer to be passed to the callback 51 | * 52 | * @return true on success 53 | */ 54 | bool frame2jpg_cb(camera_fb_t * fb, uint8_t quality, jpg_out_cb cb, void * arg); 55 | 56 | /** 57 | * @brief Convert image buffer to JPEG buffer 58 | * 59 | * @param src Source buffer in RGB565, RGB888, YUYV or GRAYSCALE format 60 | * @param src_len Length in bytes of the source buffer 61 | * @param width Width in pixels of the source image 62 | * @param height Height in pixels of the source image 63 | * @param format Format of the source image 64 | * @param quality JPEG quality of the resulting image 65 | * @param out Pointer to be populated with the address of the resulting buffer 66 | * @param out_len Pointer to be populated with the length of the output buffer 67 | * 68 | * @return true on success 69 | */ 70 | bool fmt2jpg(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, uint8_t ** out, size_t * out_len); 71 | 72 | /** 73 | * @brief Convert camera frame buffer to JPEG buffer 74 | * 75 | * @param fb Source camera frame buffer 76 | * @param quality JPEG quality of the resulting image 77 | * @param out Pointer to be populated with the address of the resulting buffer 78 | * @param out_len Pointer to be populated with the length of the output buffer 79 | * 80 | * @return true on success 81 | */ 82 | bool frame2jpg(camera_fb_t * fb, uint8_t quality, uint8_t ** out, size_t * out_len); 83 | 84 | /** 85 | * @brief Convert image buffer to BMP buffer 86 | * 87 | * @param src Source buffer in JPEG, RGB565, RGB888, YUYV or GRAYSCALE format 88 | * @param src_len Length in bytes of the source buffer 89 | * @param width Width in pixels of the source image 90 | * @param height Height in pixels of the source image 91 | * @param format Format of the source image 92 | * @param out Pointer to be populated with the address of the resulting buffer 93 | * @param out_len Pointer to be populated with the length of the output buffer 94 | * 95 | * @return true on success 96 | */ 97 | bool fmt2bmp(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t ** out, size_t * out_len); 98 | 99 | /** 100 | * @brief Convert camera frame buffer to BMP buffer 101 | * 102 | * @param fb Source camera frame buffer 103 | * @param out Pointer to be populated with the address of the resulting buffer 104 | * @param out_len Pointer to be populated with the length of the output buffer 105 | * 106 | * @return true on success 107 | */ 108 | bool frame2bmp(camera_fb_t * fb, uint8_t ** out, size_t * out_len); 109 | 110 | /** 111 | * @brief Convert image buffer to RGB888 buffer (used for face detection) 112 | * 113 | * @param src Source buffer in JPEG, RGB565, RGB888, YUYV or GRAYSCALE format 114 | * @param src_len Length in bytes of the source buffer 115 | * @param format Format of the source image 116 | * @param rgb_buf Pointer to the output buffer (width * height * 3) 117 | * 118 | * @return true on success 119 | */ 120 | bool fmt2rgb888(const uint8_t *src_buf, size_t src_len, pixformat_t format, uint8_t * rgb_buf); 121 | 122 | #ifdef __cplusplus 123 | } 124 | #endif 125 | 126 | #endif /* _IMG_CONVERTERS_H_ */ 127 | -------------------------------------------------------------------------------- /components/esp32-camera/conversions/private_include/jpge.h: -------------------------------------------------------------------------------- 1 | // jpge.h - C++ class for JPEG compression. 2 | // Public domain, Rich Geldreich 3 | // Alex Evans: Added RGBA support, linear memory allocator. 4 | #ifndef JPEG_ENCODER_H 5 | #define JPEG_ENCODER_H 6 | 7 | namespace jpge 8 | { 9 | typedef unsigned char uint8; 10 | typedef signed short int16; 11 | typedef signed int int32; 12 | typedef unsigned short uint16; 13 | typedef unsigned int uint32; 14 | typedef unsigned int uint; 15 | 16 | // JPEG chroma subsampling factors. Y_ONLY (grayscale images) and H2V2 (color images) are the most common. 17 | enum subsampling_t { Y_ONLY = 0, H1V1 = 1, H2V1 = 2, H2V2 = 3 }; 18 | 19 | // JPEG compression parameters structure. 20 | struct params { 21 | inline params() : m_quality(85), m_subsampling(H2V2) { } 22 | 23 | inline bool check() const { 24 | if ((m_quality < 1) || (m_quality > 100)) { 25 | return false; 26 | } 27 | if ((uint)m_subsampling > (uint)H2V2) { 28 | return false; 29 | } 30 | return true; 31 | } 32 | 33 | // Quality: 1-100, higher is better. Typical values are around 50-95. 34 | int m_quality; 35 | 36 | // m_subsampling: 37 | // 0 = Y (grayscale) only 38 | // 1 = H1V1 subsampling (YCbCr 1x1x1, 3 blocks per MCU) 39 | // 2 = H2V1 subsampling (YCbCr 2x1x1, 4 blocks per MCU) 40 | // 3 = H2V2 subsampling (YCbCr 4x1x1, 6 blocks per MCU-- very common) 41 | subsampling_t m_subsampling; 42 | }; 43 | 44 | // Output stream abstract class - used by the jpeg_encoder class to write to the output stream. 45 | // put_buf() is generally called with len==JPGE_OUT_BUF_SIZE bytes, but for headers it'll be called with smaller amounts. 46 | class output_stream { 47 | public: 48 | virtual ~output_stream() { }; 49 | virtual bool put_buf(const void* Pbuf, int len) = 0; 50 | virtual uint get_size() const = 0; 51 | }; 52 | 53 | // Lower level jpeg_encoder class - useful if more control is needed than the above helper functions. 54 | class jpeg_encoder { 55 | public: 56 | jpeg_encoder(); 57 | ~jpeg_encoder(); 58 | 59 | // Initializes the compressor. 60 | // pStream: The stream object to use for writing compressed data. 61 | // params - Compression parameters structure, defined above. 62 | // width, height - Image dimensions. 63 | // channels - May be 1, or 3. 1 indicates grayscale, 3 indicates RGB source data. 64 | // Returns false on out of memory or if a stream write fails. 65 | bool init(output_stream *pStream, int width, int height, int src_channels, const params &comp_params = params()); 66 | 67 | // Call this method with each source scanline. 68 | // width * src_channels bytes per scanline is expected (RGB or Y format). 69 | // You must call with NULL after all scanlines are processed to finish compression. 70 | // Returns false on out of memory or if a stream write fails. 71 | bool process_scanline(const void* pScanline); 72 | 73 | // Deinitializes the compressor, freeing any allocated memory. May be called at any time. 74 | void deinit(); 75 | 76 | private: 77 | jpeg_encoder(const jpeg_encoder &); 78 | jpeg_encoder &operator =(const jpeg_encoder &); 79 | 80 | typedef int32 sample_array_t; 81 | enum { JPGE_OUT_BUF_SIZE = 512 }; 82 | 83 | output_stream *m_pStream; 84 | params m_params; 85 | uint8 m_num_components; 86 | uint8 m_comp_h_samp[3], m_comp_v_samp[3]; 87 | int m_image_x, m_image_y, m_image_bpp, m_image_bpl; 88 | int m_image_x_mcu, m_image_y_mcu; 89 | int m_image_bpl_xlt, m_image_bpl_mcu; 90 | int m_mcus_per_row; 91 | int m_mcu_x, m_mcu_y; 92 | uint8 *m_mcu_lines[16]; 93 | uint8 m_mcu_y_ofs; 94 | sample_array_t m_sample_array[64]; 95 | int16 m_coefficient_array[64]; 96 | 97 | int m_last_dc_val[3]; 98 | uint8 m_out_buf[JPGE_OUT_BUF_SIZE]; 99 | uint8 *m_pOut_buf; 100 | uint m_out_buf_left; 101 | uint32 m_bit_buffer; 102 | uint m_bits_in; 103 | uint8 m_pass_num; 104 | bool m_all_stream_writes_succeeded; 105 | 106 | bool jpg_open(int p_x_res, int p_y_res, int src_channels); 107 | 108 | void flush_output_buffer(); 109 | void put_bits(uint bits, uint len); 110 | 111 | void emit_byte(uint8 i); 112 | void emit_word(uint i); 113 | void emit_marker(int marker); 114 | 115 | void emit_jfif_app0(); 116 | void emit_dqt(); 117 | void emit_sof(); 118 | void emit_dht(uint8 *bits, uint8 *val, int index, bool ac_flag); 119 | void emit_dhts(); 120 | void emit_sos(); 121 | 122 | void compute_quant_table(int32 *dst, const int16 *src); 123 | void load_quantized_coefficients(int component_num); 124 | 125 | void load_block_8_8_grey(int x); 126 | void load_block_8_8(int x, int y, int c); 127 | void load_block_16_8(int x, int c); 128 | void load_block_16_8_8(int x, int c); 129 | 130 | void code_coefficients_pass_two(int component_num); 131 | void code_block(int component_num); 132 | 133 | void process_mcu_row(); 134 | bool process_end_of_image(); 135 | void load_mcu(const void* src); 136 | void clear(); 137 | void init(); 138 | }; 139 | 140 | } // namespace jpge 141 | 142 | #endif // JPEG_ENCODER 143 | -------------------------------------------------------------------------------- /components/esp32-camera/conversions/private_include/yuv.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef _CONVERSIONS_YUV_H_ 15 | #define _CONVERSIONS_YUV_H_ 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include 22 | 23 | void yuv2rgb(uint8_t y, uint8_t u, uint8_t v, uint8_t *r, uint8_t *g, uint8_t *b); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /* _CONVERSIONS_YUV_H_ */ 30 | -------------------------------------------------------------------------------- /components/esp32-camera/conversions/to_jpg.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #include 15 | #include 16 | #include "esp_attr.h" 17 | #include "soc/efuse_reg.h" 18 | #include "esp_heap_caps.h" 19 | #include "esp_camera.h" 20 | #include "img_converters.h" 21 | #include "jpge.h" 22 | #include "yuv.h" 23 | 24 | #include "esp_system.h" 25 | #if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+ 26 | #if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 27 | #include "esp32/spiram.h" 28 | #else 29 | #error Target CONFIG_IDF_TARGET is not supported 30 | #endif 31 | #else // ESP32 Before IDF 4.0 32 | #include "esp_spiram.h" 33 | #endif 34 | 35 | #if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) 36 | #include "esp32-hal-log.h" 37 | #define TAG "" 38 | #else 39 | #include "esp_log.h" 40 | static const char* TAG = "to_jpg"; 41 | #endif 42 | 43 | static void *_malloc(size_t size) 44 | { 45 | void * res = malloc(size); 46 | if(res) { 47 | return res; 48 | } 49 | return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); 50 | } 51 | 52 | static IRAM_ATTR void convert_line_format(uint8_t * src, pixformat_t format, uint8_t * dst, size_t width, size_t in_channels, size_t line) 53 | { 54 | int i=0, o=0, l=0; 55 | if(format == PIXFORMAT_GRAYSCALE) { 56 | memcpy(dst, src + line * width, width); 57 | } else if(format == PIXFORMAT_RGB888) { 58 | l = width * 3; 59 | src += l * line; 60 | for(i=0; i> 3; 71 | dst[o++] = (src[i+1] & 0x1F) << 3; 72 | } 73 | } else if(format == PIXFORMAT_YUV422) { 74 | uint8_t y0, y1, u, v; 75 | uint8_t r, g, b; 76 | l = width * 2; 77 | src += l * line; 78 | for(i=0; i 100) { 110 | quality = 100; 111 | } 112 | 113 | jpge::params comp_params = jpge::params(); 114 | comp_params.m_subsampling = subsampling; 115 | comp_params.m_quality = quality; 116 | 117 | jpge::jpeg_encoder dst_image; 118 | 119 | if (!dst_image.init(dst_stream, width, height, num_channels, comp_params)) { 120 | ESP_LOGE(TAG, "JPG encoder init failed"); 121 | return false; 122 | } 123 | 124 | uint8_t* line = (uint8_t*)_malloc(width * num_channels); 125 | if(!line) { 126 | ESP_LOGE(TAG, "Scan line malloc failed"); 127 | return false; 128 | } 129 | 130 | for (int i = 0; i < height; i++) { 131 | convert_line_format(src, format, line, width, num_channels, i); 132 | if (!dst_image.process_scanline(line)) { 133 | ESP_LOGE(TAG, "JPG process line %u failed", i); 134 | free(line); 135 | return false; 136 | } 137 | } 138 | free(line); 139 | 140 | if (!dst_image.process_scanline(NULL)) { 141 | ESP_LOGE(TAG, "JPG image finish failed"); 142 | return false; 143 | } 144 | dst_image.deinit(); 145 | return true; 146 | } 147 | 148 | class callback_stream : public jpge::output_stream { 149 | protected: 150 | jpg_out_cb ocb; 151 | void * oarg; 152 | size_t index; 153 | 154 | public: 155 | callback_stream(jpg_out_cb cb, void * arg) : ocb(cb), oarg(arg), index(0) { } 156 | virtual ~callback_stream() { } 157 | virtual bool put_buf(const void* data, int len) 158 | { 159 | index += ocb(oarg, index, data, len); 160 | return true; 161 | } 162 | virtual size_t get_size() const 163 | { 164 | return index; 165 | } 166 | }; 167 | 168 | bool fmt2jpg_cb(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, jpg_out_cb cb, void * arg) 169 | { 170 | callback_stream dst_stream(cb, arg); 171 | return convert_image(src, width, height, format, quality, &dst_stream); 172 | } 173 | 174 | bool frame2jpg_cb(camera_fb_t * fb, uint8_t quality, jpg_out_cb cb, void * arg) 175 | { 176 | return fmt2jpg_cb(fb->buf, fb->len, fb->width, fb->height, fb->format, quality, cb, arg); 177 | } 178 | 179 | 180 | 181 | class memory_stream : public jpge::output_stream { 182 | protected: 183 | uint8_t *out_buf; 184 | size_t max_len, index; 185 | 186 | public: 187 | memory_stream(void *pBuf, uint buf_size) : out_buf(static_cast(pBuf)), max_len(buf_size), index(0) { } 188 | 189 | virtual ~memory_stream() { } 190 | 191 | virtual bool put_buf(const void* pBuf, int len) 192 | { 193 | if (!pBuf) { 194 | //end of image 195 | return true; 196 | } 197 | if ((size_t)len > (max_len - index)) { 198 | ESP_LOGW(TAG, "JPG output overflow: %d bytes", len - (max_len - index)); 199 | len = max_len - index; 200 | } 201 | if (len) { 202 | memcpy(out_buf + index, pBuf, len); 203 | index += len; 204 | } 205 | return true; 206 | } 207 | 208 | virtual size_t get_size() const 209 | { 210 | return index; 211 | } 212 | }; 213 | 214 | bool fmt2jpg(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, uint8_t ** out, size_t * out_len) 215 | { 216 | //todo: allocate proper buffer for holding JPEG data 217 | //this should be enough for CIF frame size 218 | int jpg_buf_len = 64*1024; 219 | 220 | 221 | uint8_t * jpg_buf = (uint8_t *)_malloc(jpg_buf_len); 222 | if(jpg_buf == NULL) { 223 | ESP_LOGE(TAG, "JPG buffer malloc failed"); 224 | return false; 225 | } 226 | memory_stream dst_stream(jpg_buf, jpg_buf_len); 227 | 228 | if(!convert_image(src, width, height, format, quality, &dst_stream)) { 229 | free(jpg_buf); 230 | return false; 231 | } 232 | 233 | *out = jpg_buf; 234 | *out_len = dst_stream.get_size(); 235 | return true; 236 | } 237 | 238 | bool frame2jpg(camera_fb_t * fb, uint8_t quality, uint8_t ** out, size_t * out_len) 239 | { 240 | return fmt2jpg(fb->buf, fb->len, fb->width, fb->height, fb->format, quality, out, out_len); 241 | } 242 | -------------------------------------------------------------------------------- /components/esp32-camera/driver/include/esp_camera.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | /* 15 | * Example Use 16 | * 17 | static camera_config_t camera_example_config = { 18 | .pin_pwdn = PIN_PWDN, 19 | .pin_reset = PIN_RESET, 20 | .pin_xclk = PIN_XCLK, 21 | .pin_sscb_sda = PIN_SIOD, 22 | .pin_sscb_scl = PIN_SIOC, 23 | .pin_d7 = PIN_D7, 24 | .pin_d6 = PIN_D6, 25 | .pin_d5 = PIN_D5, 26 | .pin_d4 = PIN_D4, 27 | .pin_d3 = PIN_D3, 28 | .pin_d2 = PIN_D2, 29 | .pin_d1 = PIN_D1, 30 | .pin_d0 = PIN_D0, 31 | .pin_vsync = PIN_VSYNC, 32 | .pin_href = PIN_HREF, 33 | .pin_pclk = PIN_PCLK, 34 | 35 | .xclk_freq_hz = 20000000, 36 | .ledc_timer = LEDC_TIMER_0, 37 | .ledc_channel = LEDC_CHANNEL_0, 38 | .pixel_format = PIXFORMAT_JPEG, 39 | .frame_size = FRAMESIZE_SVGA, 40 | .jpeg_quality = 10, 41 | .fb_count = 2 42 | }; 43 | 44 | esp_err_t camera_example_init(){ 45 | return esp_camera_init(&camera_example_config); 46 | } 47 | 48 | esp_err_t camera_example_capture(){ 49 | //capture a frame 50 | camera_fb_t * fb = esp_camera_fb_get(); 51 | if (!fb) { 52 | ESP_LOGE(TAG, "Frame buffer could not be acquired"); 53 | return ESP_FAIL; 54 | } 55 | 56 | //replace this with your own function 57 | display_image(fb->width, fb->height, fb->pixformat, fb->buf, fb->len); 58 | 59 | //return the frame buffer back to be reused 60 | esp_camera_fb_return(fb); 61 | 62 | return ESP_OK; 63 | } 64 | */ 65 | 66 | #pragma once 67 | 68 | #include "esp_err.h" 69 | #include "driver/ledc.h" 70 | #include "sensor.h" 71 | #include "sys/time.h" 72 | 73 | #ifdef __cplusplus 74 | extern "C" { 75 | #endif 76 | 77 | /** 78 | * @brief Configuration structure for camera initialization 79 | */ 80 | typedef struct { 81 | int pin_pwdn; /*!< GPIO pin for camera power down line */ 82 | int pin_reset; /*!< GPIO pin for camera reset line */ 83 | int pin_xclk; /*!< GPIO pin for camera XCLK line */ 84 | int pin_sscb_sda; /*!< GPIO pin for camera SDA line */ 85 | int pin_sscb_scl; /*!< GPIO pin for camera SCL line */ 86 | int pin_d7; /*!< GPIO pin for camera D7 line */ 87 | int pin_d6; /*!< GPIO pin for camera D6 line */ 88 | int pin_d5; /*!< GPIO pin for camera D5 line */ 89 | int pin_d4; /*!< GPIO pin for camera D4 line */ 90 | int pin_d3; /*!< GPIO pin for camera D3 line */ 91 | int pin_d2; /*!< GPIO pin for camera D2 line */ 92 | int pin_d1; /*!< GPIO pin for camera D1 line */ 93 | int pin_d0; /*!< GPIO pin for camera D0 line */ 94 | int pin_vsync; /*!< GPIO pin for camera VSYNC line */ 95 | int pin_href; /*!< GPIO pin for camera HREF line */ 96 | int pin_pclk; /*!< GPIO pin for camera PCLK line */ 97 | 98 | int xclk_freq_hz; /*!< Frequency of XCLK signal, in Hz. Either 20KHz or 10KHz for OV2640 double FPS (Experimental) */ 99 | 100 | ledc_timer_t ledc_timer; /*!< LEDC timer to be used for generating XCLK */ 101 | ledc_channel_t ledc_channel; /*!< LEDC channel to be used for generating XCLK */ 102 | 103 | pixformat_t pixel_format; /*!< Format of the pixel data: PIXFORMAT_ + YUV422|GRAYSCALE|RGB565|JPEG */ 104 | framesize_t frame_size; /*!< Size of the output image: FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA */ 105 | 106 | int jpeg_quality; /*!< Quality of JPEG output. 0-63 lower means higher quality */ 107 | size_t fb_count; /*!< Number of frame buffers to be allocated. If more than one, then each frame will be acquired (double speed) */ 108 | } camera_config_t; 109 | 110 | /** 111 | * @brief Data structure of camera frame buffer 112 | */ 113 | typedef struct { 114 | uint8_t * buf; /*!< Pointer to the pixel data */ 115 | size_t len; /*!< Length of the buffer in bytes */ 116 | size_t width; /*!< Width of the buffer in pixels */ 117 | size_t height; /*!< Height of the buffer in pixels */ 118 | pixformat_t format; /*!< Format of the pixel data */ 119 | struct timeval timestamp; /*!< Timestamp since boot of the first DMA buffer of the frame */ 120 | } camera_fb_t; 121 | 122 | #define ESP_ERR_CAMERA_BASE 0x20000 123 | #define ESP_ERR_CAMERA_NOT_DETECTED (ESP_ERR_CAMERA_BASE + 1) 124 | #define ESP_ERR_CAMERA_FAILED_TO_SET_FRAME_SIZE (ESP_ERR_CAMERA_BASE + 2) 125 | #define ESP_ERR_CAMERA_FAILED_TO_SET_OUT_FORMAT (ESP_ERR_CAMERA_BASE + 3) 126 | #define ESP_ERR_CAMERA_NOT_SUPPORTED (ESP_ERR_CAMERA_BASE + 4) 127 | 128 | /** 129 | * @brief Initialize the camera driver 130 | * 131 | * @note call camera_probe before calling this function 132 | * 133 | * This function detects and configures camera over I2C interface, 134 | * allocates framebuffer and DMA buffers, 135 | * initializes parallel I2S input, and sets up DMA descriptors. 136 | * 137 | * Currently this function can only be called once and there is 138 | * no way to de-initialize this module. 139 | * 140 | * @param config Camera configuration parameters 141 | * 142 | * @return ESP_OK on success 143 | */ 144 | esp_err_t esp_camera_init(const camera_config_t* config); 145 | 146 | /** 147 | * @brief Deinitialize the camera driver 148 | * 149 | * @return 150 | * - ESP_OK on success 151 | * - ESP_ERR_INVALID_STATE if the driver hasn't been initialized yet 152 | */ 153 | esp_err_t esp_camera_deinit(); 154 | 155 | /** 156 | * @brief Obtain pointer to a frame buffer. 157 | * 158 | * @return pointer to the frame buffer 159 | */ 160 | camera_fb_t* esp_camera_fb_get(); 161 | 162 | /** 163 | * @brief Return the frame buffer to be reused again. 164 | * 165 | * @param fb Pointer to the frame buffer 166 | */ 167 | void esp_camera_fb_return(camera_fb_t * fb); 168 | 169 | /** 170 | * @brief Get a pointer to the image sensor control structure 171 | * 172 | * @return pointer to the sensor 173 | */ 174 | sensor_t * esp_camera_sensor_get(); 175 | 176 | /** 177 | * @brief Save camera settings to non-volatile-storage (NVS) 178 | * 179 | * @param key A unique nvs key name for the camera settings 180 | */ 181 | esp_err_t esp_camera_save_to_nvs(const char *key); 182 | 183 | /** 184 | * @brief Load camera settings from non-volatile-storage (NVS) 185 | * 186 | * @param key A unique nvs key name for the camera settings 187 | */ 188 | esp_err_t esp_camera_load_from_nvs(const char *key); 189 | 190 | #ifdef __cplusplus 191 | } 192 | #endif 193 | 194 | #include "img_converters.h" 195 | 196 | -------------------------------------------------------------------------------- /components/esp32-camera/driver/include/sensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * Sensor abstraction layer. 7 | * 8 | */ 9 | #ifndef __SENSOR_H__ 10 | #define __SENSOR_H__ 11 | #include 12 | #include 13 | 14 | #define OV9650_PID (0x96) 15 | #define OV7725_PID (0x77) 16 | #define OV2640_PID (0x26) 17 | #define OV3660_PID (0x36) 18 | #define OV5640_PID (0x56) 19 | 20 | typedef enum { 21 | PIXFORMAT_RGB565, // 2BPP/RGB565 22 | PIXFORMAT_YUV422, // 2BPP/YUV422 23 | PIXFORMAT_GRAYSCALE, // 1BPP/GRAYSCALE 24 | PIXFORMAT_JPEG, // JPEG/COMPRESSED 25 | PIXFORMAT_RGB888, // 3BPP/RGB888 26 | PIXFORMAT_RAW, // RAW 27 | PIXFORMAT_RGB444, // 3BP2P/RGB444 28 | PIXFORMAT_RGB555, // 3BP2P/RGB555 29 | } pixformat_t; 30 | 31 | typedef enum { 32 | FRAMESIZE_96X96, // 96x96 33 | FRAMESIZE_QQVGA, // 160x120 34 | FRAMESIZE_QCIF, // 176x144 35 | FRAMESIZE_HQVGA, // 240x176 36 | FRAMESIZE_240X240, // 240x240 37 | FRAMESIZE_QVGA, // 320x240 38 | FRAMESIZE_CIF, // 400x296 39 | FRAMESIZE_HVGA, // 480x320 40 | FRAMESIZE_VGA, // 640x480 41 | FRAMESIZE_SVGA, // 800x600 42 | FRAMESIZE_XGA, // 1024x768 43 | FRAMESIZE_HD, // 1280x720 44 | FRAMESIZE_SXGA, // 1280x1024 45 | FRAMESIZE_UXGA, // 1600x1200 46 | // 3MP Sensors 47 | FRAMESIZE_FHD, // 1920x1080 48 | FRAMESIZE_P_HD, // 720x1280 49 | FRAMESIZE_P_3MP, // 864x1536 50 | FRAMESIZE_QXGA, // 2048x1536 51 | // 5MP Sensors 52 | FRAMESIZE_QHD, // 2560x1440 53 | FRAMESIZE_WQXGA, // 2560x1600 54 | FRAMESIZE_P_FHD, // 1080x1920 55 | FRAMESIZE_QSXGA, // 2560x1920 56 | FRAMESIZE_INVALID 57 | } framesize_t; 58 | 59 | typedef enum { 60 | ASPECT_RATIO_4X3, 61 | ASPECT_RATIO_3X2, 62 | ASPECT_RATIO_16X10, 63 | ASPECT_RATIO_5X3, 64 | ASPECT_RATIO_16X9, 65 | ASPECT_RATIO_21X9, 66 | ASPECT_RATIO_5X4, 67 | ASPECT_RATIO_1X1, 68 | ASPECT_RATIO_9X16 69 | } aspect_ratio_t; 70 | 71 | typedef enum { 72 | GAINCEILING_2X, 73 | GAINCEILING_4X, 74 | GAINCEILING_8X, 75 | GAINCEILING_16X, 76 | GAINCEILING_32X, 77 | GAINCEILING_64X, 78 | GAINCEILING_128X, 79 | } gainceiling_t; 80 | 81 | typedef struct { 82 | uint16_t max_width; 83 | uint16_t max_height; 84 | uint16_t start_x; 85 | uint16_t start_y; 86 | uint16_t end_x; 87 | uint16_t end_y; 88 | uint16_t offset_x; 89 | uint16_t offset_y; 90 | uint16_t total_x; 91 | uint16_t total_y; 92 | } ratio_settings_t; 93 | 94 | typedef struct { 95 | const uint16_t width; 96 | const uint16_t height; 97 | const aspect_ratio_t aspect_ratio; 98 | } resolution_info_t; 99 | 100 | // Resolution table (in sensor.c) 101 | extern const resolution_info_t resolution[]; 102 | 103 | typedef struct { 104 | uint8_t MIDH; 105 | uint8_t MIDL; 106 | uint8_t PID; 107 | uint8_t VER; 108 | } sensor_id_t; 109 | 110 | typedef struct { 111 | framesize_t framesize;//0 - 10 112 | bool scale; 113 | bool binning; 114 | uint8_t quality;//0 - 63 115 | int8_t brightness;//-2 - 2 116 | int8_t contrast;//-2 - 2 117 | int8_t saturation;//-2 - 2 118 | int8_t sharpness;//-2 - 2 119 | uint8_t denoise; 120 | uint8_t special_effect;//0 - 6 121 | uint8_t wb_mode;//0 - 4 122 | uint8_t awb; 123 | uint8_t awb_gain; 124 | uint8_t aec; 125 | uint8_t aec2; 126 | int8_t ae_level;//-2 - 2 127 | uint16_t aec_value;//0 - 1200 128 | uint8_t agc; 129 | uint8_t agc_gain;//0 - 30 130 | uint8_t gainceiling;//0 - 6 131 | uint8_t bpc; 132 | uint8_t wpc; 133 | uint8_t raw_gma; 134 | uint8_t lenc; 135 | uint8_t hmirror; 136 | uint8_t vflip; 137 | uint8_t dcw; 138 | uint8_t colorbar; 139 | } camera_status_t; 140 | 141 | typedef struct _sensor sensor_t; 142 | typedef struct _sensor { 143 | sensor_id_t id; // Sensor ID. 144 | uint8_t slv_addr; // Sensor I2C slave address. 145 | pixformat_t pixformat; 146 | camera_status_t status; 147 | int xclk_freq_hz; 148 | 149 | // Sensor function pointers 150 | int (*init_status) (sensor_t *sensor); 151 | int (*reset) (sensor_t *sensor); 152 | int (*set_pixformat) (sensor_t *sensor, pixformat_t pixformat); 153 | int (*set_framesize) (sensor_t *sensor, framesize_t framesize); 154 | int (*set_contrast) (sensor_t *sensor, int level); 155 | int (*set_brightness) (sensor_t *sensor, int level); 156 | int (*set_saturation) (sensor_t *sensor, int level); 157 | int (*set_sharpness) (sensor_t *sensor, int level); 158 | int (*set_denoise) (sensor_t *sensor, int level); 159 | int (*set_gainceiling) (sensor_t *sensor, gainceiling_t gainceiling); 160 | int (*set_quality) (sensor_t *sensor, int quality); 161 | int (*set_colorbar) (sensor_t *sensor, int enable); 162 | int (*set_whitebal) (sensor_t *sensor, int enable); 163 | int (*set_gain_ctrl) (sensor_t *sensor, int enable); 164 | int (*set_exposure_ctrl) (sensor_t *sensor, int enable); 165 | int (*set_hmirror) (sensor_t *sensor, int enable); 166 | int (*set_vflip) (sensor_t *sensor, int enable); 167 | 168 | int (*set_aec2) (sensor_t *sensor, int enable); 169 | int (*set_awb_gain) (sensor_t *sensor, int enable); 170 | int (*set_agc_gain) (sensor_t *sensor, int gain); 171 | int (*set_aec_value) (sensor_t *sensor, int gain); 172 | 173 | int (*set_special_effect) (sensor_t *sensor, int effect); 174 | int (*set_wb_mode) (sensor_t *sensor, int mode); 175 | int (*set_ae_level) (sensor_t *sensor, int level); 176 | 177 | int (*set_dcw) (sensor_t *sensor, int enable); 178 | int (*set_bpc) (sensor_t *sensor, int enable); 179 | int (*set_wpc) (sensor_t *sensor, int enable); 180 | 181 | int (*set_raw_gma) (sensor_t *sensor, int enable); 182 | int (*set_lenc) (sensor_t *sensor, int enable); 183 | 184 | int (*get_reg) (sensor_t *sensor, int reg, int mask); 185 | int (*set_reg) (sensor_t *sensor, int reg, int mask, int value); 186 | int (*set_res_raw) (sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning); 187 | int (*set_pll) (sensor_t *sensor, int bypass, int mul, int sys, int root, int pre, int seld5, int pclken, int pclk); 188 | int (*set_xclk) (sensor_t *sensor, int timer, int xclk); 189 | } sensor_t; 190 | 191 | #endif /* __SENSOR_H__ */ 192 | -------------------------------------------------------------------------------- /components/esp32-camera/driver/private_include/camera_common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "esp_err.h" 7 | #include "esp_intr_alloc.h" 8 | #include "freertos/FreeRTOS.h" 9 | #include "freertos/semphr.h" 10 | #include "freertos/task.h" 11 | #include "esp_camera.h" 12 | #include "sensor.h" 13 | 14 | #include "esp_system.h" 15 | #if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+ 16 | #if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 17 | #include "esp32/rom/lldesc.h" 18 | #else 19 | #error Target CONFIG_IDF_TARGET is not supported 20 | #endif 21 | #else // ESP32 Before IDF 4.0 22 | #include "rom/lldesc.h" 23 | #endif 24 | 25 | typedef union { 26 | struct { 27 | uint8_t sample2; 28 | uint8_t unused2; 29 | uint8_t sample1; 30 | uint8_t unused1; 31 | }; 32 | uint32_t val; 33 | } dma_elem_t; 34 | 35 | typedef enum { 36 | /* camera sends byte sequence: s1, s2, s3, s4, ... 37 | * fifo receives: 00 s1 00 s2, 00 s2 00 s3, 00 s3 00 s4, ... 38 | */ 39 | SM_0A0B_0B0C = 0, 40 | /* camera sends byte sequence: s1, s2, s3, s4, ... 41 | * fifo receives: 00 s1 00 s2, 00 s3 00 s4, ... 42 | */ 43 | SM_0A0B_0C0D = 1, 44 | /* camera sends byte sequence: s1, s2, s3, s4, ... 45 | * fifo receives: 00 s1 00 00, 00 s2 00 00, 00 s3 00 00, ... 46 | */ 47 | SM_0A00_0B00 = 3, 48 | } i2s_sampling_mode_t; 49 | 50 | -------------------------------------------------------------------------------- /components/esp32-camera/driver/private_include/sccb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * SCCB (I2C like) driver. 7 | * 8 | */ 9 | #ifndef __SCCB_H__ 10 | #define __SCCB_H__ 11 | #include 12 | int SCCB_Init(int pin_sda, int pin_scl); 13 | uint8_t SCCB_Probe(); 14 | uint8_t SCCB_Read(uint8_t slv_addr, uint8_t reg); 15 | uint8_t SCCB_Write(uint8_t slv_addr, uint8_t reg, uint8_t data); 16 | uint8_t SCCB_Read16(uint8_t slv_addr, uint16_t reg); 17 | uint8_t SCCB_Write16(uint8_t slv_addr, uint16_t reg, uint8_t data); 18 | #endif // __SCCB_H__ 19 | -------------------------------------------------------------------------------- /components/esp32-camera/driver/private_include/twi.h: -------------------------------------------------------------------------------- 1 | /* 2 | twi.h - Software I2C library for ESP31B 3 | 4 | Copyright (c) 2015 Hristo Gochkov. All rights reserved. 5 | This file is part of the ESP31B core for Arduino environment. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef SI2C_h 22 | #define SI2C_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | void twi_init(unsigned char sda, unsigned char scl); 29 | void twi_stop(void); 30 | void twi_setClock(unsigned int freq); 31 | uint8_t twi_writeTo(unsigned char address, unsigned char * buf, unsigned int len, unsigned char sendStop); 32 | uint8_t twi_readFrom(unsigned char address, unsigned char * buf, unsigned int len, unsigned char sendStop); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif -------------------------------------------------------------------------------- /components/esp32-camera/driver/private_include/xclk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "camera_common.h" 4 | 5 | esp_err_t camera_enable_out_clock(); 6 | 7 | void camera_disable_out_clock(); 8 | -------------------------------------------------------------------------------- /components/esp32-camera/driver/sensor.c: -------------------------------------------------------------------------------- 1 | #include "sensor.h" 2 | 3 | const resolution_info_t resolution[FRAMESIZE_INVALID] = { 4 | { 96, 96, ASPECT_RATIO_1X1 }, /* 96x96 */ 5 | { 160, 120, ASPECT_RATIO_4X3 }, /* QQVGA */ 6 | { 176, 144, ASPECT_RATIO_5X4 }, /* QCIF */ 7 | { 240, 176, ASPECT_RATIO_4X3 }, /* HQVGA */ 8 | { 240, 240, ASPECT_RATIO_1X1 }, /* 240x240 */ 9 | { 320, 240, ASPECT_RATIO_4X3 }, /* QVGA */ 10 | { 400, 296, ASPECT_RATIO_4X3 }, /* CIF */ 11 | { 480, 320, ASPECT_RATIO_3X2 }, /* HVGA */ 12 | { 640, 480, ASPECT_RATIO_4X3 }, /* VGA */ 13 | { 800, 600, ASPECT_RATIO_4X3 }, /* SVGA */ 14 | { 1024, 768, ASPECT_RATIO_4X3 }, /* XGA */ 15 | { 1280, 720, ASPECT_RATIO_16X9 }, /* HD */ 16 | { 1280, 1024, ASPECT_RATIO_5X4 }, /* SXGA */ 17 | { 1600, 1200, ASPECT_RATIO_4X3 }, /* UXGA */ 18 | // 3MP Sensors 19 | { 1920, 1080, ASPECT_RATIO_16X9 }, /* FHD */ 20 | { 720, 1280, ASPECT_RATIO_9X16 }, /* Portrait HD */ 21 | { 864, 1536, ASPECT_RATIO_9X16 }, /* Portrait 3MP */ 22 | { 2048, 1536, ASPECT_RATIO_4X3 }, /* QXGA */ 23 | // 5MP Sensors 24 | { 2560, 1440, ASPECT_RATIO_16X9 }, /* QHD */ 25 | { 2560, 1600, ASPECT_RATIO_16X10 }, /* WQXGA */ 26 | { 1088, 1920, ASPECT_RATIO_9X16 }, /* Portrait FHD */ 27 | { 2560, 1920, ASPECT_RATIO_4X3 }, /* QSXGA */ 28 | }; 29 | -------------------------------------------------------------------------------- /components/esp32-camera/driver/xclk.c: -------------------------------------------------------------------------------- 1 | #include "driver/gpio.h" 2 | #include "driver/ledc.h" 3 | #include "esp_err.h" 4 | #include "esp_log.h" 5 | #include "esp_system.h" 6 | #include "xclk.h" 7 | 8 | #if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) 9 | #include "esp32-hal-log.h" 10 | #else 11 | #include "esp_log.h" 12 | static const char* TAG = "camera_xclk"; 13 | #endif 14 | 15 | esp_err_t xclk_timer_conf(int ledc_timer, int xclk_freq_hz) 16 | { 17 | ledc_timer_config_t timer_conf; 18 | timer_conf.duty_resolution = 2; 19 | timer_conf.freq_hz = xclk_freq_hz; 20 | timer_conf.speed_mode = LEDC_HIGH_SPEED_MODE; 21 | #if ESP_IDF_VERSION_MAJOR >= 4 22 | timer_conf.clk_cfg = LEDC_AUTO_CLK; 23 | #endif 24 | timer_conf.timer_num = (ledc_timer_t)ledc_timer; 25 | esp_err_t err = ledc_timer_config(&timer_conf); 26 | if (err != ESP_OK) { 27 | ESP_LOGE(TAG, "ledc_timer_config failed for freq %d, rc=%x", xclk_freq_hz, err); 28 | } 29 | return err; 30 | } 31 | 32 | esp_err_t camera_enable_out_clock(camera_config_t* config) 33 | { 34 | periph_module_enable(PERIPH_LEDC_MODULE); 35 | 36 | esp_err_t err = xclk_timer_conf(config->ledc_timer, config->xclk_freq_hz); 37 | if (err != ESP_OK) { 38 | ESP_LOGE(TAG, "ledc_timer_config failed, rc=%x", err); 39 | return err; 40 | } 41 | 42 | ledc_channel_config_t ch_conf; 43 | ch_conf.gpio_num = config->pin_xclk; 44 | ch_conf.speed_mode = LEDC_HIGH_SPEED_MODE; 45 | ch_conf.channel = config->ledc_channel; 46 | ch_conf.intr_type = LEDC_INTR_DISABLE; 47 | ch_conf.timer_sel = config->ledc_timer; 48 | ch_conf.duty = 2; 49 | ch_conf.hpoint = 0; 50 | err = ledc_channel_config(&ch_conf); 51 | if (err != ESP_OK) { 52 | ESP_LOGE(TAG, "ledc_channel_config failed, rc=%x", err); 53 | return err; 54 | } 55 | return ESP_OK; 56 | } 57 | 58 | void camera_disable_out_clock() 59 | { 60 | periph_module_disable(PERIPH_LEDC_MODULE); 61 | } 62 | -------------------------------------------------------------------------------- /components/esp32-camera/sensors/private_include/ov2640.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * OV2640 driver. 7 | * 8 | */ 9 | #ifndef __OV2640_H__ 10 | #define __OV2640_H__ 11 | #include "sensor.h" 12 | int ov2640_init(sensor_t *sensor); 13 | #endif // __OV2640_H__ 14 | -------------------------------------------------------------------------------- /components/esp32-camera/sensors/private_include/ov2640_regs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * OV2640 register definitions. 7 | */ 8 | #ifndef __REG_REGS_H__ 9 | #define __REG_REGS_H__ 10 | /* DSP register bank FF=0x00*/ 11 | #define R_BYPASS 0x05 12 | #define QS 0x44 13 | #define CTRLI 0x50 14 | #define HSIZE 0x51 15 | #define VSIZE 0x52 16 | #define XOFFL 0x53 17 | #define YOFFL 0x54 18 | #define VHYX 0x55 19 | #define DPRP 0x56 20 | #define TEST 0x57 21 | #define ZMOW 0x5A 22 | #define ZMOH 0x5B 23 | #define ZMHH 0x5C 24 | #define BPADDR 0x7C 25 | #define BPDATA 0x7D 26 | #define CTRL2 0x86 27 | #define CTRL3 0x87 28 | #define SIZEL 0x8C 29 | #define HSIZE8 0xC0 30 | #define VSIZE8 0xC1 31 | #define CTRL0 0xC2 32 | #define CTRL1 0xC3 33 | #define R_DVP_SP 0xD3 34 | #define IMAGE_MODE 0xDA 35 | #define RESET 0xE0 36 | #define MS_SP 0xF0 37 | #define SS_ID 0xF7 38 | #define SS_CTRL 0xF7 39 | #define MC_BIST 0xF9 40 | #define MC_AL 0xFA 41 | #define MC_AH 0xFB 42 | #define MC_D 0xFC 43 | #define P_CMD 0xFD 44 | #define P_STATUS 0xFE 45 | #define BANK_SEL 0xFF 46 | 47 | #define CTRLI_LP_DP 0x80 48 | #define CTRLI_ROUND 0x40 49 | 50 | #define CTRL0_AEC_EN 0x80 51 | #define CTRL0_AEC_SEL 0x40 52 | #define CTRL0_STAT_SEL 0x20 53 | #define CTRL0_VFIRST 0x10 54 | #define CTRL0_YUV422 0x08 55 | #define CTRL0_YUV_EN 0x04 56 | #define CTRL0_RGB_EN 0x02 57 | #define CTRL0_RAW_EN 0x01 58 | 59 | #define CTRL2_DCW_EN 0x20 60 | #define CTRL2_SDE_EN 0x10 61 | #define CTRL2_UV_ADJ_EN 0x08 62 | #define CTRL2_UV_AVG_EN 0x04 63 | #define CTRL2_CMX_EN 0x01 64 | 65 | #define CTRL3_BPC_EN 0x80 66 | #define CTRL3_WPC_EN 0x40 67 | 68 | #define R_DVP_SP_AUTO_MODE 0x80 69 | 70 | #define R_BYPASS_DSP_EN 0x00 71 | #define R_BYPASS_DSP_BYPAS 0x01 72 | 73 | #define IMAGE_MODE_Y8_DVP_EN 0x40 74 | #define IMAGE_MODE_JPEG_EN 0x10 75 | #define IMAGE_MODE_YUV422 0x00 76 | #define IMAGE_MODE_RAW10 0x04 77 | #define IMAGE_MODE_RGB565 0x08 78 | #define IMAGE_MODE_HREF_VSYNC 0x02 79 | #define IMAGE_MODE_LBYTE_FIRST 0x01 80 | 81 | #define RESET_MICROC 0x40 82 | #define RESET_SCCB 0x20 83 | #define RESET_JPEG 0x10 84 | #define RESET_DVP 0x04 85 | #define RESET_IPU 0x02 86 | #define RESET_CIF 0x01 87 | 88 | #define MC_BIST_RESET 0x80 89 | #define MC_BIST_BOOT_ROM_SEL 0x40 90 | #define MC_BIST_12KB_SEL 0x20 91 | #define MC_BIST_12KB_MASK 0x30 92 | #define MC_BIST_512KB_SEL 0x08 93 | #define MC_BIST_512KB_MASK 0x0C 94 | #define MC_BIST_BUSY_BIT_R 0x02 95 | #define MC_BIST_MC_RES_ONE_SH_W 0x02 96 | #define MC_BIST_LAUNCH 0x01 97 | 98 | 99 | typedef enum { 100 | BANK_DSP, BANK_SENSOR, BANK_MAX 101 | } ov2640_bank_t; 102 | 103 | /* Sensor register bank FF=0x01*/ 104 | #define GAIN 0x00 105 | #define COM1 0x03 106 | #define REG04 0x04 107 | #define REG08 0x08 108 | #define COM2 0x09 109 | #define REG_PID 0x0A 110 | #define REG_VER 0x0B 111 | #define COM3 0x0C 112 | #define COM4 0x0D 113 | #define AEC 0x10 114 | #define CLKRC 0x11 115 | #define COM7 0x12 116 | #define COM8 0x13 117 | #define COM9 0x14 /* AGC gain ceiling */ 118 | #define COM10 0x15 119 | #define HSTART 0x17 120 | #define HSTOP 0x18 121 | #define VSTART 0x19 122 | #define VSTOP 0x1A 123 | #define MIDH 0x1C 124 | #define MIDL 0x1D 125 | #define AEW 0x24 126 | #define AEB 0x25 127 | #define VV 0x26 128 | #define REG2A 0x2A 129 | #define FRARL 0x2B 130 | #define ADDVSL 0x2D 131 | #define ADDVSH 0x2E 132 | #define YAVG 0x2F 133 | #define HSDY 0x30 134 | #define HEDY 0x31 135 | #define REG32 0x32 136 | #define ARCOM2 0x34 137 | #define REG45 0x45 138 | #define FLL 0x46 139 | #define FLH 0x47 140 | #define COM19 0x48 141 | #define ZOOMS 0x49 142 | #define COM22 0x4B 143 | #define COM25 0x4E 144 | #define BD50 0x4F 145 | #define BD60 0x50 146 | #define REG5D 0x5D 147 | #define REG5E 0x5E 148 | #define REG5F 0x5F 149 | #define REG60 0x60 150 | #define HISTO_LOW 0x61 151 | #define HISTO_HIGH 0x62 152 | 153 | #define REG04_DEFAULT 0x28 154 | #define REG04_HFLIP_IMG 0x80 155 | #define REG04_VFLIP_IMG 0x40 156 | #define REG04_VREF_EN 0x10 157 | #define REG04_HREF_EN 0x08 158 | #define REG04_SET(x) (REG04_DEFAULT|x) 159 | 160 | #define COM2_STDBY 0x10 161 | #define COM2_OUT_DRIVE_1x 0x00 162 | #define COM2_OUT_DRIVE_2x 0x01 163 | #define COM2_OUT_DRIVE_3x 0x02 164 | #define COM2_OUT_DRIVE_4x 0x03 165 | 166 | #define COM3_DEFAULT 0x38 167 | #define COM3_BAND_50Hz 0x04 168 | #define COM3_BAND_60Hz 0x00 169 | #define COM3_BAND_AUTO 0x02 170 | #define COM3_BAND_SET(x) (COM3_DEFAULT|x) 171 | 172 | #define COM7_SRST 0x80 173 | #define COM7_RES_UXGA 0x00 /* UXGA */ 174 | #define COM7_RES_SVGA 0x40 /* SVGA */ 175 | #define COM7_RES_CIF 0x20 /* CIF */ 176 | #define COM7_ZOOM_EN 0x04 /* Enable Zoom */ 177 | #define COM7_COLOR_BAR 0x02 /* Enable Color Bar Test */ 178 | 179 | #define COM8_DEFAULT 0xC0 180 | #define COM8_BNDF_EN 0x20 /* Enable Banding filter */ 181 | #define COM8_AGC_EN 0x04 /* AGC Auto/Manual control selection */ 182 | #define COM8_AEC_EN 0x01 /* Auto/Manual Exposure control */ 183 | #define COM8_SET(x) (COM8_DEFAULT|x) 184 | 185 | #define COM9_DEFAULT 0x08 186 | #define COM9_AGC_GAIN_2x 0x00 /* AGC: 2x */ 187 | #define COM9_AGC_GAIN_4x 0x01 /* AGC: 4x */ 188 | #define COM9_AGC_GAIN_8x 0x02 /* AGC: 8x */ 189 | #define COM9_AGC_GAIN_16x 0x03 /* AGC: 16x */ 190 | #define COM9_AGC_GAIN_32x 0x04 /* AGC: 32x */ 191 | #define COM9_AGC_GAIN_64x 0x05 /* AGC: 64x */ 192 | #define COM9_AGC_GAIN_128x 0x06 /* AGC: 128x */ 193 | #define COM9_AGC_SET(x) (COM9_DEFAULT|(x<<5)) 194 | 195 | #define COM10_HREF_EN 0x80 /* HSYNC changes to HREF */ 196 | #define COM10_HSYNC_EN 0x40 /* HREF changes to HSYNC */ 197 | #define COM10_PCLK_FREE 0x20 /* PCLK output option: free running PCLK */ 198 | #define COM10_PCLK_EDGE 0x10 /* Data is updated at the rising edge of PCLK */ 199 | #define COM10_HREF_NEG 0x08 /* HREF negative */ 200 | #define COM10_VSYNC_NEG 0x02 /* VSYNC negative */ 201 | #define COM10_HSYNC_NEG 0x01 /* HSYNC negative */ 202 | 203 | #define CTRL1_AWB 0x08 /* Enable AWB */ 204 | 205 | #define VV_AGC_TH_SET(h,l) ((h<<4)|(l&0x0F)) 206 | 207 | #define REG32_UXGA 0x36 208 | #define REG32_SVGA 0x09 209 | #define REG32_CIF 0x89 210 | 211 | #define CLKRC_2X 0x80 212 | #define CLKRC_2X_UXGA (0x01 | CLKRC_2X) 213 | #define CLKRC_2X_SVGA CLKRC_2X 214 | #define CLKRC_2X_CIF CLKRC_2X 215 | 216 | #endif //__REG_REGS_H__ 217 | -------------------------------------------------------------------------------- /components/esp32-camera/sensors/private_include/ov3660.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * OV3660 driver. 7 | * 8 | */ 9 | #ifndef __OV3660_H__ 10 | #define __OV3660_H__ 11 | 12 | #include "sensor.h" 13 | 14 | int ov3660_init(sensor_t *sensor); 15 | 16 | #endif // __OV3660_H__ 17 | -------------------------------------------------------------------------------- /components/esp32-camera/sensors/private_include/ov5640.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __OV5640_H__ 3 | #define __OV5640_H__ 4 | 5 | #include "sensor.h" 6 | 7 | int ov5640_init(sensor_t *sensor); 8 | 9 | #endif // __OV5640_H__ 10 | -------------------------------------------------------------------------------- /components/esp32-camera/sensors/private_include/ov7725.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * OV7725 driver. 7 | * 8 | */ 9 | #ifndef __OV7725_H__ 10 | #define __OV7725_H__ 11 | #include "sensor.h" 12 | 13 | int ov7725_init(sensor_t *sensor); 14 | #endif // __OV7725_H__ 15 | -------------------------------------------------------------------------------- /components/fb_gfx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_SRCS "fb_gfx.c") 2 | set(COMPONENT_ADD_INCLUDEDIRS "include") 3 | set(COMPONENT_PRIV_INCLUDEDIRS "") 4 | set(COMPONENT_PRIV_REQUIRES newlib) 5 | register_component() -------------------------------------------------------------------------------- /components/fb_gfx/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS := include 2 | COMPONENT_SRCDIRS := . 3 | -------------------------------------------------------------------------------- /components/fb_gfx/fb_gfx.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #include "stdint.h" 15 | #include "stdarg.h" 16 | #include "string.h" 17 | #include "stdio.h" 18 | #include "stdlib.h" 19 | #include "fb_gfx.h" 20 | 21 | typedef struct { // Data stored PER GLYPH 22 | uint16_t bitmapOffset; // Pointer into GFXfont->bitmap 23 | uint8_t width, height; // Bitmap dimensions in pixels 24 | uint8_t xAdvance; // Distance to advance cursor (x axis) 25 | int8_t xOffset, yOffset; // Dist from cursor pos to UL corner 26 | } GFXglyph; 27 | 28 | typedef struct { // Data stored for FONT AS A WHOLE: 29 | uint8_t *bitmap; // Glyph bitmaps, concatenated 30 | GFXglyph *glyph; // Glyph array 31 | uint8_t first, last; // ASCII extents 32 | uint8_t yAdvance; // Newline distance (y axis) 33 | uint8_t yOffset; // Y offset of the font zero line (y axis) 34 | } GFXfont; 35 | 36 | #include "FreeMonoBold12pt7b.h"//14x24 37 | #define gfxFont ((GFXfont*)(&FreeMonoBold12pt7b)) 38 | 39 | void fb_gfx_fillRect(fb_data_t *fb, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color) 40 | { 41 | int32_t line_step = (fb->width - w) * 3; 42 | uint8_t *data = fb->data + ((x + (y * fb->width)) * 3); 43 | uint8_t c0 = color >> 16; 44 | uint8_t c1 = color >> 8; 45 | uint8_t c2 = color; 46 | for (int i=0; ifirst) || (c > gfxFont->last)) { 75 | return xa; 76 | } 77 | 78 | c -= gfxFont->first; 79 | 80 | glyph = &(gfxFont->glyph[c]); 81 | bitmap = gfxFont->bitmap + glyph->bitmapOffset; 82 | 83 | xa = glyph->xAdvance; 84 | x += glyph->xOffset; 85 | y += glyph->yOffset; 86 | y += gfxFont->yOffset; 87 | line_width = 0; 88 | 89 | for(yy=0; yyheight; yy++) { 90 | for(xx=0; xxwidth; xx++) { 91 | if(bit == 0) { 92 | bits = *bitmap++; 93 | bit = 0x80; 94 | } 95 | if(bits & bit) { 96 | line_width++; 97 | } else if (line_width) { 98 | fb_gfx_drawFastHLine(fb, x+xx-line_width, y+yy, line_width, color); 99 | line_width=0; 100 | } 101 | bit >>= 1; 102 | } 103 | if (line_width) { 104 | fb_gfx_drawFastHLine(fb, x+xx-line_width, y+yy, line_width, color); 105 | line_width=0; 106 | } 107 | } 108 | return xa; 109 | } 110 | 111 | uint32_t fb_gfx_print(fb_data_t *fb, int x, int y, uint32_t color, const char * str) 112 | { 113 | uint32_t l = 0; 114 | int xc = x, yc = y, lc = fb->width - gfxFont->glyph[0].xAdvance; 115 | uint8_t fh = gfxFont->yAdvance; 116 | char c = *str++; 117 | while(c){ 118 | if(c != '\r'){ 119 | if(c == '\n'){ 120 | yc += fh; 121 | xc = x; 122 | } else { 123 | if(xc > lc){ 124 | yc += fh; 125 | xc = x; 126 | } 127 | xc += fb_gfx_putc(fb, xc, yc, color, c); 128 | } 129 | } 130 | l++; 131 | c = *str++; 132 | } 133 | return l; 134 | } 135 | 136 | uint32_t fb_gfx_printf(fb_data_t *fb, int32_t x, int32_t y, uint32_t color, const char *format, ...) 137 | { 138 | char loc_buf[64]; 139 | char * temp = loc_buf; 140 | int len; 141 | va_list arg; 142 | va_list copy; 143 | va_start(arg, format); 144 | va_copy(copy, arg); 145 | len = vsnprintf(loc_buf, sizeof(loc_buf), format, arg); 146 | va_end(copy); 147 | if(len >= sizeof(loc_buf)){ 148 | temp = (char*)malloc(len+1); 149 | if(temp == NULL) { 150 | return 0; 151 | } 152 | } 153 | vsnprintf(temp, len+1, format, arg); 154 | va_end(arg); 155 | fb_gfx_print(fb, x, y, color, temp); 156 | if(len > 64){ 157 | free(temp); 158 | } 159 | return len; 160 | } 161 | -------------------------------------------------------------------------------- /components/fb_gfx/include/fb_gfx.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef _FB_GFX_H_ 15 | #define _FB_GFX_H_ 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | typedef enum { 22 | FB_RGB888, FB_BGR888, FB_RGB565, FB_BGR565 23 | } fb_format_t; 24 | 25 | typedef struct { 26 | int width; 27 | int height; 28 | int bytes_per_pixel; 29 | fb_format_t format; 30 | uint8_t * data; 31 | } fb_data_t; 32 | 33 | void fb_gfx_fillRect (fb_data_t *fb, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color); 34 | void fb_gfx_drawFastHLine(fb_data_t *fb, int32_t x, int32_t y, int32_t w, uint32_t color); 35 | void fb_gfx_drawFastVLine(fb_data_t *fb, int32_t x, int32_t y, int32_t h, uint32_t color); 36 | uint8_t fb_gfx_putc (fb_data_t *fb, int32_t x, int32_t y, uint32_t color, unsigned char c); 37 | uint32_t fb_gfx_print (fb_data_t *fb, int32_t x, int32_t y, uint32_t color, const char * str); 38 | uint32_t fb_gfx_printf (fb_data_t *fb, int32_t x, int32_t y, uint32_t color, const char *format, ...); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif /* _FB_GFX_H_ */ 45 | -------------------------------------------------------------------------------- /docs/_static/get-started/esp-eye_callout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/docs/_static/get-started/esp-eye_callout.png -------------------------------------------------------------------------------- /docs/_static/get-started/face_id_enrollment_cn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/docs/_static/get-started/face_id_enrollment_cn.jpg -------------------------------------------------------------------------------- /docs/_static/get-started/face_id_enrollment_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/docs/_static/get-started/face_id_enrollment_en.png -------------------------------------------------------------------------------- /docs/_static/get-started/wifi_connection.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/docs/_static/get-started/wifi_connection.jpeg -------------------------------------------------------------------------------- /docs/_static/get-started/work_flow_cn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/docs/_static/get-started/work_flow_cn.jpg -------------------------------------------------------------------------------- /docs/_static/get-started/work_flow_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/docs/_static/get-started/work_flow_en.png -------------------------------------------------------------------------------- /docs/docs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/docs/docs.png -------------------------------------------------------------------------------- /docs/en/Camera_connections.md: -------------------------------------------------------------------------------- 1 | 2 | # Connecting 3 | 4 | The table below lists the specific pins used in this example for connecting the ESP32 module and the camera module. 5 | 6 | | Interface | Camera Pin | ESP32-WROVER | ESP-EYE | 7 | | :--- | :---: | :---: | :---: | 8 | | SCCB Clock | SIOC | IO27 | IO23 | 9 | | SCCB Data | SIOD | IO26 | IO18 | 10 | | System Clock | XCLK | IO21 | IO4 | 11 | | Vertical Sync | VSYNC | IO25 | IO5 | 12 | | Horizontal Reference | HREF | IO23 | IO27 | 13 | | Pixel Clock | PCLK | IO22 | IO25 | 14 | | Pixel Data Bit 0 | D2 | IO4 | IO34 | 15 | | Pixel Data Bit 1 | D3 | IO5 | IO13 | 16 | | Pixel Data Bit 2 | D4 | IO18 | IO14 | 17 | | Pixel Data Bit 3 | D5 | IO19 | IO35 | 18 | | Pixel Data Bit 4 | D6 | IO36 | IO39 | 19 | | Pixel Data Bit 5 | D7 | IO39 | IO38 | 20 | | Pixel Data Bit 6 | D8 | IO34 | IO37 | 21 | | Pixel Data Bit 7 | D9 | IO35 | IO36 | 22 | | Camera Reset | RESET | -1 | -1 | 23 | | Camera Power Down | PWDN | -1 | -1 | 24 | | Power Supply 3.3V | 3V3 | 3V3 | 3v3 | 25 | | Ground | GND | GND | GND | 26 | 27 | > The pin mapping will be slightly different if you use other ESP32 modules. 28 | 29 | -------------------------------------------------------------------------------- /docs/en/get-started/ESP-EYE_Getting_Started_Guide.md: -------------------------------------------------------------------------------- 1 | # ESP-EYE Getting Started Guide 2 | 3 | [[中文]](../../zh_CN/get-started/ESP-EYE_Getting_Started_Guide.md) 4 | 5 | ## What You Need 6 | 7 | * 1 × ESP-EYE V2.1 board 8 | * 1 × Micro USB cable 9 | * 1 × PC with Windows, Linux or Mac OS 10 | 11 | ## Overview 12 | 13 | ESP-EYE is an ESP32-based development board that integrates a digital microphone, an 8 MB PSRAM and a 4 MB flash, while also providing an external 2-Megapixel camera. These features make the board ideal for applications relating to face detection, face recognition and speech recognition. Besides, the board can also support image transmission over Wi-Fi and debugging through a Micro USB port, which enables the development of advanced AI solutions. 14 | 15 | ## Hardware Preparation 16 | 17 | The list and figure below describe the key components, interfaces and functions of the ESP-EYE development board: 18 | 19 | ![ESP-EYE image](../../_static/get-started/esp-eye_callout.png) 20 | 21 | * **3D_PIFA Antenna** 22 | 23 | A 3D PIFA antenna. With the R14 resistor users can select the external IPEX antenna, whereas with the R15 resistor they can select the 3D antenna. 24 | 25 | * **IPEX Connector** 26 | 27 | Used for connecting the external IPEX antenna. With the R14 resistor users can select the external IPEX antenna, whereas with the R15 resistor they can select the 3D antenna. 28 | 29 | * **ESP32 Chip** 30 | 31 | A 2.4 GHz Wi-Fi and Bluetooth combo chip. 32 | 33 | * **Crystal Oscillator** 34 | 35 | Provides an external clock to ESP32. 36 | 37 | * **Flash & PSRAM** 38 | 39 | Provides memory for storing applications. 40 | 41 | * **CP2102 USB-to-UART Chip** 42 | 43 | Converts the USB signals to UART signals. 44 | 45 | * **USB Port** 46 | 47 | Provides power supply to the whole system. 48 | 49 | * **LDO Power Supply** 50 | 51 | Provides the required power supply to the ESP32 chip, camera and LED indicators. 52 | 53 | * **Side Tactile Button** 54 | 55 | A function key. 56 | 57 | * **Top Tactile Button** 58 | 59 | Reset/Boot button. We recommend that you do not configure this button for other uses. 60 | 61 | * **LED Indicators** 62 | 63 | The board has a red and a white indicator. Different flashing combinations of the red and white indicators reflect the different statuses of the board, e.g. waking up, networking, face detection, face recognition, face enrollment and face recognition. 64 | 65 | * **Camera** 66 | 67 | An external 2-Megapixel camera module for face detection, face recognition and Face ID enrollment. 68 | 69 | * **Camera Connector** 70 | 71 | Used for connecting the external camera. 72 | 73 | * **MIC** 74 | 75 | A digital microphone for voice control functions. 76 | 77 | * **SPI Port** 78 | 79 | A reserved port for data transmission. 80 | 81 | 82 | -------------------------------------------------------------------------------- /docs/zh_CN/get-started/ESP-EYE_Getting_Started_Guide.md: -------------------------------------------------------------------------------- 1 | # ESP-EYE 入门指南 2 | 3 | [[EN]](../../en/get-started/ESP-EYE_Getting_Started_Guide.md) 4 | 5 | ## 准备工作 6 | 7 | * 1 × ESP-EYE V2.1 开发板 8 | * 1 × Micro USB B 电缆 9 | * 1 × PC(Windows、Linux 或 Mac OS) 10 | 11 | ## 简介 12 | 13 | ESP-EYE 是一款面向人脸识别和语音识别市场的开发板,搭载 ESP32 芯片、200 W 像素摄像头、数字麦克风、8 MB PSRAM 和 4 MB Flash,可满足各种 AI 应用开发需求。此外,该开发板还支持 Wi-Fi 图像传输、Micro USB 调试和供电,可以实现语音唤醒、人脸检测与识别等功能,可协助用户开发高度集成的 AI 解决方案。 14 | 15 | ## 硬件组成 16 | 17 | ESP-EYE 开发板的产品图请见下方: 18 | 19 | ![ESP-EYE image](../../_static/get-started/esp-eye_callout.png) 20 | 21 | 具体包括以下硬件组成: 22 | 23 | * **3D_PIFA Antenna(3D_PIFA 天线)** 24 | 25 | 3D PIFA 天线。用户可通过选贴 R14/R15 电阻,选用 3D 天线(选贴 R15)或外接 IPEX 天线(选贴 R14)。 26 | 27 | * **IPEX Connector(IPEX 连接器)** 28 | 29 | 用于外接 IPEX 天线。用户可通过选贴 R14/R15 电阻,选用 3D 天线(选贴 R15)或外接 IPEX 天线(选贴 R14)。 30 | 31 | * **ESP32 Chip(ESP32 芯片)** 32 | 33 | 集成 2.4 GHz Wi-Fi 和蓝牙双模的单芯片。 34 | 35 | * **Crystal(晶振)** 36 | 37 | ESP32 的外部晶振时钟源。 38 | 39 | * **Flash & PSRAM** 40 | 41 | 存储芯片,用于储存程序。 42 | 43 | * **CP2102 USB-UART Chip(USB 转 UART 芯片)** 44 | 45 | 实现 USB 到 UART 的转换功能。 46 | 47 | * **USB Port(USB 供电接口)** 48 | 49 | 为整个系统供电。 50 | 51 | * **LDO Power Supply(LDO 供电芯片)** 52 | 53 | 为 ESP32 芯片、摄像头、LED 指示灯等部件提供各自所需的电压。 54 | 55 | * **Side Tactile Button(侧面轻触按键)** 56 | 57 | 功能按键。 58 | 59 | * **Top Tactile Button(正面轻触按键)** 60 | 61 | 用于 ESP32 的 RST(复位)、BOOT(下载),不建议设置他用。 62 | 63 | * **LED 指示灯** 64 | 65 | 红灯和白灯各一个,可用于指示唤醒、联网、人脸检测、人脸录入、人脸识别等不同过程中的状态。 66 | 67 | * **Camera(摄像头)** 68 | 69 | 实现检测识别等功能。 70 | 71 | * **Camera Connector(摄像头连接器)** 72 | 73 | 用于外接摄像头模块。 74 | 75 | * **MIC(麦克风)** 76 | 77 | 数字型麦克风,实现语音控制功能。 78 | 79 | * **SPI Port(SPI 接口)** 80 | 81 | 预留数据传输接口。 82 | 83 | 84 | ## 软件开发 85 | 86 | ESP-EYE 可在 Linux、MacOs、Windows 操作系统中完成软件烧写。目前,必须进行开发环境的工具链配置,详见下方介绍。 87 | 88 | ### 准备工作 89 | 90 | - 阅读 [ESP-IDF编程指南](https://docs.espressif.com/projects/esp-idf/zh_CN/v3.1.1/get-started/index.html),参考相应章节,配置工具链; 91 | - 准备 Micro USB 线,用于连接 PC 和 ESP-EYE 开发板; 92 | - 选择一款适合开发环境的工具,例如 Terminal (Linux/MacOS) 或 MinGW (Windows) 等。 93 | 94 | ### 软件获取 95 | 96 | 打开终端(例如 Linux 环境下的 Terminal),将软件代码克隆到本地: 97 | 98 | ``` 99 | git clone --recursive https://github.com/espressif/esp-who.git 100 | ``` 101 | 102 | 执行以上命令会默认生成一个 `esp-who` 的文件夹。 103 | 104 | > 注意不要忘记 `--recursive` 选项。如果你克隆 ESP-IDF 时没有带这个选项,你还需要运进入相应文件夹中,执行以下命令下载相应的子模块: 105 | ``` 106 | git submodule update --init --recursive 107 | ``` 108 | 109 | ### 设置路径 110 | 111 | 请参考[设置路径](https://docs.espressif.com/projects/esp-idf/zh_CN/v3.1.1/get-started/index.html#get-started-setup-path)章节,将 `IDF_PATH` 设置为 `esp-who/esp-idf`。 112 | 113 | ### 软件烧写 114 | 115 | 下面,我们以 Linux 环境为例,介绍向 ESP-EYE 烧写程序的过程: 116 | 117 | - 首先将 ESP-EYE 接入 PC,接入即上电; 118 | - 通过命令 `ls /dev/ttyUSB*` 查看开发板是否成功接入 PC。成功接入后,列表将新增类似 `/dev/ttyUSB0` 的信息; 119 | - 进入一个 example 工程文件中,例如 `cd esp-who/examples/single_chip/recognition_solution`; 120 | - 执行 `make defconfig` 进行默认配置; 121 | - 执行 `make menuconfig`,在 `Serial flasher config` 中设置 `Default serial port` 设备名称(与第二步查看的设备名称一致,一般设置为 `/dev/ttyUSB0`),保存退出; 122 | - 执行 `make flash`,进行软件烧写。 123 | 124 | ### 终端获取日志 125 | 126 | 下面,我们以 Linux 环境为例,介绍如何查看日志: 127 | 128 | - 打开终端; 129 | - 执行 `make monitor`。 130 | 131 | > 注意:这个过程会重启开发板。 132 | 133 | ### 交互功能 134 | 135 | ESP-EYE 开发板的工作流程如下图所示: 136 | 137 | ![esp-eye-workflow](../../_static/get-started/work_flow_cn.jpg) 138 | 139 | 140 | #### 1. 语音唤醒 141 | 142 | 开发板上电后,会进入“等待唤醒”状态(红灯常亮、白灯常灭),需要用户通过语音进行唤醒。支持“Hi 乐鑫”唤醒,当用户说出“Hi 乐鑫”的唤醒词后,开发板唤醒并进入“等待联网”状态(红灯闪烁,白灯常灭)。此时,用户可进行联网操作。 143 | 144 | #### 2. 连接网络 145 | 146 | 用户可通过 PC、手机等设备,连接 ESP-EYE 创建的 Wi-Fi 热点。该热点的默认信息如下: 147 | 148 | - 用户名:esp-eye-xxxx(xxxx 为设备 MAC 地址) 149 | - 密码:无需密码 150 | 151 | 用户也可通过如下方式,自行设置用户名和密码: 152 | 153 | - 打开终端; 154 | - 执行 `make menuconfig`,并按照下图进行设置: 155 | 156 | ![wifi connection](../../_static/get-started/wifi_connection.jpeg) 157 | 158 | > 注:用户重新设置 Wi-Fi 热点的用户名和密码后,需要重新进行软件烧录。 159 | 160 | #### 3. 人脸检测 161 | 162 | 联网成功后,ESP-EYE 会进行“人脸检测”。用户可以打开浏览器,输入地址 `192.168.4.1/face_stream`,在网页上即可看到实时图像信息。此时,开发板红灯熄灭、白灯常亮。 163 | 164 | #### 4. 人脸识别 165 | 166 | 当开发板检测到人脸时,如已存在录入的 Face ID,则开发板将进行“人脸识别”: 167 | 168 | - “人脸识别”匹配成功 -- 开发板红灯闪烁 1 次,网页显示 **HELLO ID XXX** 169 | - “人脸识别”匹配失败 -- 开发板无反应,网页显示 **WHO?**” 170 | 171 | 否则,开发板仅进行“人脸检测”。此时,若用户希望使用人脸识别功能,则请首先录入至少一个 Face ID。 172 | 173 | #### 5. 人脸录入与删除 174 | 175 | 在联网成功的前提下,可通过摄像头采集人脸,录入 Face ID。 176 | 177 | ##### 5.1 录入 Face ID 178 | 179 | ![录入 Face ID](../../_static/get-started/face_id_enrollment_cn.jpg) 180 | 181 | - 用户单击侧面轻触按键,可进入“录入 Face ID”(红灯常亮),网页显示: **START ENROLLING**; 182 | - 用户面对摄像头,开始采集人像。每次成功一次采集,开发板将红灯闪烁,网页显示对应的采集次数,比如 **THE 1st SAMPLE** 等。默认情况下,用户每录入一个 Face ID 需要采集 3 次人像(可配置)。在人像采集过程中,如果红灯长时间未闪烁,建议用户调整姿态和角度,然后再试; 183 | - 人像采集完成后,开发板红灯常灭,表明已完成录入该 Face ID。此时,网页显示:**ENROLLED FACE ID xxx**; 184 | - Face ID 录入成功后,系统将返回“人脸检测”。 185 | 186 | 目前,ESP-EYE 开发板默认可录入 10 个 Face ID(可配置,具体与用户的 flash 内存分配有关)。 187 | 188 | ##### 5.2 删除 Face ID 189 | 190 | - 用户单击表面BOOT按键,进入“删除 FACE ID”; 191 | - 双击后,开发板白灯闪烁,系统将自动删除系统中存在的最早一条 FACE ID,终端显示:**XXX ID(S) LEFT**。 192 | 193 | #### 异常情况 194 | 195 | 当出现“网络断开”或“联网超时”等异常情况时,开发板会回到“等待唤醒”状态。 196 | -------------------------------------------------------------------------------- /docs/使用指南.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/docs/使用指南.docx -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | make -j8 4 | 5 | make flash 6 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | set(EXTRA_COMPONENT_DIRS ../../../components) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(camera_web_server) 9 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := camera_web_server 7 | 8 | SOLUTION_PATH ?= $(abspath $(shell pwd))/../../.. 9 | 10 | include $(SOLUTION_PATH)/components/component_conf.mk 11 | include $(IDF_PATH)/make/project.mk 12 | 13 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/README.md: -------------------------------------------------------------------------------- 1 | # Camera with Web Server 2 | 3 | # Preparation 4 | 5 | To run this example, you need the following components: 6 | 7 | * An ESP32 Module: Either **ESP32-CAM**, which we highly recommend for beginners, is used in this example. 8 | * A Camera Module: Either **OV2640** or **OV3660** or **OV5640** image sensor, which we highly recommend for beginners, is used in this example. 9 | 10 | # Quick Start 11 | 12 | After you've completed the hardware settings, please follow the steps below: 13 | 14 | 1. **Connect** the camera to ESP32 module. For connection pins, please see [here](../../../docs/en/Camera_connections.md) 15 | 2. **Configure** the example through `idf.py menuconfig`; 16 | 3. **Build And Flash** the application to ESP32; 17 | 4. **Open Your Browser** and point it to `http://[ip-of-esp32]/`; 18 | 5. **To Get Image** press `Get Still` or `Start Stream`; 19 | 6. **Use The Options** to enable/disable Face Detection, Face Recognition and more; 20 | t. **View The Stream** in a player like VLC: Open Network `http://[ip-of-esp32]:81/stream`; 21 | 22 | For more details of the http handler, please refer to [esp32-camera](https://github.com/espressif/esp32-camera). 23 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_SRCS "app_main.c" "app_camera.c" "app_httpd.c" "app_mdns.c" "app_wifi.c" "app_sd.c" "app_uart.c""app_smart_wifi.c") 2 | set(COMPONENT_ADD_INCLUDEDIRS "include") 3 | 4 | set(COMPONENT_REQUIRES 5 | esp32-camera 6 | esp-face 7 | nvs_flash 8 | esp_http_server 9 | fb_gfx 10 | mdns 11 | ) 12 | 13 | set(COMPONENT_EMBED_FILES 14 | "www/index_ov2640.html.gz" 15 | "www/index_ov3660.html.gz" 16 | "www/index_ov5640.html.gz" 17 | "www/monitor.html.gz") 18 | 19 | register_component() 20 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/Kconfig.projbuild: -------------------------------------------------------------------------------- 1 | menu "Camera Web Server" 2 | 3 | menu "WiFi Settings" 4 | config ESP_HOST_NAME 5 | string "Camera Host Name" 6 | default "" 7 | help 8 | Hostname that the camera will advertise over mDNS. 9 | 10 | config ESP_WIFI_SSID 11 | string "WiFi STA SSID" 12 | default "" 13 | help 14 | WiFi SSID (network name) to connect to or empty for Off. 15 | 16 | config ESP_WIFI_PASSWORD 17 | string "WiFi STA Password" 18 | default "" 19 | help 20 | WiFi Password if WEP/WPA/WPA2 or empty if Open. 21 | 22 | config ESP_WIFI_AP_SSID 23 | string "WiFi AP SSID" 24 | default "ESP32-Camera" 25 | help 26 | AP SSID (network name) to create or empty for Off. 27 | 28 | config ESP_WIFI_AP_PASSWORD 29 | string "WiFi AP Password" 30 | default "" 31 | help 32 | AP password for WPA2 or empty for Open. 33 | 34 | config MAX_STA_CONN 35 | int "Maximal STA connections" 36 | default 1 37 | help 38 | Max number of the STA connects to AP. 39 | 40 | config ESP_WIFI_AP_CHANNEL 41 | string "WiFi AP Channel" 42 | default "" 43 | help 44 | AP channel for better connection performance. 45 | 46 | config SERVER_IP 47 | string "WiFi AP IP Address" 48 | default "192.168.4.1" 49 | help 50 | IP address that the ESP will assign to it's AP interface. You can use this IP to connect to the camera after flashing. 51 | 52 | config ESP_MAXIMUM_RETRY 53 | int "Maximum retry" 54 | default 5 55 | help 56 | Set the Maximum retry to avoid station reconnecting to the AP unlimited when the AP is really inexistent. 57 | endmenu 58 | 59 | menu "LED Illuminator" 60 | config LED_ILLUMINATOR_ENABLED 61 | bool "LED Illuminator Enabled" 62 | default n 63 | help 64 | Enable an LED Flash or IR Illuminator 65 | 66 | config LED_LEDC_PIN 67 | depends on LED_ILLUMINATOR_ENABLED 68 | int "LED Illuminator GPIO Pin" 69 | range 0 33 70 | default 4 71 | help 72 | Set a pin to illuminate an onboard LED or IR Illuminator when streaming or taking snapshots. 73 | 74 | config LED_MAX_INTENSITY 75 | depends on LED_ILLUMINATOR_ENABLED 76 | int "LED Maximum Intensity (0-255)" 77 | range 0 255 78 | default 255 79 | help 80 | Limit the maximum intensity of the LED while streaming to prevent overheating (0-255). 81 | 82 | choice LED_LEDC_SPEED_MODE 83 | depends on LED_ILLUMINATOR_ENABLED 84 | bool "Select LEDC Timer Speed Mode" 85 | default LED_LEDC_LOW_SPEED_MODE 86 | help 87 | Select a speed mode for the LEDC channel 88 | 89 | config LED_LEDC_LOW_SPEED_MODE 90 | bool "LOW_SPEED_MODE" 91 | config LED_LEDC_HIGH_SPEED_MODE 92 | bool "HIGH_SPEED_MODE" 93 | endchoice 94 | 95 | config LED_LEDC_TIMER 96 | depends on LED_ILLUMINATOR_ENABLED 97 | int "LEDC Timer" 98 | range 0 3 99 | default 1 100 | help 101 | Select the LEDC Timer (0-3) 102 | 103 | config LED_LEDC_CHANNEL 104 | depends on LED_ILLUMINATOR_ENABLED 105 | int "LEDC Channel" 106 | range 0 7 107 | default 1 108 | help 109 | Select the LEDC Channel (0-7) 110 | endmenu 111 | 112 | menu "Camera Pins" 113 | choice CAMERA_MODEL 114 | bool "Select Camera Pinout" 115 | default CAMERA_MODEL_WROVER_KIT 116 | help 117 | Select Camera Pinout. 118 | 119 | config CAMERA_MODEL_WROVER_KIT 120 | bool "WROVER-KIT With OV2640 Module" 121 | config CAMERA_MODEL_ESP32_CAM_BOARD 122 | bool "ESP32 Camera Development Board" 123 | config CAMERA_MODEL_ESP_EYE 124 | bool "ESP_EYE DevKit" 125 | config CAMERA_MODEL_M5STACK_PSRAM 126 | bool "M5Stack Camera With PSRAM" 127 | config CAMERA_MODEL_M5STACK_WIDE 128 | bool "M5Stack Camera F (Wide)" 129 | config CAMERA_MODEL_AI_THINKER 130 | bool "ESP32-CAM by AI-Thinker" 131 | config CAMERA_MODEL_CUSTOM 132 | bool "Custom Camera Pinout" 133 | endchoice 134 | 135 | config CAMERA_PIN_PWDN 136 | depends on CAMERA_MODEL_CUSTOM 137 | int "Power Down pin" 138 | range -1 33 139 | default -1 140 | help 141 | Select Power Down pin or -1 for unmanaged. 142 | 143 | config CAMERA_PIN_RESET 144 | depends on CAMERA_MODEL_CUSTOM 145 | int "Reset pin" 146 | range -1 33 147 | default -1 148 | help 149 | Select Camera Reset pin or -1 for software reset. 150 | 151 | config CAMERA_PIN_XCLK 152 | depends on CAMERA_MODEL_CUSTOM 153 | int "XCLK pin" 154 | range 0 33 155 | default 21 156 | help 157 | Select Camera XCLK pin. 158 | 159 | config CAMERA_PIN_SIOD 160 | depends on CAMERA_MODEL_CUSTOM 161 | int "SIOD pin" 162 | range 0 33 163 | default 26 164 | help 165 | Select Camera SIOD pin. 166 | 167 | config CAMERA_PIN_SIOC 168 | depends on CAMERA_MODEL_CUSTOM 169 | int "SIOC pin" 170 | range 0 33 171 | default 27 172 | help 173 | Select Camera SIOC pin. 174 | 175 | config CAMERA_PIN_VSYNC 176 | depends on CAMERA_MODEL_CUSTOM 177 | int "VSYNC pin" 178 | range 0 39 179 | default 25 180 | help 181 | Select Camera VSYNC pin. 182 | 183 | config CAMERA_PIN_HREF 184 | depends on CAMERA_MODEL_CUSTOM 185 | int "HREF pin" 186 | range 0 39 187 | default 23 188 | help 189 | Select Camera HREF pin. 190 | 191 | config CAMERA_PIN_PCLK 192 | depends on CAMERA_MODEL_CUSTOM 193 | int "PCLK pin" 194 | range 0 39 195 | default 25 196 | help 197 | Select Camera PCLK pin. 198 | 199 | config CAMERA_PIN_Y2 200 | depends on CAMERA_MODEL_CUSTOM 201 | int "Y2 pin" 202 | range 0 39 203 | default 4 204 | help 205 | Select Camera Y2 pin. 206 | 207 | config CAMERA_PIN_Y3 208 | depends on CAMERA_MODEL_CUSTOM 209 | int "Y3 pin" 210 | range 0 39 211 | default 5 212 | help 213 | Select Camera Y3 pin. 214 | 215 | config CAMERA_PIN_Y4 216 | depends on CAMERA_MODEL_CUSTOM 217 | int "Y4 pin" 218 | range 0 39 219 | default 18 220 | help 221 | Select Camera Y4 pin. 222 | 223 | config CAMERA_PIN_Y5 224 | depends on CAMERA_MODEL_CUSTOM 225 | int "Y5 pin" 226 | range 0 39 227 | default 19 228 | help 229 | Select Camera Y5 pin. 230 | 231 | config CAMERA_PIN_Y6 232 | depends on CAMERA_MODEL_CUSTOM 233 | int "Y6 pin" 234 | range 0 39 235 | default 36 236 | help 237 | Select Camera Y6 pin. 238 | 239 | config CAMERA_PIN_Y7 240 | depends on CAMERA_MODEL_CUSTOM 241 | int "Y7 pin" 242 | range 0 39 243 | default 39 244 | help 245 | Select Camera Y7 pin. 246 | 247 | config CAMERA_PIN_Y8 248 | depends on CAMERA_MODEL_CUSTOM 249 | int "Y8 pin" 250 | range 0 39 251 | default 34 252 | help 253 | Select Camera Y8 pin. 254 | 255 | config CAMERA_PIN_Y9 256 | depends on CAMERA_MODEL_CUSTOM 257 | int "Y9 pin" 258 | range 0 39 259 | default 35 260 | help 261 | Select Camera Y9 pin. 262 | 263 | endmenu 264 | 265 | config ESP_FACE_DETECT_ENABLED 266 | bool "ESP-WHO Face Detection" 267 | default y 268 | help 269 | Enables ESP-WHO Face Detection through the web interface. 270 | 271 | choice ESP_FACE_DETECT_MODEL 272 | bool "Detection Model" 273 | depends on ESP_FACE_DETECT_ENABLED 274 | default ESP_FACE_DETECT_MTMN 275 | 276 | config ESP_FACE_DETECT_MTMN 277 | bool "MTMN" 278 | 279 | config ESP_FACE_DETECT_LSSH 280 | bool "LSSH" 281 | endchoice 282 | 283 | config ESP_FACE_RECOGNITION_ENABLED 284 | bool "ESP-WHO Face Recognition" 285 | depends on ESP_FACE_DETECT_MTMN 286 | default y 287 | help 288 | Enables ESP-WHO Face Recognition through the web interface. 289 | 290 | menu "VERSION" 291 | config ESP_CAM_VERSION 292 | string "esp_cam version" 293 | default "" 294 | help 295 | Set the SDk software version number. 296 | endmenu 297 | 298 | endmenu 299 | 300 | menu "board config" 301 | 302 | menu "SdCard storage" 303 | config ESP_SDCARD_STORAGE_ENABLED 304 | bool "SdCard storage" 305 | default n 306 | help 307 | Enables SdCard storage feature will automatically store camera data locally . 308 | 309 | endmenu 310 | 311 | menu "wifi sntp updata" 312 | config ESP_SNTP_ENABLED 313 | bool "sntp enabled" 314 | default n 315 | help 316 | Enables sntp. 317 | 318 | endmenu 319 | 320 | menu "smart config" 321 | config ESP_SMAERT_CONFIG 322 | bool "smart config enabled" 323 | default n 324 | help 325 | Enables smart config. 326 | 327 | endmenu 328 | 329 | endmenu -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/app_board.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2017 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | 25 | #include "string.h" 26 | #include "app_uart.h" 27 | #include "app_board.h" 28 | #include "app_sd.h" 29 | #include "app_smart_wifi.h" 30 | #include "app_camera.h" 31 | #include "app_wifi.h" 32 | #include "sdkconfig.h" 33 | 34 | void app_board_main(void) 35 | { 36 | app_camera_main(); 37 | #ifdef CONFIG_ESP_SMAERT_CONFIG 38 | initialise_wifi(); 39 | #else 40 | app_wifi_main(); 41 | #endif 42 | uart_init(); 43 | SdCard_init(); 44 | 45 | } -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/app_camera.c: -------------------------------------------------------------------------------- 1 | /* ESPRESSIF MIT License 2 | * 3 | * Copyright (c) 2018 4 | * 5 | * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case, 6 | * it is free of charge, to any person obtaining a copy of this software and associated 7 | * documentation files (the "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 10 | * to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * 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, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | #include "esp_log.h" 23 | #include "driver/ledc.h" 24 | #include "esp_camera.h" 25 | #include "app_camera.h" 26 | #include "sdkconfig.h" 27 | #include "nvs_flash.h" 28 | 29 | static const char *TAG = "app_camera"; 30 | 31 | void app_camera_main () 32 | { 33 | 34 | esp_err_t ret = nvs_flash_init(); 35 | if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { 36 | ESP_ERROR_CHECK(nvs_flash_erase()); 37 | ret = nvs_flash_init(); 38 | } 39 | ESP_ERROR_CHECK(ret); 40 | 41 | #if CONFIG_CAMERA_MODEL_ESP_EYE || CONFIG_CAMERA_MODEL_ESP32_CAM_BOARD 42 | /* IO13, IO14 is designed for JTAG by default, 43 | * to use it as generalized input, 44 | * firstly declair it as pullup input */ 45 | gpio_config_t conf; 46 | conf.mode = GPIO_MODE_INPUT; 47 | conf.pull_up_en = GPIO_PULLUP_ENABLE; 48 | conf.pull_down_en = GPIO_PULLDOWN_DISABLE; 49 | conf.intr_type = GPIO_INTR_DISABLE; 50 | conf.pin_bit_mask = 1LL << 13; 51 | gpio_config(&conf); 52 | conf.pin_bit_mask = 1LL << 14; 53 | gpio_config(&conf); 54 | #endif 55 | 56 | #ifdef CONFIG_LED_ILLUMINATOR_ENABLED 57 | gpio_set_direction(CONFIG_LED_LEDC_PIN,GPIO_MODE_OUTPUT); 58 | ledc_timer_config_t ledc_timer = { 59 | .duty_resolution = LEDC_TIMER_8_BIT, // resolution of PWM duty 60 | .freq_hz = 1000, // frequency of PWM signal 61 | .speed_mode = LEDC_LOW_SPEED_MODE, // timer mode 62 | .timer_num = CONFIG_LED_LEDC_TIMER // timer index 63 | }; 64 | ledc_channel_config_t ledc_channel = { 65 | .channel = CONFIG_LED_LEDC_CHANNEL, 66 | .duty = 0, 67 | .gpio_num = CONFIG_LED_LEDC_PIN, 68 | .speed_mode = LEDC_LOW_SPEED_MODE, 69 | .hpoint = 0, 70 | .timer_sel = CONFIG_LED_LEDC_TIMER 71 | }; 72 | #ifdef CONFIG_LED_LEDC_HIGH_SPEED_MODE 73 | ledc_timer.speed_mode = ledc_channel.speed_mode = LEDC_HIGH_SPEED_MODE; 74 | #endif 75 | switch (ledc_timer_config(&ledc_timer)) { 76 | case ESP_ERR_INVALID_ARG: ESP_LOGE(TAG, "ledc_timer_config() parameter error"); break; 77 | case ESP_FAIL: ESP_LOGE(TAG, "ledc_timer_config() Can not find a proper pre-divider number base on the given frequency and the current duty_resolution"); break; 78 | case ESP_OK: if (ledc_channel_config(&ledc_channel) == ESP_ERR_INVALID_ARG) { 79 | ESP_LOGE(TAG, "ledc_channel_config() parameter error"); 80 | } 81 | break; 82 | default: break; 83 | } 84 | #endif 85 | 86 | camera_config_t config; 87 | config.ledc_channel = LEDC_CHANNEL_0; 88 | config.ledc_timer = LEDC_TIMER_0; 89 | config.pin_d0 = Y2_GPIO_NUM; 90 | config.pin_d1 = Y3_GPIO_NUM; 91 | config.pin_d2 = Y4_GPIO_NUM; 92 | config.pin_d3 = Y5_GPIO_NUM; 93 | config.pin_d4 = Y6_GPIO_NUM; 94 | config.pin_d5 = Y7_GPIO_NUM; 95 | config.pin_d6 = Y8_GPIO_NUM; 96 | config.pin_d7 = Y9_GPIO_NUM; 97 | config.pin_xclk = XCLK_GPIO_NUM; 98 | config.pin_pclk = PCLK_GPIO_NUM; 99 | config.pin_vsync = VSYNC_GPIO_NUM; 100 | config.pin_href = HREF_GPIO_NUM; 101 | config.pin_sscb_sda = SIOD_GPIO_NUM; 102 | config.pin_sscb_scl = SIOC_GPIO_NUM; 103 | config.pin_pwdn = PWDN_GPIO_NUM; 104 | config.pin_reset = RESET_GPIO_NUM; 105 | config.xclk_freq_hz = 20000000;// 2 20000000 106 | config.pixel_format = PIXFORMAT_JPEG; 107 | //init with high specs to pre-allocate larger buffers 108 | config.frame_size = FRAMESIZE_QSXGA; 109 | config.jpeg_quality = 10; 110 | config.fb_count = 4;// 2 2 111 | 112 | // camera init 113 | esp_err_t err = esp_camera_init(&config); 114 | if (err != ESP_OK) { 115 | ESP_LOGE(TAG, "Camera init failed with error 0x%x", err); 116 | return; 117 | } 118 | 119 | sensor_t * s = esp_camera_sensor_get(); 120 | //initial sensors are flipped vertically and colors are a bit saturated 121 | if (s->id.PID == OV3660_PID) { 122 | s->set_vflip(s, 1);//flip it back 123 | s->set_brightness(s, 1);//up the blightness just a bit 124 | s->set_saturation(s, -2);//lower the saturation 125 | } 126 | //drop down frame size for higher initial frame rate 127 | s->set_framesize(s, FRAMESIZE_HD); 128 | } 129 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/app_main.c: -------------------------------------------------------------------------------- 1 | /* ESPRESSIF MIT License 2 | * 3 | * Copyright (c) 2018 4 | * 5 | * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case, 6 | * it is free of charge, to any person obtaining a copy of this software and associated 7 | * documentation files (the "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 10 | * to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * 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, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include "app_httpd.h" 24 | #include "app_mdns.h" 25 | #include "app_board.h" 26 | #include "esp_log.h" 27 | #include "sdkconfig.h" 28 | 29 | void app_main() 30 | { 31 | 32 | app_board_main(); 33 | app_httpd_main(); 34 | app_mdns_main(); 35 | 36 | ESP_LOGI("esp-cam Version",CONFIG_ESP_CAM_VERSION); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/app_sd.c: -------------------------------------------------------------------------------- 1 | /* SD card and FAT filesystem example. 2 | This example code is in the Public Domain (or CC0 licensed, at your option.) 3 | 4 | Unless required by applicable law or agreed to in writing, this 5 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 6 | CONDITIONS OF ANY KIND, either express or implied. 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "esp_err.h" 14 | #include "esp_log.h" 15 | #include "esp_vfs_fat.h" 16 | #include "driver/sdmmc_host.h" 17 | #include "driver/sdspi_host.h" 18 | #include "sdmmc_cmd.h" 19 | 20 | #include "freertos/FreeRTOS.h" 21 | #include "freertos/task.h" 22 | #include "freertos/semphr.h" 23 | #include "esp_camera.h" 24 | 25 | #include "app_sd.h" 26 | #include 27 | #include "sdkconfig.h" 28 | 29 | static const char *TAG = "example"; 30 | 31 | typedef struct { 32 | QueueHandle_t data_ready; 33 | QueueHandle_t fb_in; 34 | QueueHandle_t fb_out; 35 | 36 | SemaphoreHandle_t frame_ready; 37 | TaskHandle_t dma_filter_task; 38 | } sd_state_t; 39 | static sdmmc_card_t* card; 40 | //sd_state_t* sd_state = NULL; 41 | QueueHandle_t sd_ready; 42 | #ifdef USE_SPI_MODE 43 | // Pin mapping when using SPI mode. 44 | // With this mapping, SD card can be used both in SPI and 1-line SD mode. 45 | // Note that a pull-up on CS line is required in SD mode. 46 | #define PIN_NUM_MISO 2 47 | #define PIN_NUM_MOSI 15 48 | #define PIN_NUM_CLK 14 49 | #define PIN_NUM_CS 13 50 | #endif //USE_SPI_MODE 51 | 52 | void sd_write(const char *_jpg_buf, int _jpg_buf_len) 53 | { 54 | // Use POSIX and C standard library functions to work with files. 55 | // First create a file. 56 | ESP_LOGI(TAG, "Opening file"); 57 | FILE* f = fopen("/sdcard/hello.txt", "w"); 58 | if (f == NULL) { 59 | ESP_LOGE(TAG, "Failed to open file for writing"); 60 | return; 61 | } 62 | fprintf(f, "Hello file IO %s!\n", card->cid.name); 63 | fclose(f); 64 | ESP_LOGI(TAG, "File written"); 65 | 66 | // Check if destination file exists before renaming 67 | struct stat st; 68 | if (stat("/sdcard/foo.txt", &st) == 0) { 69 | // Delete it if it exists 70 | unlink("/sdcard/foo.txt"); 71 | } 72 | 73 | // Rename original file 74 | ESP_LOGI(TAG, "Renaming file"); 75 | if (rename("/sdcard/hello.txt", "/sdcard/foo.txt") != 0) { 76 | ESP_LOGE(TAG, "Rename failed"); 77 | return; 78 | } 79 | 80 | // Open renamed file for reading 81 | ESP_LOGI(TAG, "Reading file"); 82 | f = fopen("/sdcard/foo.txt", "r"); 83 | if (f == NULL) { 84 | ESP_LOGE(TAG, "Failed to open file for reading"); 85 | return; 86 | } 87 | char line[64]; 88 | fgets(line, sizeof(line), f); 89 | fclose(f); 90 | // strip newline 91 | char* pos = strchr(line, '\n'); 92 | if (pos) { 93 | *pos = '\0'; 94 | } 95 | ESP_LOGI(TAG, "Read from file: '%s'", line); 96 | 97 | // All done, unmount partition and disable SDMMC or SPI peripheral 98 | esp_vfs_fat_sdmmc_unmount(); 99 | ESP_LOGI(TAG, "Card unmounted"); 100 | } 101 | 102 | static void Sdcard_task(void *pvParameters) 103 | { 104 | 105 | while (true){ 106 | 107 | vTaskDelay((5*1000) / portTICK_PERIOD_MS); 108 | } 109 | vTaskDelete(NULL); 110 | } 111 | void SdCard_init(void) 112 | { 113 | #if CONFIG_ESP_SNTP_ENABLED 114 | { 115 | time_t now; 116 | char strftime_buf[64]; 117 | struct tm timeinfo; 118 | 119 | time(&now); 120 | // Set timezone to China Standard Time 121 | setenv("TZ", "CST-8", 1); 122 | tzset(); 123 | 124 | localtime_r(&now, &timeinfo); 125 | strftime(strftime_buf, sizeof(strftime_buf), "%Y-%m-%d %H:%M:%S", &timeinfo); 126 | ESP_LOGI(TAG, "The current date/time is: %s", strftime_buf); 127 | } 128 | #endif 129 | #if CONFIG_ESP_SDCARD_STORAGE_ENABLED 130 | ESP_LOGI(TAG, "Initializing SD card"); 131 | 132 | #ifndef USE_SPI_MODE 133 | ESP_LOGI(TAG, "Using SDMMC peripheral"); 134 | sdmmc_host_t host = SDMMC_HOST_DEFAULT(); 135 | 136 | // This initializes the slot without card detect (CD) and write protect (WP) signals. 137 | // Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals. 138 | sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT(); 139 | 140 | // To use 1-line SD mode, uncomment the following line: 141 | // slot_config.width = 1; 142 | 143 | // GPIOs 15, 2, 4, 12, 13 should have external 10k pull-ups. 144 | // Internal pull-ups are not sufficient. However, enabling internal pull-ups 145 | // does make a difference some boards, so we do that here. 146 | gpio_set_pull_mode(15, GPIO_PULLUP_ONLY); // CMD, needed in 4- and 1- line modes 147 | gpio_set_pull_mode(2, GPIO_PULLUP_ONLY); // D0, needed in 4- and 1-line modes 148 | gpio_set_pull_mode(4, GPIO_PULLUP_ONLY); // D1, needed in 4-line mode only 149 | gpio_set_pull_mode(12, GPIO_PULLUP_ONLY); // D2, needed in 4-line mode only 150 | gpio_set_pull_mode(13, GPIO_PULLUP_ONLY); // D3, needed in 4- and 1-line modes 151 | 152 | #else 153 | ESP_LOGI(TAG, "Using SPI peripheral"); 154 | 155 | sdmmc_host_t host = SDSPI_HOST_DEFAULT(); 156 | sdspi_slot_config_t slot_config = SDSPI_SLOT_CONFIG_DEFAULT(); 157 | slot_config.gpio_miso = PIN_NUM_MISO; 158 | slot_config.gpio_mosi = PIN_NUM_MOSI; 159 | slot_config.gpio_sck = PIN_NUM_CLK; 160 | slot_config.gpio_cs = PIN_NUM_CS; 161 | // This initializes the slot without card detect (CD) and write protect (WP) signals. 162 | // Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals. 163 | #endif //USE_SPI_MODE 164 | 165 | // Options for mounting the filesystem. 166 | // If format_if_mount_failed is set to true, SD card will be partitioned and 167 | // formatted in case when mounting fails. 168 | esp_vfs_fat_sdmmc_mount_config_t mount_config = { 169 | .format_if_mount_failed = false,// 2 false 170 | .max_files = 5, 171 | .allocation_unit_size = 16 * 1024 172 | }; 173 | 174 | // Use settings defined above to initialize SD card and mount FAT filesystem. 175 | // Note: esp_vfs_fat_sdmmc_mount is an all-in-one convenience function. 176 | // Please check its source code and implement error recovery when developing 177 | // production applications. 178 | esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card); 179 | 180 | if (ret != ESP_OK) { 181 | if (ret == ESP_FAIL) { 182 | ESP_LOGE(TAG, "Failed to mount filesystem. " 183 | "If you want the card to be formatted, set format_if_mount_failed = true."); 184 | } else { 185 | ESP_LOGE(TAG, "Failed to initialize the card (%s). " 186 | "Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret)); 187 | } 188 | return; 189 | } 190 | 191 | // Card has been initialized, print its properties 192 | sdmmc_card_print_info(stdout, card); 193 | xTaskCreate(&Sdcard_task, "Sdcard_task", 4096, NULL, 5, NULL); 194 | #endif 195 | } 196 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/app_smart_wifi.c: -------------------------------------------------------------------------------- 1 | /* Esptouch example 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #include 11 | #include 12 | #include "freertos/FreeRTOS.h" 13 | #include "freertos/task.h" 14 | #include "freertos/event_groups.h" 15 | #include "esp_wifi.h" 16 | #include "esp_wpa2.h" 17 | #include "esp_event.h" 18 | #include "esp_log.h" 19 | #include "esp_system.h" 20 | #include "nvs_flash.h" 21 | #include "tcpip_adapter.h" 22 | #include "esp_smartconfig.h" 23 | 24 | #include 25 | #include 26 | #include "esp_sntp.h" 27 | #include "sdkconfig.h" 28 | 29 | /* FreeRTOS event group to signal when we are connected & ready to make a request */ 30 | static EventGroupHandle_t s_wifi_event_group; 31 | 32 | /* The event group allows multiple bits for each event, 33 | but we only care about one event - are we connected 34 | to the AP with an IP? */ 35 | static const int CONNECTED_BIT = BIT0; 36 | static const int ESPTOUCH_DONE_BIT = BIT1; 37 | static const char *TAG = "smartconfig_example"; 38 | 39 | static void smartconfig_example_task(void * parm); 40 | 41 | static void event_handler(void* arg, esp_event_base_t event_base, 42 | int32_t event_id, void* event_data) 43 | { 44 | if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { 45 | xTaskCreate(smartconfig_example_task, "smartconfig_example_task", 4096, NULL, 3, NULL); 46 | } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { 47 | esp_wifi_connect(); 48 | xEventGroupClearBits(s_wifi_event_group, CONNECTED_BIT); 49 | } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { 50 | xEventGroupSetBits(s_wifi_event_group, CONNECTED_BIT); 51 | } else if (event_base == SC_EVENT && event_id == SC_EVENT_SCAN_DONE) { 52 | ESP_LOGI(TAG, "Scan done"); 53 | } else if (event_base == SC_EVENT && event_id == SC_EVENT_FOUND_CHANNEL) { 54 | ESP_LOGI(TAG, "Found channel"); 55 | } else if (event_base == SC_EVENT && event_id == SC_EVENT_GOT_SSID_PSWD) { 56 | ESP_LOGI(TAG, "Got SSID and password"); 57 | 58 | smartconfig_event_got_ssid_pswd_t *evt = (smartconfig_event_got_ssid_pswd_t *)event_data; 59 | wifi_config_t wifi_config; 60 | uint8_t ssid[33] = { 0 }; 61 | uint8_t password[65] = { 0 }; 62 | 63 | bzero(&wifi_config, sizeof(wifi_config_t)); 64 | memcpy(wifi_config.sta.ssid, evt->ssid, sizeof(wifi_config.sta.ssid)); 65 | memcpy(wifi_config.sta.password, evt->password, sizeof(wifi_config.sta.password)); 66 | wifi_config.sta.bssid_set = evt->bssid_set; 67 | if (wifi_config.sta.bssid_set == true) { 68 | memcpy(wifi_config.sta.bssid, evt->bssid, sizeof(wifi_config.sta.bssid)); 69 | } 70 | 71 | memcpy(ssid, evt->ssid, sizeof(evt->ssid)); 72 | memcpy(password, evt->password, sizeof(evt->password)); 73 | ESP_LOGI(TAG, "SSID:%s", ssid); 74 | ESP_LOGI(TAG, "PASSWORD:%s", password); 75 | 76 | ESP_ERROR_CHECK( esp_wifi_disconnect() ); 77 | ESP_ERROR_CHECK( esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); 78 | ESP_ERROR_CHECK( esp_wifi_connect() ); 79 | } else if (event_base == SC_EVENT && event_id == SC_EVENT_SEND_ACK_DONE) { 80 | xEventGroupSetBits(s_wifi_event_group, ESPTOUCH_DONE_BIT); 81 | } 82 | } 83 | void time_sync_notification_cb(struct timeval *tv) 84 | { 85 | ESP_LOGI(TAG, "SNTP OK "); 86 | } 87 | static void initialize_sntp(void) 88 | { 89 | ESP_LOGI(TAG, "Initializing SNTP"); 90 | sntp_setoperatingmode(SNTP_OPMODE_POLL); 91 | sntp_setservername(0, "pool.ntp.org"); 92 | sntp_set_time_sync_notification_cb(time_sync_notification_cb); 93 | #ifdef CONFIG_SNTP_TIME_SYNC_METHOD_SMOOTH 94 | sntp_set_sync_mode(SNTP_SYNC_MODE_SMOOTH); 95 | #endif 96 | sntp_init(); 97 | } 98 | 99 | static void smartconfig_example_task(void * parm) 100 | { 101 | EventBits_t uxBits; 102 | ESP_ERROR_CHECK( esp_smartconfig_set_type(SC_TYPE_ESPTOUCH) ); 103 | smartconfig_start_config_t cfg = SMARTCONFIG_START_CONFIG_DEFAULT(); 104 | ESP_ERROR_CHECK( esp_smartconfig_start(&cfg) ); 105 | while (1) { 106 | uxBits = xEventGroupWaitBits(s_wifi_event_group, CONNECTED_BIT | ESPTOUCH_DONE_BIT, true, false, portMAX_DELAY); 107 | if(uxBits & CONNECTED_BIT) { 108 | ESP_LOGI(TAG, "WiFi Connected to ap"); 109 | } 110 | if(uxBits & ESPTOUCH_DONE_BIT) { 111 | ESP_LOGI(TAG, "smartconfig over"); 112 | #if CONFIG_ESP_SNTP_ENABLED 113 | { 114 | initialize_sntp(); 115 | 116 | // wait for time to be set 117 | time_t now = 0; 118 | struct tm timeinfo = { 0 }; 119 | int retry = 0; 120 | const int retry_count = 10; 121 | while (sntp_get_sync_status() == SNTP_SYNC_STATUS_RESET && ++retry < retry_count) { 122 | //ESP_LOGI(TAG, "Waiting for system time to be set... (%d/%d)", retry, retry_count); 123 | vTaskDelay(1000 / portTICK_PERIOD_MS); 124 | } 125 | 126 | time(&now); 127 | localtime_r(&now, &timeinfo); 128 | } 129 | #endif 130 | esp_smartconfig_stop(); 131 | vTaskDelete(NULL); 132 | } 133 | } 134 | } 135 | 136 | void initialise_wifi(void) 137 | { 138 | tcpip_adapter_init(); 139 | s_wifi_event_group = xEventGroupCreate(); 140 | ESP_ERROR_CHECK(esp_event_loop_create_default()); 141 | 142 | wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); 143 | ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); 144 | 145 | ESP_ERROR_CHECK( esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL) ); 146 | ESP_ERROR_CHECK( esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL) ); 147 | ESP_ERROR_CHECK( esp_event_handler_register(SC_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL) ); 148 | 149 | ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) ); 150 | ESP_ERROR_CHECK( esp_wifi_start() ); 151 | } 152 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/app_uart.c: -------------------------------------------------------------------------------- 1 | /* UART Events Example 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | #include 10 | #include 11 | #include "freertos/FreeRTOS.h" 12 | #include "freertos/task.h" 13 | #include "freertos/queue.h" 14 | #include "driver/uart.h" 15 | #include "esp_log.h" 16 | 17 | static const char *TAG = "uart_events"; 18 | 19 | /** 20 | * This example shows how to use the UART driver to handle special UART events. 21 | * 22 | * It also reads data from UART0 directly, and echoes it to console. 23 | * 24 | * - Port: UART0 25 | * - Receive (Rx) buffer: on 26 | * - Transmit (Tx) buffer: off 27 | * - Flow control: off 28 | * - Event queue: on 29 | * - Pin assignment: TxD (default), RxD (default) 30 | */ 31 | 32 | #define EX_UART_NUM UART_NUM_0 33 | #define PATTERN_CHR_NUM (3) /*!< Set the number of consecutive and identical characters received by receiver which defines a UART pattern*/ 34 | 35 | #define BUF_SIZE (256) 36 | #define RD_BUF_SIZE (BUF_SIZE) 37 | static QueueHandle_t uart0_queue; 38 | 39 | static void uart_event_task(void *arg) 40 | { 41 | uart_event_t event; 42 | // size_t buffered_size; 43 | uint8_t* dtmp = (uint8_t*) malloc(RD_BUF_SIZE); 44 | while(1) { 45 | //Waiting for UART event. 46 | if(xQueueReceive(uart0_queue, (void * )&event, (portTickType)portMAX_DELAY)) { 47 | bzero(dtmp, RD_BUF_SIZE); 48 | //ESP_LOGI(TAG, "uart[%d] event:", EX_UART_NUM); 49 | switch(event.type) { 50 | //Event of UART receving data 51 | /*We'd better handler data event fast, there would be much more data events than 52 | other types of events. If we take too much time on data event, the queue might 53 | be full.*/ 54 | case UART_DATA: 55 | //ESP_LOGI(TAG, "[UART DATA]: %d", event.size); 56 | uart_read_bytes(EX_UART_NUM, dtmp, event.size, portMAX_DELAY); 57 | ESP_LOGI(TAG, "[DATA EVT]:%d:",sizeof(dtmp)); 58 | uart_write_bytes(EX_UART_NUM, (const char*) dtmp, event.size); 59 | break; 60 | //Event of HW FIFO overflow detected 61 | case UART_FIFO_OVF: 62 | ESP_LOGI(TAG, "hw fifo overflow"); 63 | // If fifo overflow happened, you should consider adding flow control for your application. 64 | // The ISR has already reset the rx FIFO, 65 | // As an example, we directly flush the rx buffer here in order to read more data. 66 | uart_flush_input(EX_UART_NUM); 67 | xQueueReset(uart0_queue); 68 | break; 69 | //Event of UART ring buffer full 70 | case UART_BUFFER_FULL: 71 | ESP_LOGI(TAG, "ring buffer full"); 72 | // If buffer full happened, you should consider encreasing your buffer size 73 | // As an example, we directly flush the rx buffer here in order to read more data. 74 | uart_flush_input(EX_UART_NUM); 75 | xQueueReset(uart0_queue); 76 | break; 77 | #if 0 78 | //Event of UART RX break detected 79 | case UART_BREAK: 80 | ESP_LOGI(TAG, "uart rx break"); 81 | break; 82 | //Event of UART parity check error 83 | case UART_PARITY_ERR: 84 | ESP_LOGI(TAG, "uart parity error"); 85 | break; 86 | //Event of UART frame error 87 | case UART_FRAME_ERR: 88 | ESP_LOGI(TAG, "uart frame error"); 89 | break; 90 | //UART_PATTERN_DET 91 | case UART_PATTERN_DET: 92 | uart_get_buffered_data_len(EX_UART_NUM, &buffered_size); 93 | int pos = uart_pattern_pop_pos(EX_UART_NUM); 94 | ESP_LOGI(TAG, "[UART PATTERN DETECTED] pos: %d, buffered size: %d", pos, buffered_size); 95 | if (pos == -1) { 96 | // There used to be a UART_PATTERN_DET event, but the pattern position queue is full so that it can not 97 | // record the position. We should set a larger queue size. 98 | // As an example, we directly flush the rx buffer here. 99 | uart_flush_input(EX_UART_NUM); 100 | } else { 101 | uart_read_bytes(EX_UART_NUM, dtmp, pos, 100 / portTICK_PERIOD_MS); 102 | uint8_t pat[PATTERN_CHR_NUM + 1]; 103 | memset(pat, 0, sizeof(pat)); 104 | uart_read_bytes(EX_UART_NUM, pat, PATTERN_CHR_NUM, 100 / portTICK_PERIOD_MS); 105 | ESP_LOGI(TAG, "read data: %s", dtmp); 106 | ESP_LOGI(TAG, "read pat : %s", pat); 107 | } 108 | break; 109 | #endif 110 | //Others 111 | default: 112 | ESP_LOGI(TAG, "uart event type: %d", event.type); 113 | break; 114 | } 115 | //ESP_LOGD(TAG, "uart stack : %d", uxTaskGetStackHighWaterMark(NULL)); 116 | } 117 | 118 | //ESP_LOGI(TAG, "%sFree heap: %u",__func__ ,xPortGetFreeHeapSize()); 119 | } 120 | free(dtmp); 121 | dtmp = NULL; 122 | vTaskDelete(NULL); 123 | } 124 | 125 | void uart_init() 126 | { 127 | esp_log_level_set(TAG, ESP_LOG_INFO); 128 | 129 | /* Configure parameters of an UART driver, 130 | * communication pins and install the driver */ 131 | uart_config_t uart_config = { 132 | .baud_rate = 115200, 133 | .data_bits = UART_DATA_8_BITS, 134 | .parity = UART_PARITY_DISABLE, 135 | .stop_bits = UART_STOP_BITS_1, 136 | .flow_ctrl = UART_HW_FLOWCTRL_DISABLE 137 | }; 138 | uart_param_config(EX_UART_NUM, &uart_config); 139 | 140 | //Set UART log level 141 | esp_log_level_set(TAG, ESP_LOG_INFO); 142 | //Set UART pins (using UART0 default pins ie no changes.) 143 | uart_set_pin(EX_UART_NUM, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); 144 | //Install UART driver, and get the queue. 145 | uart_driver_install(EX_UART_NUM, BUF_SIZE * 2, BUF_SIZE * 2, 20, &uart0_queue, 0); 146 | 147 | //Set uart pattern detect function. 148 | //uart_enable_pattern_det_intr(EX_UART_NUM, '+', PATTERN_CHR_NUM, 10000, 10, 10); 149 | //Reset the pattern queue length to record at most 20 pattern positions. 150 | //uart_pattern_queue_reset(EX_UART_NUM, 20); 151 | //Create a task to handler UART event from ISR 152 | xTaskCreate(uart_event_task, "uart_event_task", 2048, NULL, 5, NULL); 153 | 154 | 155 | 156 | } 157 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/app_wifi.c: -------------------------------------------------------------------------------- 1 | /* ESPRESSIF MIT License 2 | * 3 | * Copyright (c) 2018 4 | * 5 | * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case, 6 | * it is free of charge, to any person obtaining a copy of this software and associated 7 | * documentation files (the "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 10 | * to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * 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, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | #include 23 | #include "freertos/FreeRTOS.h" 24 | #include "freertos/task.h" 25 | #include "freertos/event_groups.h" 26 | #include "esp_system.h" 27 | #include "esp_wifi.h" 28 | #include "esp_event_loop.h" 29 | #include "esp_log.h" 30 | #include "sdkconfig.h" 31 | 32 | #include "lwip/err.h" 33 | #include "lwip/sys.h" 34 | 35 | #include "mdns.h" 36 | 37 | /* The examples use WiFi configuration that you can set via 'make menuconfig'. 38 | 39 | If you'd rather not, just change the below entries to strings with 40 | the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid" 41 | */ 42 | #define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID 43 | #define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD 44 | #define EXAMPLE_ESP_MAXIMUM_RETRY CONFIG_ESP_MAXIMUM_RETRY 45 | #define EXAMPLE_ESP_WIFI_AP_SSID CONFIG_ESP_WIFI_AP_SSID 46 | #define EXAMPLE_ESP_WIFI_AP_PASS CONFIG_ESP_WIFI_AP_PASSWORD 47 | #define EXAMPLE_MAX_STA_CONN CONFIG_MAX_STA_CONN 48 | #define EXAMPLE_IP_ADDR CONFIG_SERVER_IP 49 | #define EXAMPLE_ESP_WIFI_AP_CHANNEL CONFIG_ESP_WIFI_AP_CHANNEL 50 | 51 | static const char *TAG = "camera wifi"; 52 | 53 | static int s_retry_num = 0; 54 | 55 | static esp_err_t event_handler(void *ctx, system_event_t *event) 56 | { 57 | switch(event->event_id) { 58 | case SYSTEM_EVENT_AP_STACONNECTED: 59 | ESP_LOGI(TAG, "station:" MACSTR " join, AID=%d", 60 | MAC2STR(event->event_info.sta_connected.mac), 61 | event->event_info.sta_connected.aid); 62 | break; 63 | case SYSTEM_EVENT_AP_STADISCONNECTED: 64 | ESP_LOGI(TAG, "station:" MACSTR "leave, AID=%d", 65 | MAC2STR(event->event_info.sta_disconnected.mac), 66 | event->event_info.sta_disconnected.aid); 67 | break; 68 | case SYSTEM_EVENT_STA_START: 69 | esp_wifi_connect(); 70 | break; 71 | case SYSTEM_EVENT_STA_GOT_IP: 72 | ESP_LOGI(TAG, "got ip:%s", 73 | ip4addr_ntoa(&event->event_info.got_ip.ip_info.ip)); 74 | s_retry_num = 0; 75 | break; 76 | case SYSTEM_EVENT_STA_DISCONNECTED: 77 | { 78 | if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) { 79 | esp_wifi_connect(); 80 | s_retry_num++; 81 | ESP_LOGI(TAG,"retry to connect to the AP"); 82 | } 83 | ESP_LOGI(TAG,"connect to the AP fail"); 84 | break; 85 | } 86 | default: 87 | break; 88 | } 89 | mdns_handle_system_event(ctx, event); 90 | return ESP_OK; 91 | } 92 | 93 | void wifi_init_softap() 94 | { 95 | if (strcmp(EXAMPLE_IP_ADDR, "192.168.4.1")) 96 | { 97 | int a, b, c, d; 98 | sscanf(EXAMPLE_IP_ADDR, "%d.%d.%d.%d", &a, &b, &c, &d); 99 | tcpip_adapter_ip_info_t ip_info; 100 | IP4_ADDR(&ip_info.ip, a, b, c, d); 101 | IP4_ADDR(&ip_info.gw, a, b, c, d); 102 | IP4_ADDR(&ip_info.netmask, 255, 255, 255, 0); 103 | ESP_ERROR_CHECK(tcpip_adapter_dhcps_stop(WIFI_IF_AP)); 104 | ESP_ERROR_CHECK(tcpip_adapter_set_ip_info(WIFI_IF_AP, &ip_info)); 105 | ESP_ERROR_CHECK(tcpip_adapter_dhcps_start(WIFI_IF_AP)); 106 | } 107 | wifi_config_t wifi_config; 108 | memset(&wifi_config, 0, sizeof(wifi_config_t)); 109 | snprintf((char*)wifi_config.ap.ssid, 32, "%s", EXAMPLE_ESP_WIFI_AP_SSID); 110 | wifi_config.ap.ssid_len = strlen((char*)wifi_config.ap.ssid); 111 | snprintf((char*)wifi_config.ap.password, 64, "%s", EXAMPLE_ESP_WIFI_AP_PASS); 112 | wifi_config.ap.max_connection = EXAMPLE_MAX_STA_CONN; 113 | wifi_config.ap.authmode = WIFI_AUTH_WPA_WPA2_PSK; 114 | if (strlen(EXAMPLE_ESP_WIFI_AP_PASS) == 0) { 115 | wifi_config.ap.authmode = WIFI_AUTH_OPEN; 116 | } 117 | if (strlen(EXAMPLE_ESP_WIFI_AP_CHANNEL)) { 118 | int channel; 119 | sscanf(EXAMPLE_ESP_WIFI_AP_CHANNEL, "%d", &channel); 120 | wifi_config.ap.channel = channel; 121 | } 122 | 123 | ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config)); 124 | 125 | ESP_LOGI(TAG, "wifi_init_softap finished.SSID:%s password:%s", 126 | EXAMPLE_ESP_WIFI_AP_SSID, EXAMPLE_ESP_WIFI_AP_PASS); 127 | } 128 | //extern char SSID_NAME[32]; 129 | //extern char SSID_PASSWD[64]; 130 | void wifi_init_sta() 131 | { 132 | wifi_config_t wifi_config; 133 | memset(&wifi_config, 0, sizeof(wifi_config_t)); 134 | snprintf((char*)wifi_config.sta.ssid, 32, "%s", EXAMPLE_ESP_WIFI_SSID); 135 | snprintf((char*)wifi_config.sta.password, 64, "%s", EXAMPLE_ESP_WIFI_PASS); 136 | 137 | ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); 138 | 139 | ESP_LOGI(TAG, "wifi_init_sta finished."); 140 | ESP_LOGI(TAG, "connect to ap SSID:|%s| password:|%s|", EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS); 141 | //SSID_NAME, SSID_PASSWD); 142 | } 143 | 144 | void app_wifi_main() 145 | { 146 | wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); 147 | wifi_mode_t mode = WIFI_MODE_NULL; 148 | if (strlen(EXAMPLE_ESP_WIFI_AP_SSID) && strlen(EXAMPLE_ESP_WIFI_SSID)) { 149 | mode = WIFI_MODE_APSTA; 150 | } else if (strlen(EXAMPLE_ESP_WIFI_AP_SSID)) { 151 | mode = WIFI_MODE_AP; 152 | } else if (strlen(EXAMPLE_ESP_WIFI_SSID)) { 153 | mode = WIFI_MODE_STA; 154 | } 155 | 156 | 157 | if (mode == WIFI_MODE_NULL) { 158 | ESP_LOGW(TAG,"Neither AP or STA have been configured. WiFi will be off."); 159 | return; 160 | } 161 | 162 | tcpip_adapter_init(); 163 | ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL)); 164 | ESP_ERROR_CHECK(esp_wifi_init(&cfg)); 165 | ESP_ERROR_CHECK(esp_wifi_set_mode(mode)); 166 | 167 | if (mode & WIFI_MODE_AP) { 168 | wifi_init_softap(); 169 | } 170 | 171 | if (mode & WIFI_MODE_STA) { 172 | wifi_init_sta(); 173 | } 174 | ESP_ERROR_CHECK(esp_wifi_start()); 175 | ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE)); 176 | } 177 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main Makefile. This is basically the same as a component makefile. 3 | # 4 | # This Makefile should, at the very least, just include $(SDK_PATH)/make/component.mk. By default, 5 | # this will take the sources in the src/ directory, compile them and link them into 6 | # lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable, 7 | # please read the SDK documents if you need to do this. 8 | # 9 | COMPONENT_EMBED_FILES := www/index_ov2640.html.gz 10 | COMPONENT_EMBED_FILES += www/index_ov3660.html.gz 11 | COMPONENT_EMBED_FILES += www/index_ov5640.html.gz 12 | COMPONENT_EMBED_FILES += www/monitor.html.gz 13 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/include/app_at.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2017 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | #ifndef _APP_AT_H_ 25 | #define _APP_AT_H_ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | uint8_t CMDParse( uint8_t* p_cmd, uint8_t len ); 32 | 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/include/app_board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2017 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | #ifndef _APP_BOARD_H_ 25 | #define _APP_BOARD_H_ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | void app_board_main(void); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/include/app_camera.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2017 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | #ifndef _APP_CAMERA_H_ 25 | #define _APP_CAMERA_H_ 26 | 27 | #if CONFIG_CAMERA_MODEL_WROVER_KIT 28 | #define CAM_BOARD "WROVER-KIT" 29 | #define PWDN_GPIO_NUM -1 30 | #define RESET_GPIO_NUM -1 31 | #define XCLK_GPIO_NUM 21 32 | #define SIOD_GPIO_NUM 26 33 | #define SIOC_GPIO_NUM 27 34 | 35 | #define Y9_GPIO_NUM 35 36 | #define Y8_GPIO_NUM 34 37 | #define Y7_GPIO_NUM 39 38 | #define Y6_GPIO_NUM 36 39 | #define Y5_GPIO_NUM 19 40 | #define Y4_GPIO_NUM 18 41 | #define Y3_GPIO_NUM 5 42 | #define Y2_GPIO_NUM 4 43 | #define VSYNC_GPIO_NUM 25 44 | #define HREF_GPIO_NUM 23 45 | #define PCLK_GPIO_NUM 22 46 | 47 | #elif CONFIG_CAMERA_MODEL_ESP32_CAM_BOARD 48 | #define CAM_BOARD "ESP-DEVCAM" 49 | #define PWDN_GPIO_NUM 32 50 | #define RESET_GPIO_NUM 33 51 | #define XCLK_GPIO_NUM 4 52 | #define SIOD_GPIO_NUM 18 53 | #define SIOC_GPIO_NUM 23 54 | 55 | #define Y9_GPIO_NUM 36 56 | #define Y8_GPIO_NUM 19 57 | #define Y7_GPIO_NUM 21 58 | #define Y6_GPIO_NUM 39 59 | #define Y5_GPIO_NUM 35 60 | #define Y4_GPIO_NUM 14 61 | #define Y3_GPIO_NUM 13 62 | #define Y2_GPIO_NUM 34 63 | #define VSYNC_GPIO_NUM 5 64 | #define HREF_GPIO_NUM 27 65 | #define PCLK_GPIO_NUM 25 66 | 67 | #elif CONFIG_CAMERA_MODEL_ESP_EYE 68 | #define CAM_BOARD "ESP-EYE" 69 | #define PWDN_GPIO_NUM -1 70 | #define RESET_GPIO_NUM -1 71 | #define XCLK_GPIO_NUM 4 72 | #define SIOD_GPIO_NUM 18 73 | #define SIOC_GPIO_NUM 23 74 | 75 | #define Y9_GPIO_NUM 36 76 | #define Y8_GPIO_NUM 37 77 | #define Y7_GPIO_NUM 38 78 | #define Y6_GPIO_NUM 39 79 | #define Y5_GPIO_NUM 35 80 | #define Y4_GPIO_NUM 14 81 | #define Y3_GPIO_NUM 13 82 | #define Y2_GPIO_NUM 34 83 | #define VSYNC_GPIO_NUM 5 84 | #define HREF_GPIO_NUM 27 85 | #define PCLK_GPIO_NUM 25 86 | 87 | #elif CONFIG_CAMERA_MODEL_M5STACK_PSRAM 88 | #define CAM_BOARD "M5CAM" 89 | #define PWDN_GPIO_NUM -1 90 | #define RESET_GPIO_NUM 15 91 | #define XCLK_GPIO_NUM 27 92 | #define SIOD_GPIO_NUM 25 93 | #define SIOC_GPIO_NUM 23 94 | 95 | #define Y9_GPIO_NUM 19 96 | #define Y8_GPIO_NUM 36 97 | #define Y7_GPIO_NUM 18 98 | #define Y6_GPIO_NUM 39 99 | #define Y5_GPIO_NUM 5 100 | #define Y4_GPIO_NUM 34 101 | #define Y3_GPIO_NUM 35 102 | #define Y2_GPIO_NUM 32 103 | #define VSYNC_GPIO_NUM 22 104 | #define HREF_GPIO_NUM 26 105 | #define PCLK_GPIO_NUM 21 106 | 107 | #elif CONFIG_CAMERA_MODEL_M5STACK_WIDE 108 | #define CAM_BOARD "M5CAMW" 109 | #define PWDN_GPIO_NUM -1 110 | #define RESET_GPIO_NUM 15 111 | #define XCLK_GPIO_NUM 27 112 | #define SIOD_GPIO_NUM 22 113 | #define SIOC_GPIO_NUM 23 114 | 115 | #define Y9_GPIO_NUM 19 116 | #define Y8_GPIO_NUM 36 117 | #define Y7_GPIO_NUM 18 118 | #define Y6_GPIO_NUM 39 119 | #define Y5_GPIO_NUM 5 120 | #define Y4_GPIO_NUM 34 121 | #define Y3_GPIO_NUM 35 122 | #define Y2_GPIO_NUM 32 123 | #define VSYNC_GPIO_NUM 25 124 | #define HREF_GPIO_NUM 26 125 | #define PCLK_GPIO_NUM 21 126 | 127 | #elif CONFIG_CAMERA_MODEL_AI_THINKER 128 | #define CAM_BOARD "AI-THINKER" 129 | #define PWDN_GPIO_NUM 32 130 | #define RESET_GPIO_NUM -1 131 | #define XCLK_GPIO_NUM 0 132 | #define SIOD_GPIO_NUM 26 133 | #define SIOC_GPIO_NUM 27 134 | 135 | #define Y9_GPIO_NUM 35 136 | #define Y8_GPIO_NUM 34 137 | #define Y7_GPIO_NUM 39 138 | #define Y6_GPIO_NUM 36 139 | #define Y5_GPIO_NUM 21 140 | #define Y4_GPIO_NUM 19 141 | #define Y3_GPIO_NUM 18 142 | #define Y2_GPIO_NUM 5 143 | #define VSYNC_GPIO_NUM 25 144 | #define HREF_GPIO_NUM 23 145 | #define PCLK_GPIO_NUM 22 146 | 147 | 148 | #elif CONFIG_CAMERA_MODEL_CUSTOM 149 | #define CAM_BOARD "CUSTOM" 150 | #define PWDN_GPIO_NUM CONFIG_CAMERA_PIN_PWDN 151 | #define RESET_GPIO_NUM CONFIG_CAMERA_PIN_RESET 152 | #define XCLK_GPIO_NUM CONFIG_CAMERA_PIN_XCLK 153 | #define SIOD_GPIO_NUM CONFIG_CAMERA_PIN_SIOD 154 | #define SIOC_GPIO_NUM CONFIG_CAMERA_PIN_SIOC 155 | 156 | #define Y9_GPIO_NUM CONFIG_CAMERA_PIN_Y9 157 | #define Y8_GPIO_NUM CONFIG_CAMERA_PIN_Y8 158 | #define Y7_GPIO_NUM CONFIG_CAMERA_PIN_Y7 159 | #define Y6_GPIO_NUM CONFIG_CAMERA_PIN_Y6 160 | #define Y5_GPIO_NUM CONFIG_CAMERA_PIN_Y5 161 | #define Y4_GPIO_NUM CONFIG_CAMERA_PIN_Y4 162 | #define Y3_GPIO_NUM CONFIG_CAMERA_PIN_Y3 163 | #define Y2_GPIO_NUM CONFIG_CAMERA_PIN_Y2 164 | #define VSYNC_GPIO_NUM CONFIG_CAMERA_PIN_VSYNC 165 | #define HREF_GPIO_NUM CONFIG_CAMERA_PIN_HREF 166 | #define PCLK_GPIO_NUM CONFIG_CAMERA_PIN_PCLK 167 | #endif 168 | #ifdef __cplusplus 169 | extern "C" { 170 | #endif 171 | 172 | void app_camera_main(); 173 | 174 | #ifdef __cplusplus 175 | } 176 | #endif 177 | 178 | #endif 179 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/include/app_httpd.h: -------------------------------------------------------------------------------- 1 | 2 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | #ifndef _CAMERA_HTTPD_H_ 16 | #define _CAMERA_HTTPD_H_ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | typedef signed char int8_t; 22 | void app_httpd_main(); 23 | #if 0 24 | int8_t e_save_face_id_to_flash(void); 25 | int8_t e_delete_face_id_in_flash(void); 26 | int8_t e_read_face_id_from_flash(uint8_t sv_id_num,uint8_t cf_times); 27 | #endif 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* _CAMERA_HTTPD_H_ */ 33 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/include/app_mdns.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef _CAMERA_MDNS_H_ 15 | #define _CAMERA_MDNS_H_ 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include 22 | 23 | void app_mdns_main(); 24 | void app_mdns_update_framesize(int size); 25 | const char * app_mdns_query(size_t * out_len); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* _CAMERA_MDNS_H_ */ 32 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/include/app_sd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2017 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | #ifndef _APP_SD_H_ 25 | #define _APP_SD_H_ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | void SdCard_init(); 32 | //void sd_write(const char *_jpg_buf, int _jpg_buf_len); 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/include/app_smart_wifi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2017 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | #ifndef _APP_SMART_WIFI_H_ 25 | #define _APP_SMART_WIFI_H_ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | void initialise_wifi(void); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/include/app_uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2017 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | #ifndef _APP_UART_H_ 25 | #define _APP_UART_H_ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | void uart_init(); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/include/app_wifi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2017 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | #ifndef _APP_WIFI_H_ 25 | #define _APP_WIFI_H_ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | void app_wifi_main(); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/www/compress_pages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for file in `ls *.html`; do 3 | echo "Compressing: $file" 4 | cp "$file" "copy_$file" && \ 5 | gzip -f "$file" && \ 6 | mv "copy_$file" "$file" 7 | done 8 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/www/index_ov2640.html.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/examples/single_chip/camera_web_server/main/www/index_ov2640.html.gz -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/www/index_ov3660.html.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/examples/single_chip/camera_web_server/main/www/index_ov3660.html.gz -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/www/index_ov5640.html.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/examples/single_chip/camera_web_server/main/www/index_ov5640.html.gz -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/main/www/monitor.html.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/examples/single_chip/camera_web_server/main/www/monitor.html.gz -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table,,,, 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 3840K 4 | nvs, data, nvs, 0x3D0000, 16K 5 | face_id,32,32, 0x3E0000, 128K 6 | -------------------------------------------------------------------------------- /examples/single_chip/camera_web_server/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | 2 | CONFIG_ESPTOOLPY_PORT="/dev/ttyUSB1" 3 | CONFIG_ESPTOOLPY_BAUD_115200B= 4 | CONFIG_ESPTOOLPY_BAUD_230400B= 5 | CONFIG_ESPTOOLPY_BAUD_921600B=y 6 | CONFIG_ESPTOOLPY_BAUD_2MB= 7 | CONFIG_ESPTOOLPY_BAUD_OTHER= 8 | CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 9 | CONFIG_ESPTOOLPY_BAUD=921600 10 | CONFIG_ESPTOOLPY_COMPRESSED=y 11 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 12 | CONFIG_ESPTOOLPY_FLASHMODE_QOUT= 13 | CONFIG_ESPTOOLPY_FLASHMODE_DIO= 14 | CONFIG_ESPTOOLPY_FLASHMODE_DOUT= 15 | CONFIG_ESPTOOLPY_FLASHMODE="dio" 16 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 17 | CONFIG_ESPTOOLPY_FLASHFREQ_40M= 18 | CONFIG_ESPTOOLPY_FLASHFREQ_26M= 19 | CONFIG_ESPTOOLPY_FLASHFREQ_20M= 20 | CONFIG_ESPTOOLPY_FLASHFREQ="80m" 21 | CONFIG_ESPTOOLPY_FLASHSIZE_1MB= 22 | CONFIG_ESPTOOLPY_FLASHSIZE_2MB= 23 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 24 | CONFIG_ESPTOOLPY_FLASHSIZE_8MB= 25 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB= 26 | CONFIG_ESPTOOLPY_FLASHSIZE="4MB" 27 | CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y 28 | CONFIG_ESPTOOLPY_BEFORE_RESET=y 29 | CONFIG_ESPTOOLPY_BEFORE_NORESET= 30 | CONFIG_ESPTOOLPY_BEFORE="default_reset" 31 | CONFIG_ESPTOOLPY_AFTER_RESET=y 32 | CONFIG_ESPTOOLPY_AFTER_NORESET= 33 | CONFIG_ESPTOOLPY_AFTER="hard_reset" 34 | CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B= 35 | CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B= 36 | CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y 37 | CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B= 38 | CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B= 39 | CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB= 40 | CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER= 41 | CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200 42 | CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 43 | 44 | # 45 | # Partition Table 46 | # 47 | CONFIG_PARTITION_TABLE_SINGLE_APP= 48 | CONFIG_PARTITION_TABLE_TWO_OTA= 49 | CONFIG_PARTITION_TABLE_CUSTOM=y 50 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 51 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 52 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 53 | CONFIG_PARTITION_TABLE_MD5=y 54 | # 55 | # Camera configuration 56 | # 57 | CONFIG_ENABLE_TEST_PATTERN= 58 | CONFIG_OV2640_SUPPORT=y 59 | CONFIG_OV7725_SUPPORT= 60 | 61 | # 62 | # ESP32-specific 63 | # 64 | CONFIG_ESP32_DEFAULT_CPU_FREQ_80= 65 | CONFIG_ESP32_DEFAULT_CPU_FREQ_160= 66 | CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y 67 | CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240 68 | CONFIG_ESP32_SPIRAM_SUPPORT=y 69 | 70 | # 71 | # SPI RAM config 72 | # 73 | CONFIG_ESP32_SPIRAM_BOOT_INIT=y 74 | CONFIG_ESP32_SPIRAM_IGNORE_NOTFOUND= 75 | CONFIG_ESP32_SPIRAM_USE_MEMMAP= 76 | CONFIG_ESP32_SPIRAM_USE_CAPS_ALLOC=y 77 | CONFIG_ESP32_SPIRAM_USE_MALLOC= 78 | CONFIG_ESP32_SPIRAM_TYPE_AUTO=y 79 | CONFIG_ESP32_SPIRAM_TYPE_ESPPSRAM32= 80 | CONFIG_ESP32_SPIRAM_TYPE_ESPPSRAM64= 81 | CONFIG_ESP32_SPIRAM_SIZE=-1 82 | CONFIG_ESP32_SPIRAM_SPEED_40M= 83 | CONFIG_ESP32_SPIRAM_SPEED_80M=y 84 | CONFIG_ESP32_SPIRAM_MEMTEST=y 85 | CONFIG_ESP32_SPIRAM_CACHE_WORKAROUND=y 86 | CONFIG_ESP32_SPIRAM_BANKSWITCH_ENABLE=y 87 | CONFIG_ESP32_SPIRAM_BANKSWITCH_RESERVE=8 88 | CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP= 89 | CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY= 90 | 91 | CONFIG_ESP_TASK_WDT= 92 | -------------------------------------------------------------------------------- /img/CAM5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/CAM5.jpg -------------------------------------------------------------------------------- /img/cam.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/cam.jpg -------------------------------------------------------------------------------- /img/cam2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/cam2.jpg -------------------------------------------------------------------------------- /img/cam_uart.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/cam_uart.jpg -------------------------------------------------------------------------------- /img/detected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/detected.png -------------------------------------------------------------------------------- /img/enrollment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/enrollment.png -------------------------------------------------------------------------------- /img/esp-wrover-kit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/esp-wrover-kit.jpg -------------------------------------------------------------------------------- /img/esp_eye_Wechat_cross.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/esp_eye_Wechat_cross.jpeg -------------------------------------------------------------------------------- /img/esp_eye_Wechat_list.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/esp_eye_Wechat_list.jpg -------------------------------------------------------------------------------- /img/esp_eye_Wechat_network_configuration.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/esp_eye_Wechat_network_configuration.jpg -------------------------------------------------------------------------------- /img/esp_eye_wechat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/esp_eye_wechat.jpg -------------------------------------------------------------------------------- /img/esp_eye_wechat_qr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/esp_eye_wechat_qr.jpg -------------------------------------------------------------------------------- /img/esp_wrover_kit_with_ov2640.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/esp_wrover_kit_with_ov2640.png -------------------------------------------------------------------------------- /img/no_matched.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/no_matched.png -------------------------------------------------------------------------------- /img/ov2640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/ov2640.jpg -------------------------------------------------------------------------------- /img/overview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/overview.jpg -------------------------------------------------------------------------------- /img/recognized.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/recognized.png -------------------------------------------------------------------------------- /img/start_login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/start_login.png -------------------------------------------------------------------------------- /img/start_recognition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ai-Thinker-Open/Ai-Thinker-Open_ESP32-CAMERA_LAN/97a29e147b6706df947a9f3faaa3ff185179733a/img/start_recognition.png -------------------------------------------------------------------------------- /tools/ci/build_examples.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Build all examples from the examples directory, out of tree to 4 | # ensure they can run when copied to a new directory. 5 | # 6 | # Runs as part of CI process. 7 | # 8 | # Assumes PWD is an out-of-tree build directory, and will copy examples 9 | # to individual subdirectories, one by one. 10 | # 11 | # 12 | # Without arguments it just builds all examples 13 | # 14 | # With one argument it builds part of the examples. This is a useful for 15 | # parallel execution in CI. 16 | # must look like this: 17 | # _ 18 | # It scans .gitlab-ci.yaml to count number of jobs which have name "_" 19 | # It scans the filesystem to count all examples 20 | # Based on this, it decides to run qa set of examples. 21 | # 22 | 23 | # ----------------------------------------------------------------------------- 24 | # Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d). 25 | 26 | if [[ ! -z ${DEBUG_SHELL} ]] 27 | then 28 | set -x # Activate the expand mode if DEBUG is anything but empty. 29 | fi 30 | 31 | set -o errexit # Exit if command failed. 32 | set -o pipefail # Exit if pipe failed. 33 | set -o nounset # Exit if variable not set. 34 | 35 | # Remove the initial space and instead use '\n'. 36 | IFS=$'\n\t' 37 | 38 | # ----------------------------------------------------------------------------- 39 | 40 | die() { 41 | echo "${1:-"Unknown Error"}" 1>&2 42 | exit 1 43 | } 44 | 45 | [ -z ${IDF_PATH} ] && die "IDF_PATH is not set" 46 | [ -z ${LOG_PATH} ] && die "LOG_PATH is not set" 47 | [ -d ${LOG_PATH} ] || mkdir -p ${LOG_PATH} 48 | 49 | echo "build_examples running in ${PWD}" 50 | 51 | export BATCH_BUILD=1 52 | export V=0 # only build verbose if there's an error 53 | 54 | shopt -s lastpipe # Workaround for Bash to use variables in loops (http://mywiki.wooledge.org/BashFAQ/024) 55 | 56 | RESULT=0 57 | FAILED_EXAMPLES="" 58 | RESULT_ISSUES=22 # magic number result code for issues found 59 | LOG_SUSPECTED=${LOG_PATH}/common_log.txt 60 | touch ${LOG_SUSPECTED} 61 | SDKCONFIG_DEFAULTS_CI=sdkconfig.ci 62 | 63 | EXAMPLE_PATHS=$( find ${CI_PROJECT_DIR}/examples/ -type f -name Makefile | grep -v "/build_system/cmake/" | sort ) 64 | 65 | if [ -z "${CI_NODE_TOTAL:-}" ] 66 | then 67 | START_NUM=0 68 | END_NUM=999 69 | else 70 | JOB_PATTERN=$( echo ${CI_JOB_NAME} | sed -n -r 's/^(.*)_[0-9]+$/\1/p' ) 71 | [ -z ${JOB_PATTERN} ] && die "JOB_PATTERN is bad" 72 | 73 | JOB_NUM=$( echo ${CI_JOB_NAME} | sed -n -r 's/^.*_0*([0-9]+)$/\1/p' ) 74 | [ -z ${JOB_NUM} ] && die "JOB_NUM is bad" 75 | 76 | # count number of the jobs 77 | NUM_OF_JOBS=$( grep -c -E "^${JOB_PATTERN}_[0-9]+:$" "${CI_PROJECT_DIR}/.gitlab-ci.yml" ) 78 | [ -z ${NUM_OF_JOBS} ] && die "NUM_OF_JOBS is bad" 79 | 80 | # count number of examples 81 | NUM_OF_EXAMPLES=$( echo "${EXAMPLE_PATHS}" | wc -l ) 82 | [ -z ${NUM_OF_EXAMPLES} ] && die "NUM_OF_EXAMPLES is bad" 83 | 84 | # separate intervals 85 | #57 / 5 == 12 86 | NUM_OF_EX_PER_JOB=$(( (${NUM_OF_EXAMPLES} + ${NUM_OF_JOBS} - 1) / ${NUM_OF_JOBS} )) 87 | [ -z ${NUM_OF_EX_PER_JOB} ] && die "NUM_OF_EX_PER_JOB is bad" 88 | 89 | # ex.: [0; 12); [12; 24); [24; 36); [36; 48); [48; 60) 90 | START_NUM=$(( ${JOB_NUM} * ${NUM_OF_EX_PER_JOB} )) 91 | [ -z ${START_NUM} ] && die "START_NUM is bad" 92 | 93 | END_NUM=$(( (${JOB_NUM} + 1) * ${NUM_OF_EX_PER_JOB} )) 94 | [ -z ${END_NUM} ] && die "END_NUM is bad" 95 | fi 96 | 97 | build_example () { 98 | local ID=$1 99 | shift 100 | local MAKE_FILE=$1 101 | shift 102 | 103 | local EXAMPLE_DIR=$(dirname "${MAKE_FILE}") 104 | local EXAMPLE_NAME=$(basename "${EXAMPLE_DIR}") 105 | 106 | echo "Building ${EXAMPLE_NAME} as ${ID}..." 107 | mkdir -p "${ID}" 108 | cp -r "${EXAMPLE_DIR}" "${ID}" 109 | pushd "${ID}/${EXAMPLE_NAME}" 110 | # be stricter in the CI build than the default IDF settings 111 | export EXTRA_CFLAGS="-Werror -Werror=deprecated-declarations" 112 | export EXTRA_CXXFLAGS=${EXTRA_CFLAGS} 113 | 114 | # build non-verbose first 115 | local BUILDLOG=${LOG_PATH}/ex_${ID}_log.txt 116 | touch ${BUILDLOG} 117 | 118 | 119 | make clean >>${BUILDLOG} 2>&1 && 120 | make defconfig >>${BUILDLOG} 2>&1 && 121 | make all >>${BUILDLOG} 2>&1 && 122 | 123 | cat ${BUILDLOG} 124 | popd 125 | 126 | grep -i "error\|warning" "${BUILDLOG}" 2>&1 >> "${LOG_SUSPECTED}" || : 127 | } 128 | 129 | EXAMPLE_NUM=0 130 | 131 | echo "Current job will build example ${START_NUM} - ${END_NUM}" 132 | 133 | for EXAMPLE_PATH in ${EXAMPLE_PATHS} 134 | do 135 | if [[ $EXAMPLE_NUM -lt $START_NUM || $EXAMPLE_NUM -ge $END_NUM ]] 136 | then 137 | EXAMPLE_NUM=$(( $EXAMPLE_NUM + 1 )) 138 | continue 139 | fi 140 | echo ">>> example [ ${EXAMPLE_NUM} ] - $EXAMPLE_PATH" 141 | 142 | build_example "${EXAMPLE_NUM}" "${EXAMPLE_PATH}" 143 | 144 | EXAMPLE_NUM=$(( $EXAMPLE_NUM + 1 )) 145 | done 146 | 147 | # show warnings 148 | echo -e "\nFound issues:" 149 | 150 | # Ignore the next messages: 151 | # "error.o" or "-Werror" in compiler's command line 152 | # "reassigning to symbol" or "changes choice state" in sdkconfig 153 | # 'Compiler and toochain versions is not supported' from make/project.mk 154 | IGNORE_WARNS="\ 155 | library/error\.o\ 156 | \|\ -Werror\ 157 | \|error\.d\ 158 | \|reassigning to symbol\ 159 | \|changes choice state\ 160 | \|Compiler version is not supported\ 161 | \|Toolchain version is not supported\ 162 | " 163 | 164 | sort -u "${LOG_SUSPECTED}" | grep -v "${IGNORE_WARNS}" \ 165 | && RESULT=$RESULT_ISSUES \ 166 | || echo -e "\tNone" 167 | 168 | [ -z ${FAILED_EXAMPLES} ] || echo -e "\nThere are errors in the next examples: $FAILED_EXAMPLES" 169 | [ $RESULT -eq 0 ] || echo -e "\nFix all warnings and errors above to pass the test!" 170 | 171 | echo -e "\nReturn code = $RESULT" 172 | 173 | exit $RESULT 174 | -------------------------------------------------------------------------------- /tools/ci/build_examples_cmake.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Build all examples from the examples directory, out of tree to 4 | # ensure they can run when copied to a new directory. 5 | # 6 | # Runs as part of CI process. 7 | # 8 | # Assumes PWD is an out-of-tree build directory, and will copy examples 9 | # to individual subdirectories, one by one. 10 | # 11 | # 12 | # Without arguments it just builds all examples 13 | # 14 | # With one argument it builds part of the examples. This is a useful for 15 | # parallel execution in CI. 16 | # must look like this: 17 | # _ 18 | # It scans .gitlab-ci.yaml to count number of jobs which have name "_" 19 | # It scans the filesystem to count all examples 20 | # Based on this, it decides to run qa set of examples. 21 | # 22 | 23 | # ----------------------------------------------------------------------------- 24 | # Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d). 25 | 26 | if [[ ! -z ${DEBUG_SHELL} ]] 27 | then 28 | set -x # Activate the expand mode if DEBUG is anything but empty. 29 | fi 30 | 31 | set -o errexit # Exit if command failed. 32 | set -o pipefail # Exit if pipe failed. 33 | set -o nounset # Exit if variable not set. 34 | 35 | # Remove the initial space and instead use '\n'. 36 | IFS=$'\n\t' 37 | 38 | export PATH="$IDF_PATH/tools:$PATH" # for idf.py 39 | 40 | # ----------------------------------------------------------------------------- 41 | 42 | die() { 43 | echo "${1:-"Unknown Error"}" 1>&2 44 | exit 1 45 | } 46 | 47 | [ -z ${IDF_PATH} ] && die "IDF_PATH is not set" 48 | [ -z ${LOG_PATH} ] && die "LOG_PATH is not set" 49 | [ -d ${LOG_PATH} ] || mkdir -p ${LOG_PATH} 50 | 51 | echo "build_examples running in ${PWD}" 52 | 53 | export BATCH_BUILD=1 54 | export V=0 # only build verbose if there's an error 55 | 56 | shopt -s lastpipe # Workaround for Bash to use variables in loops (http://mywiki.wooledge.org/BashFAQ/024) 57 | 58 | RESULT=0 59 | FAILED_EXAMPLES="" 60 | RESULT_ISSUES=22 # magic number result code for issues found 61 | LOG_SUSPECTED=${LOG_PATH}/common_log.txt 62 | touch ${LOG_SUSPECTED} 63 | SDKCONFIG_DEFAULTS_CI=sdkconfig.ci 64 | 65 | EXAMPLE_PATHS=$( find ${CI_PROJECT_DIR}/examples/ -type f -name CMakeLists.txt | grep -v "/components/" | grep -v "/main/" | sort ) 66 | 67 | if [ -z "${CI_NODE_TOTAL:-}" ] 68 | then 69 | START_NUM=0 70 | END_NUM=999 71 | else 72 | JOB_PATTERN=$( echo ${CI_JOB_NAME} | sed -n -r 's/^(.*)_[0-9]+$/\1/p' ) 73 | [ -z ${JOB_PATTERN} ] && die "JOB_PATTERN is bad" 74 | 75 | JOB_NUM=$( echo ${CI_JOB_NAME} | sed -n -r 's/^.*_0*([0-9]+)$/\1/p' ) 76 | [ -z ${JOB_NUM} ] && die "JOB_NUM is bad" 77 | 78 | # count number of the jobs 79 | NUM_OF_JOBS=$( grep -c -E "^${JOB_PATTERN}_[0-9]+:$" "${CI_PROJECT_DIR}/.gitlab-ci.yml" ) 80 | [ -z ${NUM_OF_JOBS} ] && die "NUM_OF_JOBS is bad" 81 | 82 | # count number of examples 83 | NUM_OF_EXAMPLES=$( echo "${EXAMPLE_PATHS}" | wc -l ) 84 | [ -z ${NUM_OF_EXAMPLES} ] && die "NUM_OF_EXAMPLES is bad" 85 | 86 | # separate intervals 87 | #57 / 5 == 12 88 | NUM_OF_EX_PER_JOB=$(( (${NUM_OF_EXAMPLES} + ${NUM_OF_JOBS} - 1) / ${NUM_OF_JOBS} )) 89 | [ -z ${NUM_OF_EX_PER_JOB} ] && die "NUM_OF_EX_PER_JOB is bad" 90 | 91 | # ex.: [0; 12); [12; 24); [24; 36); [36; 48); [48; 60) 92 | START_NUM=$(( ${JOB_NUM} * ${NUM_OF_EX_PER_JOB} )) 93 | [ -z ${START_NUM} ] && die "START_NUM is bad" 94 | 95 | END_NUM=$(( (${JOB_NUM} + 1) * ${NUM_OF_EX_PER_JOB} )) 96 | [ -z ${END_NUM} ] && die "END_NUM is bad" 97 | fi 98 | 99 | build_example () { 100 | local ID=$1 101 | shift 102 | local CMAKELISTS=$1 103 | shift 104 | 105 | local EXAMPLE_DIR=$(dirname "${CMAKELISTS}") 106 | local EXAMPLE_NAME=$(basename "${EXAMPLE_DIR}") 107 | 108 | echo "Building ${EXAMPLE_NAME} as ${ID}..." 109 | mkdir -p "${ID}" 110 | cp -r "${EXAMPLE_DIR}" "${ID}" 111 | pushd "${ID}/${EXAMPLE_NAME}" 112 | # be stricter in the CI build than the default IDF settings 113 | export EXTRA_CFLAGS="-Werror -Werror=deprecated-declarations" 114 | export EXTRA_CXXFLAGS=${EXTRA_CFLAGS} 115 | 116 | # build non-verbose first 117 | local BUILDLOG=${LOG_PATH}/ex_${ID}_log.txt 118 | touch ${BUILDLOG} 119 | 120 | 121 | idf.py fullclean >>${BUILDLOG} 2>&1 && 122 | idf.py build >>${BUILDLOG} 2>&1 && 123 | 124 | cat ${BUILDLOG} 125 | popd 126 | 127 | grep -i "error\|warning" "${BUILDLOG}" 2>&1 | grep -v "error.c.obj" >> "${LOG_SUSPECTED}" || : 128 | } 129 | 130 | EXAMPLE_NUM=0 131 | 132 | echo "Current job will build example ${START_NUM} - ${END_NUM}" 133 | 134 | for EXAMPLE_PATH in ${EXAMPLE_PATHS} 135 | do 136 | if [[ $EXAMPLE_NUM -lt $START_NUM || $EXAMPLE_NUM -ge $END_NUM ]] 137 | then 138 | EXAMPLE_NUM=$(( $EXAMPLE_NUM + 1 )) 139 | continue 140 | fi 141 | echo ">>> example [ ${EXAMPLE_NUM} ] - $EXAMPLE_PATH" 142 | 143 | build_example "${EXAMPLE_NUM}" "${EXAMPLE_PATH}" 144 | 145 | EXAMPLE_NUM=$(( $EXAMPLE_NUM + 1 )) 146 | done 147 | 148 | # show warnings 149 | echo -e "\nFound issues:" 150 | 151 | # Ignore the next messages: 152 | # "error.o" or "-Werror" in compiler's command line 153 | # "reassigning to symbol" or "changes choice state" in sdkconfig 154 | # 'Compiler and toochain versions is not supported' from crosstool_version_check.cmake 155 | IGNORE_WARNS="\ 156 | library/error\.o\ 157 | \|\ -Werror\ 158 | \|error\.d\ 159 | \|reassigning to symbol\ 160 | \|changes choice state\ 161 | \|crosstool_version_check\.cmake\ 162 | " 163 | 164 | sort -u "${LOG_SUSPECTED}" | grep -v "${IGNORE_WARNS}" \ 165 | && RESULT=$RESULT_ISSUES \ 166 | || echo -e "\tNone" 167 | 168 | [ -z ${FAILED_EXAMPLES} ] || echo -e "\nThere are errors in the next examples: $FAILED_EXAMPLES" 169 | [ $RESULT -eq 0 ] || echo -e "\nFix all warnings and errors above to pass the test!" 170 | 171 | echo -e "\nReturn code = $RESULT" 172 | 173 | exit $RESULT 174 | --------------------------------------------------------------------------------