Reading sent image over Uart

Hi OpenMV People,

I was able to send and save an image from OpenMV to a Pycom board following OpenMV forums;

uart = UART(3, 115200, bits=8 , parity=None , timeout_char=2000)
img = img.compress(quality=10)

However, I have a hard time converting the saved image from Pycom flash memory to an image on my computer to check if it sent it correctly.
I found a base64 decode to image from this link: How to convert Byte Data to Image in Python (using Pillow library) - YouTube
Since Uart does not do base64 encoding mentioned in the video, I removed that part as follows and just tried to display it using imshow function; but it did not work;

import PIL.Image as Image
import io
from byte_array_fromOpenMV import byte_data
img =

The start of OpenMV transmitted image looks like:


The Python Error in Computer;
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xff in position 0: invalid start byte

I am not sure what type the file transmitted is, it looks like it is a hex file, but I don’t know how to convert it back to an image!

Thank you in advance for your help!

It’s a JPEG image, save it to file and open it.

1 Like

Thanks, yes eventually I realized it is JPEG.
I used ubinascii.b2a_base64(img.compress(quality=10)) to make it base64 encoding then decoded it using the mentioned code in the computer and got back the image.