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

Reduce memory usage in raw_pixels_to_ir_data (and CameraDriver) #2

Open
paxswill opened this issue Nov 4, 2021 · 1 comment
Open

Comments

@paxswill
Copy link
Owner

paxswill commented Nov 4, 2021

I noticed while responding to #1 that raw_pixels_to_ir_data requires different input and output buffers for the pixel data it operates on, even though they don't need to be completely separate. Two approaches I can think of right now for combining the pixel_data and destination arguments:

  1. Shuffle the data in pixel_data so that each 2-byte value from the camera's RAM is spaced out with 2 empty/ignored bytes between each input value, and then the output data is written over the 4 bytes (ex: from camera: 001122, input to function: 00--11--22--, output from function: AAAABBBBCCCC).
  2. Double the size of the in/out buffer, and then calculate the output values in the reverse order, so that by the time they catch up to the input data we'll be overwriting data that isn't needed anymore (ex: from camera: 001122, input to function: 001122------, buffer for each step: 001122--CCCC, 0011BBBBCCCC, AAAABBBBCCCC).

The first option might be a bit slower, as you'd need to shuffle the data around before calling the function (unless the function that read that data off of the camera spaced it out for you). The second option sounds like it would be unsafe, so I'm pretty hesitant to jump into that (then again, the first method basically requires transmute-ing between bytes, u16 and f32).

@ActuallyHappening
Copy link

This library uses a LOT of memory!
I can't run this (even without std_lib) on a generic Adafruit ESP32 Feather

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