javl / image2cpp

GNU General Public License v3.0
529 stars 156 forks source link

Do not go through the HTML page #56

Open Valou1807 opened 1 year ago

Valou1807 commented 1 year ago

Good morning,

I am currently working on a simple project consisting of reading data from an image (figures for example). When I came across your project, I realized that it might interest me. For now, I have an ARDUINO code that sends the photo I took (via an esp32 cam) to a web page via an ip address. I would like to display this image on the OLED screen. Ideally, I would therefore like to send this image directly to the "arduino code generator". This would be made "automatic" by lines of code simply by directing the photo directly to this generator and I would therefore not have to select the image to be processed myself. My OLED screen would therefore display what is written on my image.

Is this possible?

valou1807

javl commented 1 year ago

This project is a web page that needs user interaction to work, so you can't call it remotely with an image, but you are free to take the relevant pieces from the code and add them to your own project. That way you could make your own version that does take image data send with your request.

Side note: please post any follow up questions in English, as that is the language used for everything in this project and the language most users understand. It doesn't matter if your English isn't perfect, we'll figure it out.

Valou1807 commented 1 year ago

Not a problem for me to answer you in English, I didn't pay attention to this.

I am a beginner in this field. Which part of the code should I to use and put directly in my Arduino code to display the image on the OLED screen? Do I need more than the Arduino Software if I don’t want to go through the web page. I think I just need the part of the project which is genretating the OLED code. The connection to the IP address is already made for the part where I take the photo.

Thank you

javl commented 1 year ago

The webpage generates a byte array: basically a long text version of your image. For most projects it's enough to store this in the Arduino code as they only need a couple of fixed images, like some icons. In your case, you need to find a way to get the byte array you want to use back to the microcontroller.

Is your OLED connected to the ESP that took the photo? In that case you need a way to send data back to the OLED. You could do this using the same request you're using to send the image to the server:

ESP takes photo -> ESP sends image to server -> server converts it to byte array and returns it in the response-> ESP shows result on OLED

Where to add the conversion code (from image to byte array) depends on your project and what kind of server you are using. If it is a Node JS server you should be able to use some of the code of image2cpp directly on the server, otherwise you'll need to port the way the code works to the language you're using. This part is doing the converting for the most common type of display. It takes the RGBA data of the image (from the javascript canvas) and the width of the image, and converts it to the right bytes. Below that one you'll find the other types. You can find the one you need by using the website and checking what setting worked for you when manually pasting the resulting byte array into your code.

I'm afraid I don't really have the time to help figure out the best way to do this for your use case but I'll keep this issue open for others to see, as I can imagine there are others that would like to do (or have done) the same thing.