Oct-30-2016, 10:48 AM
Why do you need threading? If you can locate the T in less than 30ms and if you don't need millisecond accuracy on the Arduino notification and if the Arduino comms are quick then this is superfluous
Threading is complicated when your threads write to the same variables. But here you would have one thread that periodically extracts the 'T' position and makes a tuples out of it, and a second thread that runs every 30ms, gets the tuple, and sends it to the Arduino. Not that using a tuple here is already a thread-aware tecnique, if you were using three different variables for X,Y,A, the Arduino thread could be reading them exactly when the video analysis thread updates them and obtain X,Y from the previous extract and A from the new extract. Using a tuple(*) ensures that all three values aere collected together.
(*) and not a list... the tuple contents are immutable...
Threading is complicated when your threads write to the same variables. But here you would have one thread that periodically extracts the 'T' position and makes a tuples out of it, and a second thread that runs every 30ms, gets the tuple, and sends it to the Arduino. Not that using a tuple here is already a thread-aware tecnique, if you were using three different variables for X,Y,A, the Arduino thread could be reading them exactly when the video analysis thread updates them and obtain X,Y from the previous extract and A from the new extract. Using a tuple(*) ensures that all three values aere collected together.
(*) and not a list... the tuple contents are immutable...
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Your one-stop place for all your GIMP needs: gimp-forum.net