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
Merged
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
4 changes: 3 additions & 1 deletion adafruit_ov5640/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,9 @@ def capture(self, buf: Union[bytearray, memoryview]) -> None:
def capture_buffer_size(self) -> int:
"""Return the size of capture buffer to use with current resolution & colorspace settings"""
if self.colorspace == OV5640_COLOR_JPEG:
return self.width * self.height // self.quality
# This is somewhat arbirary but seems to work for a wide range of JPEG images
# the user can chose to further scale the buffer in the user code if necessary
return 2 * (self.width * self.height // self.quality)
if self.colorspace == OV5640_COLOR_GRAYSCALE:
return self.width * self.height
return self.width * self.height * 2
Expand Down