Problems transferring images with USB-VCP commands

Good afternoon I wanted to tell you something that happened to me when using the camera to transfer images to a client through the USB-VCP commands.
Even though the camera almost always sends the requested image correctly. Sometimes the image that is sent is cut (CapturaOCRW146.jpg) and at other times the image that is sent is damaged (CapturaOCRW26.jpg).

When opening the file of the damaged image in hexadecimal format I noticed that at the beginning there was a text that was sent to print in the code.

It is not clear to me how this text is entered into a variable received with the command img = sensor.snapshot ().

I am attaching the above code and images to see if you can explain to me why this error occurs and how to try to solve it.

Thanks in advance.
main.py (4.42 KB)


CapturaOCRW146.jpg

Is this from the USB DGB protocol that OpenMV IDE uses to communicate to the camera? Or, is this your code printing images via uart.write(img.compressed())?

No, this is the image that resulted when I used the “communication-Serial.py” script to send the command “CapturaOCRW” to the camera when it is in stand-alone mode.
On line 104 of the main.py script, the image is sent through the usb.send (image) comabndo.

This script works wonderfully all the time, however sometimes it delivers the cut images.

What really impacted me was that in one of those images that returned, in the header of the JPG file was embedded the text that was in a “Print” command before in the script.
I also attached the script “communication-Serial.py” so that the communication between the PC and the camera can be understood.

By the way, another question I wanted to ask is that if you do not plan to get a more powerful camera in terms of ram and image quality? it would be great if they improved the hardware because you have developed excellent software.
Comunicacion-Serial.py (1.45 KB)

I can’t debug your question right at this moment. I will get to it though. As for your second question, yes, the next version of the system will have the same performance as the raspberry pi zero, or, as the original raspberry pi. But, while drawing less than 200 mA. We will also have support for global shutter imaging too. We plan to KickStart the camera next year. In the meantime, our goal is to grow the company as much as possible with the M7. Once the new cam comes out the goal is to get the price of the M7 down to make it into the low performance cheap option camera.

On this line:

if (str(msj) == "b'Captura'"):
                sensor.set_windowing((600, 480)) # V Res of 80 == less work (40 for 2X the speed).
                msje = ("Tomando Captura2")
                img = sensor.snapshot()
                usb.send(imagen)

The imagen variable is not initialized before previously… So, MicroPython might not have caught the variable was uninitiated… which means it might have sent data randomly from the heap.