Transfer video stream and detection result of multiple OpenMV through RS485 bus

General discussion about topics related to OpenMV.
dukelec
Posts: 5
Joined: Fri Apr 06, 2018 8:42 am

Transfer video stream and detection result of multiple OpenMV through RS485 bus

Postby dukelec » Fri Apr 06, 2018 9:06 am

When we threat the OpenMV as a stand alone sensor, we should first connect it to the IDE through USB, so we can see what the OpenMV Cam is looking at while working on our code,
but when we finish our code, we disconnect the USB, and for example, put the OpenMV to the end of a robotic arm, after that, we can't know what is the cam looking at, and how is the recognition process.

Especially for a project which with multiple OpenMV attached, it's hard to connect all device to PC through USB, so, I start to thought, why not connect all device through a single RS485 bus, include multiple OpenMV and multiple robotic arms, it's very useful for industry applications.
Last edited by dukelec on Sat Apr 07, 2018 1:02 am, edited 4 times in total.
dukelec
Posts: 5
Joined: Fri Apr 06, 2018 8:42 am

Re: Transfer video stream and detection result of multiple OpenMV through RS485 bus

Postby dukelec » Fri Apr 06, 2018 10:15 am

I already doing it on Raspberry Pi, and I really want to do it on OpenMV, one RS485 port for every thing: communication with the IDE, upgrade firmware etc.
But I'm not very similar with OpenMV, and don't have enough time for it at now, maybe a few month later. But now, let's back to my demo:
cv_demo.jpg
cv_demo.jpg (158.21 KiB) Viewed 710 times
Full video:
https://youtu.be/qX5dh4wcfSk

The Raspberry Pi can output preview video and control command at the same time. We can monitor the recognition process on the PC. When problems are encountered, it is convenient to know the reason and adjust the parameters, and disconnecting the PC will not affect the demo operation.
Screenshot_2018-04-06_17-03-38.png
Screenshot_2018-04-06_17-03-38.png (45.37 KiB) Viewed 710 times
The human head shape board above the Raspberry Pi is a solderless socket board for CDCTL-Bx. It uses the CDBITE connection method: Bite the module with the probe.

The demo uses CDNET-TUN to set up a standard LAN, which allows video transmission without writing any code. And for controlling the slider, such as programming in Python via standard Socket communication, requires only 4 lines of code including the import statement, to control its movement and ensure that the command is delivered accurately. In addition, the Raspberry Pi can access the internet at any time through the PC, and it is easy to update software and for remote control.

However, for applications where high real-time performance is required, both the PC and the MCU can use the underlying CDNET protocol stack directly, which is very convenient to use.

This demo is base on the CDBUS protocol, which introduces an arbitration mechanism that automatically avoids conflicts like the CAN bus, more details:
https://github.com/dukelec/cdbus_doc (Introduction)
https://github.com/dukelec/cdbus_ip (Protocol details & FPGA IP core)
Last edited by dukelec on Sat Apr 07, 2018 2:15 pm, edited 2 times in total.
dukelec
Posts: 5
Joined: Fri Apr 06, 2018 8:42 am

Re: Transfer video stream and detection result of multiple OpenMV through RS485 bus

Postby dukelec » Sat Apr 07, 2018 12:33 pm

A debug log picture for CDBUS is added. I use two computers to communicate through CDBUS Bridge box, share Internet from one to another, download files, and play MV videos on the YouTube for several days:
cdbus_test_log.png
cdbus_test_log.png (196.46 KiB) Viewed 589 times
The device corresponding to /dev/ttyUSB1 has a low priority, so when it completed sending more than 16 million packets in one direction, it successfully managed to avoid 9753 data collisions. And there is no packet error or lost.

The RS485 baud rate tested was 1 Mbps + 10 Mbps, and the length of the test line is about 2 meters.

Moreover, even if the bus is short-circuited or disconnected from the bus, the upper CDNET protocol will automatically retransmit corrupted packets to ensure the integrity of the user data.
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Transfer video stream and detection result of multiple OpenMV through RS485 bus

Postby kwagyeman » Sat Apr 07, 2018 1:34 pm

Hi, sorry for not getting back to you in a immediately.

To send video data over RS485 please use the hardware UART on the OpenMV Cam and set the baud rate to something very high. The hardware UART can run above 1 M Baud up to about 4 M Baud or so.

Then just do this at the end of your script loop:

Code: Select all

uart.send(img.compress())
This will jpeg compress the image and send the byte stream to the UART. Now, you may wish to add headers and etc. to make it easier for your application to view.

...

Alternatively, you can use OpenMV IDE to open a serial port connected on the other end of the RS485 link. If you do that... using OpenMV IDE's Open Terminal feature under tools... then you should to this instead:

Code: Select all

uart.send(img.compress_for_ide())
This jpeg compresses the image and then turns the byte stream into a special format for reception over a clear text serial link with debug info from things like print(). OpenMV IDE will be able to decode the image and display it in the frame buffer.
Nyamekye,
dukelec
Posts: 5
Joined: Fri Apr 06, 2018 8:42 am

Re: Transfer video stream and detection result of multiple OpenMV through RS485 bus

Postby dukelec » Sat Apr 07, 2018 2:07 pm

Thanks for your reply, but I don't think your solution is suitable for real applications, for example, if a robotic arm and an OpenMV module connected on the same RS485 bus, when the OpenMV output the image byte stream, and if we send command to the robotic arm at the same time, the data on the RS485 bus will conflict and corrupted, so we need a mechanism to avoids conflicts, which was already implemented in the CDBUS protocol.

Even for a single OpenMV, when it output data, most command we send to it will be corrupted and lost.
And don't forget my post title is to connect multiple OpenMV through a single bus.

I hope you are not going to suggest me to use the traditional polling method, because that's too slow to transfer video streams. :|
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Transfer video stream and detection result of multiple OpenMV through RS485 bus

Postby kwagyeman » Sat Apr 07, 2018 4:00 pm

Okay, I'm not really sure what you want me to do... if you want to hack the firmware to add the CBUS library please go ahead. You can also put a gateway device in front of the OpenMV Cam to handle the CBUS.

We provide the basics with the OpenMV Cam of being able to create a JPEG file stream and we provide a SPI bus / I2C bus / Async Serial bus on which you can send the data. If you have a device that can talk CBUS and route data over it please use that with the OpenMV Cam. It looks like there are CBUS bridges...

http://dukelec.com/en/cdctl-bx.html
Nyamekye,
dukelec
Posts: 5
Joined: Fri Apr 06, 2018 8:42 am

Re: Transfer video stream and detection result of multiple OpenMV through RS485 bus

Postby dukelec » Sun Apr 08, 2018 1:52 pm

You don't need to do anything for me now. I just want to see if anyone is interested in it. If so, I'll take the time to create a matching shield for OpenMV as soon as possible and open source it for everyone to use. If I have problems in this process, I will ask you for help again. ;)
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Transfer video stream and detection result of multiple OpenMV through RS485 bus

Postby kwagyeman » Sun Apr 08, 2018 3:20 pm

Cool, well, to view the image stream just use the open terminal feature with OpenMV IDE and send the img.compressed_for_ide() jpeg data.

As long as the device appears as a serial port to the PC in some way shape or form you're good.
Nyamekye,

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 4 guests