Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions components/camera/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set(COMPONENT_SRCS
bitmap.c
)

set(COMPONENT_ADD_INCLUDEDIRS include)

register_component()
3 changes: 2 additions & 1 deletion components/camera/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
25 changes: 25 additions & 0 deletions main/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down