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
128 changes: 128 additions & 0 deletions main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,123 @@ menu "Pin Configuration"
default "2"
endmenu

choice PIXEL_FORMAT
prompt "Select the pixel format"
default PIXFORMAT_RGB565
help
Select the sensor output pixel format.

config PIXFORMAT_RGB565
bool "RGB565"
help
The RGB565 color format is the same as the RGB555 color format,
except that 6 bits are used for the green value instead of 5.
Therefore, all 16 bits are in use.

config PIXFORMAT_YUV422
bool "YUV422"
help
4 bytes per 2 pixels.

config PIXFORMAT_GRAYSCALE
bool "GRAYSCALE"
help
The value of each pixel is a single sample representing only an amount of light,
that is, it carries only intensity information.

config PIXFORMAT_JPEG
bool "JPEG"
help
JPEG compression.

config PIXFORMAT_RGB888
bool "RGB888"
help
uncompressed, 3 bytes for pixel.

config PIXFORMAT_RAW
bool "RAW"
help
raw.

config PIXFORMAT_RGB444
bool "RGB444"
help
2 bytes por pixel.

config PIXFORMAT_RGB555
bool "RGB555"
help
2 bytes por pixel.
endchoice

choice FRAME_SIZE
prompt "Select the frame size"
default FRAMESIZE_QQVGA
help
Select the sensor output frame size.

config FRAMESIZE_96X96
bool "96x96"
help
96 x 96 pixeles.

config FRAMESIZE_QQVGA
bool "QQVGA"
help
160 x 120 pixeles.

config FRAMESIZE_QCIF
bool "QCIF"
help
176 x 144 pixeles.

config FRAMESIZE_HQVGA
bool "HQVGA"
help
240 x 176.

config FRAMESIZE_240X240
bool "240x240"
help
240 x 240 pixeles.

config FRAMESIZE_QVGA
bool "QVGA"
help
320 x 240 pixeles.

config FRAMESIZE_CIF
bool "CIF"
help
400 x 296 pixeles.

config FRAMESIZE_HVGA
bool "HVGA"
help
480 x 320 pixeles.

config FRAMESIZE_VGA
bool "VGA"
help
640 x 480 pixeles.

config FRAMESIZE_SVGA
bool "SVGA"
help
800 x 600 pixeles.

config FRAMESIZE_XGA
bool "XGA"
help
1024 x 768 pixeles.

config FRAMESIZE_HD
bool "HD"
help
1280 x 720 pixeles.
endchoice

config ENABLE_TEST_PATTERN
bool "Enable test pattern on camera output"
default n
Expand All @@ -65,4 +182,15 @@ config ENABLE_TEST_PATTERN
Instead, module will generate regular vertical bars
in shades from dark to white.

config ENABLE_VERTICAL_FLIP
bool "Enable vertical flip on camera output"
default n
help
Flip the frame of the the camera module.

config ENABLE_HORIZONTAL_MIRROR
bool "Enable horizontal mirror on camera output"
default n
help
Mirror the frame of the the camera module.
endmenu
69 changes: 63 additions & 6 deletions main/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
#include "protocol_examples_common.h"
#include <esp_http_server.h>


#define ENABLE_TEST_PATTERN CONFIG_ENABLE_TEST_PATTERN
#define ENABLE_TEST_PATTERN CONFIG_ENABLE_TEST_PATTERN
#define ENABLE_VERTICAL_FLIP CONFIG_ENABLE_VERTICAL_FLIP
#define ENABLE_HORIZONTAL_MIRROR CONFIG_ENABLE_HORIZONTAL_MIRROR

static httpd_handle_t start_webserver(void);
static void connect_handler(void* arg, esp_event_base_t event_base,
Expand Down Expand Up @@ -91,8 +92,50 @@ void app_main()
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,

.pixel_format = /*PIXFORMAT_GRAYSCALE,*/ PIXFORMAT_RGB565, /* PIXFORMAT_RGB888,*/
.frame_size = FRAMESIZE_QQVGA, /*FRAMESIZE_QVGA,*/ //QQVGA-QXGA Do not use sizes above QVGA when not JPEG
#if CONFIG_PIXFORMAT_RGB565
.pixel_format = PIXFORMAT_RGB565,
#elif CONFIG_PIXFORMAT_YUV422
.pixel_format = PIXFORMAT_YUV422,
#elif CONFIG_PIXFORMAT_GRAYSCALE
.pixel_format = PIXFORMAT_GRAYSCALE,
#elif CONFIG_PIXFORMAT_JPEG
.pixel_format = PIXFORMAT_JPEG,
#elif CONFIG_PIXFORMAT_RGB888
.pixel_format = PIXFORMAT_RGB888,
#elif CONFIG_PIXFORMAT_RAW
.pixel_format = PIXFORMAT_RAW,
#elif CONFIG_PIXFORMAT_RGB444
.pixel_format = PIXFORMAT_RGB444,
#elif CONFIG_PIXFORMAT_RGB555
.pixel_format = PIXFORMAT_RGB55,
#endif

//QQVGA-QXGA Do not use sizes above QVGA when not JPEG
#if CONFIG_FRAMESIZE_96X96
.frame_size = FRAMESIZE_96X96,
#elif CONFIG_FRAMESIZE_QQVGA
.frame_size = FRAMESIZE_QQVGA,
#elif CONFIG_FRAMESIZE_QCIF
.frame_size = FRAMESIZE_QCIF,
#elif CONFIG_FRAMESIZE_HQVGA
.frame_size = FRAMESIZE_HQVGA,
#elif CONFIG_FRAMESIZE_240X240
.frame_size = FRAMESIZE_240X240,
#elif CONFIG_FRAMESIZE_QVGA
.frame_size = FRAMESIZE_QVGA,
#elif CONFIG_FRAMESIZE_CIF
.frame_size = FRAMESIZE_CIF,
#elif CONFIG_FRAMESIZE_HVGA
.frame_size = FRAMESIZE_HVGA,
#elif CONFIG_FRAMESIZE_VGA
.frame_size = FRAMESIZE_VGA,
#elif CONFIG_FRAMESIZE_SVGA
.frame_size = FRAMESIZE_SVGA,
#elif CONFIG_FRAMESIZE_XGA
.frame_size = FRAMESIZE_XGA,
#elif CONFIG_FRAMESIZE_HD
.frame_size = FRAMESIZE_HD,
#endif

.jpeg_quality = 12, //0-63 lower number means higher quality
.fb_count = 1 //if more than one, i2s runs in continuous mode. Use only with JPEG
Expand All @@ -104,17 +147,31 @@ void app_main()
return;
}

#if ENABLE_TEST_PATTERN || ENABLE_VERTICAL_FLIP || ENABLE_HORIZONTAL_MIRROR
sensor_t * sensor = esp_camera_sensor_get();
#endif

#if ENABLE_TEST_PATTERN
/* Test pattern may get handy
if you are unable to get the live image right.
Once test pattern is enable, sensor will output
vertical shaded bars instead of live image.
*/
sensor_t * sensor = esp_camera_sensor_get();
sensor->set_colorbar(sensor, 1);
ESP_LOGD(TAG, "Test pattern enabled");
ESP_LOGI(TAG, "Test pattern enabled");
#endif

#if ENABLE_VERTICAL_FLIP
sensor->set_vflip(sensor, 1);
ESP_LOGI(TAG, "Vertical flip enabled");
#endif

#if ENABLE_HORIZONTAL_MIRROR
sensor->set_hmirror(sensor, 1);
ESP_LOGI(TAG, "Horizontal mirror enabled");
#endif


ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());

Expand Down