Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cnadler86 committed Nov 21, 2024
1 parent 5d80859 commit eb1deb7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/benchmark_img_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def print_summary_table(results, cam):

try:
for fb in [1, 2]:
cam.reconfigure(fb_count=fb)
cam.reconfigure(fb_count=fb, frame_size=FrameSize.QQVGA)
results[fb] = {}
for p in dir(PixelFormat):
if not p.startswith('_'):
Expand Down
15 changes: 4 additions & 11 deletions src/modcamera.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@
#error Camera only works on boards configured with spiram
#endif

// #if !defined(CONFIG_CAMERA_CORE0) && !defined(CONFIG_CAMERA_CORE1)
// #if MP_TASK_COREID == 0
// #define CONFIG_CAMERA_CORE0 1
// #elif MP_TASK_COREID == 1
// #define CONFIG_CAMERA_CORE1 1
// #endif
// #endif // CONFIG_CAMERA_COREx

// Helper functions
static int map(int value, int fromLow, int fromHigh, int toLow, int toHigh) {
if (fromHigh == fromLow) {
Expand All @@ -71,7 +63,7 @@ static void set_check_xclk_freq(mp_camera_obj_t *self, int32_t xclk_freq_hz) {
}
}

static void set_check_fb_count(mp_camera_obj_t *self, int fb_count) {
static void set_check_fb_count(mp_camera_obj_t *self, mp_int_t fb_count) {
if (fb_count > 2) {
self->camera_config.fb_count = 2;
mp_warning(NULL, "Frame buffer size limited to 2");
Expand Down Expand Up @@ -192,7 +184,7 @@ void mp_camera_hal_deinit(mp_camera_obj_t *self) {

void mp_camera_hal_reconfigure(mp_camera_obj_t *self, mp_camera_framesize_t frame_size, mp_camera_pixformat_t pixel_format, mp_camera_grabmode_t grab_mode, mp_int_t fb_count) {
check_init(self);
ESP_LOGI(TAG, "Reconfiguring camera");
ESP_LOGI(TAG, "Reconfiguring camera with frame size: %d, pixel format: %d, grab mode: %d, fb count: %d", (int)frame_size, (int)pixel_format, (int)grab_mode, (int)fb_count);

sensor_t *sensor = esp_camera_sensor_get();
camera_sensor_info_t *sensor_info = esp_camera_sensor_get_info(&sensor->id);
Expand Down Expand Up @@ -236,6 +228,7 @@ mp_obj_t mp_camera_hal_capture(mp_camera_obj_t *self, int8_t out_format) {
}

if (out_format >= 0 && (mp_camera_pixformat_t)out_format != self->camera_config.pixel_format) {
ESP_LOGI(TAG, "Converting image to pixel format: %d", out_format);
switch ((mp_camera_pixformat_t)out_format) {
case PIXFORMAT_JPEG:
if (frame2jpg(self->captured_buffer, self->camera_config.jpeg_quality, &out_buf, &out_len)) {
Expand Down Expand Up @@ -289,7 +282,7 @@ mp_obj_t mp_camera_hal_capture(mp_camera_obj_t *self, int8_t out_format) {
}

if (self->bmp_out == false) {
ESP_LOGI(TAG, "Returning imgae without conversion");
ESP_LOGI(TAG, "Returning image without conversion");
return mp_obj_new_memoryview('b', self->captured_buffer->len, self->captured_buffer->buf);
} else {
ESP_LOGI(TAG, "Returning image as bitmap");
Expand Down
2 changes: 1 addition & 1 deletion src/modcamera_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ static mp_obj_t camera_reconfigure(size_t n_args, const mp_obj_t *pos_args, mp_m
args[ARG_grab_mode].u_obj != MP_ROM_NONE
? args[ARG_grab_mode].u_int
: mp_camera_hal_get_grab_mode(self);
uint8_t fb_count =
mp_int_t fb_count =
args[ARG_fb_count].u_obj != MP_ROM_NONE
? args[ARG_fb_count].u_int
: mp_camera_hal_get_fb_count(self);
Expand Down

0 comments on commit eb1deb7

Please sign in to comment.