Talking to a PC-side application

Discussion related to "under the hood" OpenMV topics.
Sanworks
Posts: 1
Joined: Tue Dec 19, 2017 2:07 pm

Talking to a PC-side application

Postby Sanworks » Tue Dec 19, 2017 5:44 pm

Hi,

I'm interested in developing a PC-side application in Python, to help the user tune parameters and filters for object tracking with the OpenMV M7 camera.
The application will have to display images from the cam so the user can adjust threshold, white balance and other parameters, to optimize the tracking system for their environment. Once the system is configured, the M7 will run autonomously for the remainder of the user session.

My question is about moving image data and parameters between the M7 and the PC-side application.
In several places in the forum, the USB_VCP class is referenced as a way to move data between a serial terminal and the M7 (albeit at the expense of being able to debug in the OpenMV IDE). Presumably, the PC side would use the PySerial class. The M7 could compress frames into jpg, and send them via USB_VCP.

To get started, I wrote a very simple sketch, to exchange a byte:

Code: Select all

import time, pyb

myUSB = pyb.USB_VCP()

while(True):
    if myUSB.any():
        message = myUSB.read()
        myUSB.send('X')
Unfortunately, when I open a serial terminal from Python using the pySerial class, instead of 'X' in response to a byte, I get an echo of whatever byte I sent.
Is there any guidance about why I might be seeing this, and more generally, how to have OpenMV talk to an application? I have seen suggestions to use UART and a UART to USB (FTDI) interface - but I am worried that the transfer speed would be impractical for sending image data. Any advice?

Thanks!
User avatar
kwagyeman
Posts: 2116
Joined: Sun May 24, 2015 2:10 pm

Re: Talking to a PC-side application

Postby kwagyeman » Tue Dec 19, 2017 9:26 pm

Hi, if you use it you can leverage alot of the work we've put into making OpenMV IDE very robust. The thing is Open source. If not, then we have a python script which will let you control the OpenMV Cam and pull frames off of it.

But, it seams like you want the camera to be controllable from a PC app and do all the serial work yourself. The problem with this is that we only have one serial port which the IDE uses to talk to the cam. So, if you use the VCP port in your app you can't program the camera with OpenMV IDE (yes, we should definitely add a second USB serial port then - bug Ibrahim to get this done on the GitHub).

The other TTL serial port can also be used with the cam and OpenMV IDE at the same time... But, then you have to use another USB to serial adapter which will be limited to 3mbs... Not as fast as the 12mbs full speed USB.

...

I don't see a great solution for this unless we add another VCP port. I don't know how hard this is...
Nyamekye,
User avatar
kwagyeman
Posts: 2116
Joined: Sun May 24, 2015 2:10 pm

Re: Talking to a PC-side application

Postby kwagyeman » Wed Dec 20, 2017 3:45 am

Hi, so, the STM32F7 chip only has 2 USB endpoints which means it only can do 2 USB things at a time (flash drive and serial port). Adding another function isn't possible so you only have one serial port. So, if you want to use the VCP you can't use the IDE on that port.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests