Skip to content

revise calculation of JPEG buffer #35

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

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

jerryneedell
Copy link
Contributor

@jerryneedell jerryneedell commented Feb 4, 2025

Addresses #29

Change the calculation of the JPEG capture buffer to avoid corrupted captures.
the old calculation was width*height/quality
but this often resulted in the buffer being too small, especially for higher quality (lower resolution) images.

the new calculation doubles the size:
2*width*height/quality

This may be overkill, but does seem to work over a wide range of JPEG sizes and qualities.
We can discuss reducing it and accept more risk of errors.
setting the buffer to width*height//5 also seems to work, but seems very difficult to explain...

These changes were tested with a Pico2W.

Using a PicoW there are still severe memory constraints. I was only able to use JPEG images of 160x120 (QQVGA)

I was also able to capture JPEG images and write to an SD on a Pico.
Using the PicoW to capture an image and send it to AIO was not viable, in my experience.

That is why I moved to the Pico2W to work on this.

@jerryneedell jerryneedell requested a review from a team February 5, 2025 17:43
@ladyada ladyada merged commit 78152bb into adafruit:main Feb 5, 2025
1 check passed
@jerryneedell jerryneedell deleted the jerryn_buffer branch February 5, 2025 19:25
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 11, 2025
Updating https://github.com/adafruit/Adafruit_CircuitPython_OV5640 to 1.2.4 from 1.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_OV5640#35 from jerryneedell/jerryn_buffer

Updating https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display to 3.13 from 3.12.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#129 from adafruit/gc9a01a

Updating https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT to 7.11.5 from 7.11.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#238 from dhalbert/test_recv_timeout
casten added a commit to casten/Adafruit_Learning_System_Guides that referenced this pull request Apr 11, 2025
Changes to Adafruit_CircuitPython_OV5640 doubled the memory usage for a given quality setting.  This makes the latest release of in CircuitPython incompatible with the previous quality setting=3
 + colorspace=adafruit_ov5640.OV5640_COLOR_JPEG due to that working out an an allocation size of 204800.  This is too much for the first Pico.
Here is the breaking change:
adafruit/Adafruit_CircuitPython_OV5640#35
Quality 4 is still too large at 153,600 bytes.
Quality 5 using 122,880 works.
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

Successfully merging this pull request may close these issues.

2 participants