tsaarni / esp32-micropython-webcam

ESP32-CAM webcam with MicroPython
Apache License 2.0
148 stars 33 forks source link

frame2bmp #5

Closed 470mr0f1 closed 3 years ago

470mr0f1 commented 4 years ago

Hi, is it possible to use the function "frame2bmp" (included in the camera driver) directly from micropython? I need to convert the image from .jpg to .bmp or to a pixel array for further processing. Do you have any other ideas to do that in micropython?

Thanks!

tsaarni commented 4 years ago

I think you probably could just try modify https://github.com/tsaarni/micropython-with-esp32-cam/blob/584bc5b2a90becb6b8223bd60f54bdd7405fb651/ports/esp32/modcamera.c#L91 and call frame2bmp() from there by adapting the example in the driver's readme file. Alternatively you could add a new function which would return the image as BMP, or add a parameters for setting image format...

You likely know this already, but a warning here that this is bit involved process: modifying C-based micropython modules requires (re)compiling micropython itself.

In my example here I used a fork of the camera driver with very small modification which you can see here. My fork is old so you would need to uplift a version of the driver which now includes frame2bmp() function.

Hope this helps!

tsaarni commented 4 years ago

Regarding any other ideas: I do not know if there is pure-python image library that would be capable of converting image format and which would be compatible with micropython. If you did not do it already, I guess it is worth of googling a bit!

470mr0f1 commented 4 years ago

Thanks alot for your input! I already googled a lot regarding a pure-python image library which is compatible with micropython. I think the best thing is to modify the driver and recompile micropython.

Thanks again for your comments!