Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardcoded buffer size for JPEG is too small for low resolution settings (e.g., QQVGA) #663

Closed
maruta opened this issue Jun 16, 2024 · 2 comments

Comments

@maruta
Copy link
Contributor

maruta commented Jun 16, 2024

Description:

When using JPEG mode with low resolution settings such as QQVGA, the allocated frame buffer size frequently becomes insufficient, causing capture failures. This issue arises due to the hardcoded buffer size calculation in cam_hal.h.

if(cam_obj->jpeg_mode){
cam_obj->recv_size = cam_obj->width * cam_obj->height / 5;
cam_obj->fb_size = cam_obj->recv_size;
} else {

I have confirmed this problem with OV2640. The settings at that time were as follows

config.pixel_format = PIXFORMAT_JPEG;
config.frame_size = FRAMESIZE_QQVGA;
config.jpeg_quality = 16;

The hardcoded limit for this setting is 3840 bytes, but this limit is frequently exceeded when capturing complex objects, even with a relatively low JPEG quality setting.

Suggested Fix:

One potential solution is to add a new member to the camera_config_t structure to allow the frame buffer size to be adjusted during the esp_camera_init call. However, I am not very experienced with this library, so this suggestion might not be the most feasible.

@me-no-dev
Copy link
Member

There is no clear way to calculate the expected maximum size that an image can be. Spec goes as far to say that with high quality, the image can be larger than it's RGB counterpart. I'll think about providing a way to adjust this, or make it slightly larger for smaller resolutions

@maruta
Copy link
Contributor Author

maruta commented Jul 17, 2024

This issue has been resolved by #667

@maruta maruta closed this as completed Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants