From 109b8200e0e3c0fa0181f7825c9ae38333feb8c9 Mon Sep 17 00:00:00 2001 From: jjsch-dev Date: Sat, 14 Mar 2020 17:47:58 -0300 Subject: [PATCH] add CMakeLists.txt --- CMakeLists.txt | 12 ++++++++++++ components/camera/CMakeLists.txt | 7 +++++++ components/camera/bitmap.c | 3 ++- main/CMakeLists.txt | 11 +++++++++++ main/app_main.c | 25 +++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt create mode 100644 components/camera/CMakeLists.txt create mode 100644 main/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4ce8bb9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,12 @@ +# The following lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(EXTRA_COMPONENT_DIRS ../../../components) + +# (Not part of the boilerplate) +# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. +set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(esp32-cam-demo) diff --git a/components/camera/CMakeLists.txt b/components/camera/CMakeLists.txt new file mode 100644 index 0000000..2a50fcd --- /dev/null +++ b/components/camera/CMakeLists.txt @@ -0,0 +1,7 @@ +set(COMPONENT_SRCS + bitmap.c + ) + +set(COMPONENT_ADD_INCLUDEDIRS include) + +register_component() diff --git a/components/camera/bitmap.c b/components/camera/bitmap.c index e13a638..f21e9d1 100644 --- a/components/camera/bitmap.c +++ b/components/camera/bitmap.c @@ -9,7 +9,8 @@ bitmap_header_t *bmp_create_header(int w, int h) bitmap_header_t *pbitmap = (bitmap_header_t*)calloc(1, sizeof(bitmap_header_t)); int _pixelbytesize = w * h * _bitsperpixel/8; int _filesize = _pixelbytesize+sizeof(bitmap_header_t); - strcpy((char*)pbitmap->fileheader.signature, "BM"); + pbitmap->fileheader.signature[0] = 'B'; + pbitmap->fileheader.signature[1] = 'M'; pbitmap->fileheader.filesize = _filesize; pbitmap->fileheader.fileoffset_to_pixelarray = sizeof(bitmap_header_t); pbitmap->bitmapinfoheader.dibheadersize = sizeof(bitmapinfoheader); diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt new file mode 100644 index 0000000..ef0068e --- /dev/null +++ b/main/CMakeLists.txt @@ -0,0 +1,11 @@ +set(COMPONENT_SRCS "app_main.c") + +set(COMPONENT_REQUIRES + esp32-camera + nvs_flash + esp_http_server + camera + protocol_examples_common + ) + +register_component() diff --git a/main/app_main.c b/main/app_main.c index 616facc..025a2ef 100644 --- a/main/app_main.c +++ b/main/app_main.c @@ -389,9 +389,13 @@ static esp_err_t handle_jpg(httpd_req_t *req) { esp_err_t err = ESP_OK; + uint64_t us_start = (uint64_t) esp_timer_get_time(); + //acquire a frame camera_fb_t * fb = esp_camera_fb_get(); + uint64_t us_capture = (uint64_t) esp_timer_get_time(); + if (!fb) { ESP_LOGE(TAG, "Camera Capture Failed"); return ESP_FAIL; @@ -409,6 +413,13 @@ static esp_err_t handle_jpg(httpd_req_t *req) esp_camera_fb_return(fb); + uint64_t us_end = (uint64_t) esp_timer_get_time(); + + ESP_LOGI(TAG, "JPG Capture time %d uS, send time %d uS, total %d uS", + (int) (us_capture - us_start), + (int) (us_end - us_capture), + (int) (us_end - us_start)); + return err; } @@ -487,9 +498,16 @@ static esp_err_t handle_jpg_stream(httpd_req_t *req) err = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE); while (err == ESP_OK) { + uint64_t us_start = (uint64_t) esp_timer_get_time(); + //acquire a frame camera_fb_t * fb = esp_camera_fb_get(); + uint64_t us_capture = (uint64_t) esp_timer_get_time(); + + //acquire a frame + //camera_fb_t * fb = esp_camera_fb_get(); + if (!fb) { ESP_LOGE(TAG, "Camera Capture Failed"); err = ESP_FAIL; @@ -510,6 +528,13 @@ static esp_err_t handle_jpg_stream(httpd_req_t *req) } esp_camera_fb_return(fb); + + uint64_t us_end = (uint64_t) esp_timer_get_time(); + + ESP_LOGI(TAG, "JPG Capture time %d uS, send time %d uS, total %d uS", + (int) (us_capture - us_start), + (int) (us_end - us_capture), + (int) (us_end - us_start)); } return err;