send values to serial port

General discussion about topics related to OpenMV.
luisantunespena
Posts: 8
Joined: Wed Jun 06, 2018 11:11 am

send values to serial port

Postby luisantunespena » Wed Jun 06, 2018 11:24 am

Hello,
I'm using the example multi_color_blob_tracking_1.py and would like to send the main values frame size for red, green and blue to a serial port. The idea is to communicate with another program called csound (an audio processing software) which can receive serial data.
Which functions do I need for this?
Thank you.
Luis
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: send values to serial port

Postby kwagyeman » Wed Jun 06, 2018 12:48 pm

Hi, for serial port sending please see the pixy emulation examples. They show off how to send data via the serial port.
Nyamekye,
luisantunespena
Posts: 8
Joined: Wed Jun 06, 2018 11:11 am

Re: send values to serial port

Postby luisantunespena » Thu Jun 07, 2018 11:00 am

Thanks for your answer. I was wondering if once the OpenMV Cam is connected via USB to the computer, if there is a simpler way to grab data from the camera. If so, could you give me an example? Thank you in advance.
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: send values to serial port

Postby kwagyeman » Thu Jun 07, 2018 11:44 am

Hi, literally just use the print() method on objects. The output will then appear in the terminal in OpenMV IDE. A y program on a the computer can open the OpenMV Cam's serial port and read the print output while the script is running.
Nyamekye,
luisantunespena
Posts: 8
Joined: Wed Jun 06, 2018 11:11 am

Re: send values to serial port

Postby luisantunespena » Thu Jun 07, 2018 1:49 pm

Thanks for your kind reply! I'll try that.
Luis
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: send values to serial port

Postby kwagyeman » Thu Jun 07, 2018 3:31 pm

Note you cannot use OpenMV IDE with the camera if another program is reading the serial port at the same time. To make your script permanent on the OpenMV Cam use Tools -> Save script to the OpenMV Cam.
Nyamekye,
luisantunespena
Posts: 8
Joined: Wed Jun 06, 2018 11:11 am

Re: send values to serial port

Postby luisantunespena » Fri Jun 08, 2018 3:23 am

That's it! Thank you very, very much! Now csound is receiving data from OpenMV!
And thanks for creating this wonderful project!
Luis
ondraga
Posts: 5
Joined: Thu Nov 15, 2018 11:15 pm

Re: send values to serial port

Postby ondraga » Mon Nov 19, 2018 4:02 am

kwagyeman wrote:
Thu Jun 07, 2018 3:31 pm
Note you cannot use OpenMV IDE with the camera if another program is reading the serial port at the same time. To make your script permanent on the OpenMV Cam use Tools -> Save script to the OpenMV Cam.
Hi!! I am trying to do the same. But while Save script to the OpenMV cam, I am getting an error Error: Cannot write file D:\\main.py. Disk full?!
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: send values to serial port

Postby kwagyeman » Mon Nov 19, 2018 3:33 pm

Hi, please verify your drive is writable.
Nyamekye,
luisantunespena
Posts: 8
Joined: Wed Jun 06, 2018 11:11 am

Re: send values to serial port

Postby luisantunespena » Tue Dec 11, 2018 7:09 am

Hello,
is there a very simple solution to send the image of the camera to an external monitor? Do I need to run an external python script or is it possible to send a stream directly from the OpenMV IDE?
Thank you.
Luis
User avatar
iabdalkader
Posts: 1180
Joined: Sun May 24, 2015 3:53 pm

Re: send values to serial port

Postby iabdalkader » Tue Dec 11, 2018 3:17 pm

luisantunespena wrote:
Tue Dec 11, 2018 7:09 am
Hello,
is there a very simple solution to send the image of the camera to an external monitor? Do I need to run an external python script or is it possible to send a stream directly from the OpenMV IDE?
Thank you.
Luis
What kind of monitor ?
luisantunespena
Posts: 8
Joined: Wed Jun 06, 2018 11:11 am

Re: send values to serial port

Postby luisantunespena » Tue Dec 11, 2018 4:46 pm

I mean one of the screens of the computer.
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: send values to serial port

Postby kwagyeman » Wed Dec 12, 2018 12:46 am

Hi, the Microcontroller can't do that. It doesn't have the hardware to do so.
Nyamekye,
luisantunespena
Posts: 8
Joined: Wed Jun 06, 2018 11:11 am

Re: send values to serial port

Postby luisantunespena » Wed Dec 12, 2018 7:22 am

Thanks for you replies.
I think I might have led you to a misunderstanding.
My idea is to stream the images of the camera to a beamer in full screen. Instead of having the camera images in the OpenMV IDE, I would like to stream it to a beamer for an audio and video performance.
Is there a simple way to do this?
Thank you in advance and for your pacience.
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: send values to serial port

Postby kwagyeman » Wed Dec 12, 2018 12:39 pm

Yes, as mentioned we just have a USB port. We don't have HDMI so we can't stream to a TV. You can fullscreen OpenMV IDE and resize the viewing window to make that fullscreen.
Nyamekye,
luisantunespena
Posts: 8
Joined: Wed Jun 06, 2018 11:11 am

Re: send values to serial port

Postby luisantunespena » Fri Dec 14, 2018 2:52 am

OK, I see. Thank you for your reply.
It seems like it is not ideal for the application I want to have of the camera. I need the images to be projected to an external screen and I need to send the image tracking information via serial port.
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: send values to serial port

Postby kwagyeman » Fri Dec 14, 2018 9:43 am

So, we will have a solution for this soon that let's the camera transmit the image over the 5ghz spectrum using an NTSC transmitter. But, we don't have what you need now.
Nyamekye,
oliviergschwend
Posts: 4
Joined: Wed Apr 22, 2020 11:53 pm

Re: send values to serial port

Postby oliviergschwend » Thu Apr 23, 2020 12:09 am

Hi,

Sorry for this newbie post but I am kind of stuck. I am also trying to send values to the serial without success. The script runs properly, the camera serial receive the values, I save the script to the camera, close the camera IDE and then try to read it with Processing (or CoolTerm) but it doesn't read anything. I don't get it because I used to make it work.

Is there any recent update I should be making? Or another (new) step I have missed?

Thanks for your help.
Cheers,

Olivier
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: send values to serial port

Postby kwagyeman » Thu Apr 23, 2020 1:54 am

HI, I'm almost done with a new interface library that will be the new gold standard for anyone want to move data from the camera to anything else.

Is it possible you can wait till next week on this? I should be done by then. The interface library I've been writing allows you to do RPC calls on the camera. I.e., you call a method on the camera, pass some data structure, and you get some data structure back. It's rather high performance so you can move raw images, jpeg images, processed outputs, etc. Whatever you want.

I will have an example script for USB VCP control and WiFI control on the PC.
Nyamekye,
oliviergschwend
Posts: 4
Joined: Wed Apr 22, 2020 11:53 pm

Re: send values to serial port

Postby oliviergschwend » Thu Apr 23, 2020 1:14 pm

Of course! Looking forward to play with it.
Thanks!
oliviergschwend
Posts: 4
Joined: Wed Apr 22, 2020 11:53 pm

Re: send values to serial port

Postby oliviergschwend » Mon May 04, 2020 4:21 pm

Hi again,

Any news on that matter. I should also mention than when I connect the camera, I get a pop up message asking me if I want to update the firmware. When I try to update, I get an error message telling me I cannot connect to the cam's normal bootloader. Might it be related?

In fact, I don't need to pass a lot of data. Just a simple signal (string... or position value but it's not even crucial) that I can easily detect with my Processing script.

Thanks for your help.
Olivier
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: send values to serial port

Postby kwagyeman » Mon May 04, 2020 4:54 pm

Hi, yes, the interface library is finally out. I need to write documentation for the release before I can push the new binaries to OpenMV IDE.

As for your firmware update... what system are you using? Mac? Can you try twice?

Latest firmware is here: https://github.com/openmv/openmv/releases

If you have an H7 then the firmware to install is the OPENMV4/firmware.bin file using the Tools->Run Bootloader option in OpenMV IDE.

Once you do that checkout this script (it will be inside of OpenMV IDE soon) https://github.com/openmv/openmv/blob/m ... _device.py

And put that on the OpenMV Cam.

Then here's the documentation on the interface library for Python: https://github.com/openmv/openmv/blob/m ... /README.md

...

Note that if you are using the USB VCP it is very difficult to debug the OpenMV Cam.

...

Given your requirements... however, just use print() to print text to OpenMV IDE. Then, once you are done with your OpenMV Cam script you can just open the same VCP port in processing and that text will appear on the serial port. The interface library is only needed if you are doing complex things.
Nyamekye,
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: send values to serial port

Postby kwagyeman » Mon May 04, 2020 5:23 pm

Adding this to the documentation:

Please note that if you only need to read `print()` output from a script running on the OpenMV Cam over USB then you only need to open the OpenMV Cam's Virtual COM Port and read lines of text from the serial port. For example (using https://pythonhosted.org/pyserial/index.html):

Code: Select all

import serial

ser = serial.Serial("COM3", timeout=1, dsrdtr=False)

while True:
    line = ser.readline().strip()
    if line: print(line)
The above code works for Windows, Mac, or Linux. You just need to change the above port name to the same name of the USB VCP port the OpenMV Cam shows up as (it will be under `/dev/` on Mac or Linux). Note that if you are opening the USB VCP port using another serial library and/or language make sure to set the DTR line to false - otherwise the OpenMV Cam will suppress printed output.
Nyamekye,
oliviergschwend
Posts: 4
Joined: Wed Apr 22, 2020 11:53 pm

Re: send values to serial port

Postby oliviergschwend » Thu May 07, 2020 10:11 am

Hi,

All right, thanks so much. I will give it a go asap.

As for the print() function, that's exactly what I used to do and it used to work perfectly. For some reason, it ceased to work when I tried to use the cam again recently. Maybe because of the firmware update. I'll check.

Thanks again.
Olivier

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 2 guests