Skip to content

Commit 21ea2c6

Browse files
committed
move setting pixel format of the sensor after successful camera configuration
1 parent d7864ac commit 21ea2c6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

driver/esp_camera.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,6 @@ esp_err_t esp_camera_init(const camera_config_t *config)
327327
frame_size = camera_sensor[camera_model].max_size;
328328
}
329329

330-
s_state->sensor.pixformat = pix_format;
331-
ESP_LOGD(TAG, "Setting pixel format to %d", pix_format);
332-
if (s_state->sensor.set_pixformat(&s_state->sensor, pix_format)) {
333-
ESP_LOGE(TAG, "Failed to set pixel format");
334-
err = ESP_ERR_CAMERA_FAILED_TO_SET_PIXEL_FORMAT;
335-
goto fail;
336-
}
337-
338330
err = cam_config(config, frame_size, s_state->sensor.id.PID);
339331
if (err != ESP_OK) {
340332
ESP_LOGE(TAG, "Camera config failed with error 0x%x", err);
@@ -349,6 +341,14 @@ esp_err_t esp_camera_init(const camera_config_t *config)
349341
goto fail;
350342
}
351343

344+
s_state->sensor.pixformat = pix_format;
345+
ESP_LOGD(TAG, "Setting pixel format to %d", pix_format);
346+
if (s_state->sensor.set_pixformat(&s_state->sensor, pix_format)) {
347+
ESP_LOGE(TAG, "Failed to set pixel format");
348+
err = ESP_ERR_CAMERA_FAILED_TO_SET_PIXEL_FORMAT;
349+
goto fail;
350+
}
351+
352352
#if CONFIG_CAMERA_CONVERTER_ENABLED
353353
if(config->conv_mode) {
354354
s_state->sensor.pixformat = get_output_data_format(config->conv_mode); // If conversion enabled, change the out data format by conversion mode

0 commit comments

Comments
 (0)