Python Forum

Full Version: Need advice: UDP? TCP? Multithread?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all!

I need some advice for a software that I need to do...

I've 6-8 Cameras( intel realsense) in a room. Every camera calculate the contours of the objects in the scene (with opencv - findcontours) in a big while cycle and send it (as a string) to this software that I need to do. (a lot of messages every second)

This software that I need to do read the messages (every cycle from a different camera), draws the contours in a section of a  big image that represent the room.

Every cycle that software performs an objects tracking on this "room".

I tried to use UDP socket for the connection but it seams to slow down when more then 2 cameras are in the room. What do you suggest? a multithread TCP connection? Can you give me some documentation (or example) that can help me? 

Another question. The content of the message is the result of find contours. It's a very long string. Do you know any better method than this? 

Thank you very much and sorry for my english ;)
How are you receiving messages? Are you just binding to a port and handling it manually? Have you tried using Twisted to handle the networking?
(Apr-27-2017, 05:47 PM)nilamo Wrote: [ -> ]How are you receiving messages?  Are you just binding to a port and handling it manually?  Have you tried using Twisted to handle the networking?

hi, thank you for the reply!
 
Yes, I'm binding to a port in a single process. So wherever the message comes, I process it. This is not ideal.

I don't know Twisted, I'll take a look. Have you some documentation to suggest?
I don't have a lot of experience with Twisted (I really want to change that, though, it looks like it can help with many of the things I do lol), and I especially have no experience at all with it's UDP. But the main docs look pretty good: https://twistedmatrix.com/documents/curr...o/udp.html
(Apr-28-2017, 03:14 PM)nilamo Wrote: [ -> ]I don't have a lot of experience with Twisted (I really want to change that, though, it looks like it can help with many of the things I do lol), and I especially have no experience at all with it's UDP.  But the main docs look pretty good: https://twistedmatrix.com/documents/curr...o/udp.html

Thank you very much! I'll try to understand something these days!
Twisted... See this. It's a simple enough and is a good starting point.

Also, you may try asyncio module.
https://docs.python.org/3.5/library/asyncio-stream.html