Hey there!
I am currently working on a project using an ESP32. In this project, I am requesting image data from a server. The image itself is 480x800 pixels. Each pixel has one of three values (red, black, white).
When sending an HTTP request to the server, and getting the image data as a response, I noticed, that I need to use the available resources on the ESP in a smart way, since simply requesting the raw image data seemed to require more than the available resources on the ESP32 (I received a code 200 responses but empty response string). When shortening down the response string, for example using a compression algorithm, I manage to receive the full response string. However, I then noticed, that decompression seems to be slow to do on the ESP32. Below you can see an overview of the different approaches I used to modify the sent data:
- Using no compression
- Deconstructing the base image (Red, black, white) into two images (red, white <-> black, white) as bytearray
- Base64-Encoding of the two bytearrays
Response-size: 125 KB
- Using LZMA compression algorithm
- Deconstructing the base image (Red, black, white) into two images (red, white <-> black, white) as bytearray
- LZMA compression of the two bytearrays
- Base64-Encoding of the two compressed variables
Response-size: 5,8 KB
While the compression is great and helps a lot to save space in the request, I didn't find any Arduino/ESP library, that implemented LZMA decompression while also seeming widely accepted/well maintained.
I can adjust the server code to implement any common compression method, or possibly also implement a custom-made one since there are only 3 possible values for each pixel. The server-side code is written in Python.
How would you go about setting up the general software on the ESP and on the server for requesting the image data?