Continously send images to pc

General discussion about topics related to OpenMV.
Sakuyal
Posts: 6
Joined: Wed Aug 15, 2018 7:10 pm

Continously send images to pc

Postby Sakuyal » Wed Aug 15, 2018 7:48 pm

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 viewtopic.php?f=6&t=892

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

Code: Select all

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. :geek:
User avatar
iabdalkader
Posts: 550
Joined: Sun May 24, 2015 3:53 pm

Re: Continously send images to pc

Postby iabdalkader » Sat Aug 18, 2018 7:02 pm

Hi,

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

https://github.com/openmv/openmv/blob/m ... yopenmv.py

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

https://github.com/openmv/openmv/blob/m ... enmv_fb.py

Does this help ?

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 7 guests