Continously send images to pc

Hello,

I’m trying to grab the camera data from an OpenMV M7 camera to use in another program. The camera will remain connected to the pc it needs to send the data to via USB. Transmitting the images by UART or Serial is the goal.

I’m still a bit of a newbie to i/o, but using the thread here I’ve been able to get a bit of a start http://forums.openmv.io/viewtopic.php?f=6&t=892

So here’s what I have on the sending side currently:

import time, sensor, image, ustruct
from pyb import UART, USB_VCP

uart = UART(3, 19200, timeout_char=1000)


sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
usb = USB_VCP()

while(True):
    clock.tick()
    img = sensor.snapshot().compress()
    usb.send(ustruct.pack("<L", img.size()))
    usb.send(img)
    #print(img)
    print(clock.fps())
    time.sleep(100)

There are bits of UART in there but ignore them–for simplicity’s sake I’m starting with Serial. The program in question I’m supposed to be sending data to hasn’t been written yet so currently nothing is being done with the sent data.

I would appreciate it if someone could point me in the right direction re:

  1. Is the code above correct? I saw there’s a Serial class too but I’m not sure if that’s needed.
  2. What would be the simplest way to test if the images are being sent + can be reassembled correctly? Ex. should I whip up a Processing sketch, or?

Thanks for the help. :nerd:

Hi,

You can use our pyopenmv.py module to grab frames from the camera in Python:

And there’s an example script using this module and pygame to draw the frames:

Does this help ?