Skip to content
Open
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: 9 additions & 3 deletions driver/esp_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,22 +327,28 @@ esp_err_t esp_camera_init(const camera_config_t *config)
frame_size = camera_sensor[camera_model].max_size;
}

s_state->sensor.pixformat = pix_format;
ESP_LOGD(TAG, "Setting pixel format to %d", pix_format);
if (s_state->sensor.set_pixformat(&s_state->sensor, pix_format)) {
ESP_LOGE(TAG, "Failed to set pixel format");
err = ESP_ERR_CAMERA_FAILED_TO_SET_PIXEL_FORMAT;
goto fail;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move this after set_framesize where it used to be

err = cam_config(config, frame_size, s_state->sensor.id.PID);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Camera config failed with error 0x%x", err);
goto fail;
}

s_state->sensor.status.framesize = frame_size;
s_state->sensor.pixformat = pix_format;

ESP_LOGD(TAG, "Setting frame size to %dx%d", resolution[frame_size].width, resolution[frame_size].height);
if (s_state->sensor.set_framesize(&s_state->sensor, frame_size) != 0) {
ESP_LOGE(TAG, "Failed to set frame size");
err = ESP_ERR_CAMERA_FAILED_TO_SET_FRAME_SIZE;
goto fail;
}
s_state->sensor.set_pixformat(&s_state->sensor, pix_format);

#if CONFIG_CAMERA_CONVERTER_ENABLED
if(config->conv_mode) {
s_state->sensor.pixformat = get_output_data_format(config->conv_mode); // If conversion enabled, change the out data format by conversion mode
Expand Down
9 changes: 5 additions & 4 deletions driver/include/esp_camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,11 @@ typedef struct {
} camera_fb_t;

#define ESP_ERR_CAMERA_BASE 0x20000
#define ESP_ERR_CAMERA_NOT_DETECTED (ESP_ERR_CAMERA_BASE + 1)
#define ESP_ERR_CAMERA_FAILED_TO_SET_FRAME_SIZE (ESP_ERR_CAMERA_BASE + 2)
#define ESP_ERR_CAMERA_FAILED_TO_SET_OUT_FORMAT (ESP_ERR_CAMERA_BASE + 3)
#define ESP_ERR_CAMERA_NOT_SUPPORTED (ESP_ERR_CAMERA_BASE + 4)
#define ESP_ERR_CAMERA_NOT_DETECTED (ESP_ERR_CAMERA_BASE + 1)
#define ESP_ERR_CAMERA_FAILED_TO_SET_FRAME_SIZE (ESP_ERR_CAMERA_BASE + 2)
#define ESP_ERR_CAMERA_FAILED_TO_SET_PIXEL_FORMAT (ESP_ERR_CAMERA_BASE + 3)
#define ESP_ERR_CAMERA_FAILED_TO_SET_OUT_FORMAT (ESP_ERR_CAMERA_BASE + 4)
#define ESP_ERR_CAMERA_NOT_SUPPORTED (ESP_ERR_CAMERA_BASE + 5)

/**
* @brief Initialize the camera driver
Expand Down