Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Threading
#1
I am a beginner in programming but I was able to develop a tracking program in python. It finds and tracks a T shape in a video and return its coordinates (cX, cY) and Orientation (angle). The code itself is working, however, I want to put it on a loop or thread that gives me an update of the values of those variables (cX, cY, angle). I am supposed to send this information every 30 ms to an Arduino through a port (or any other method, I am not really fussy about how). All I need is to see the variables even if they are saved in 


I know that this is possible with threading but as a beginner, I have never used threading. The more I read about it the more confused I got. everywhere I read it says threading is not for beginners. I tried understanding how it works but I am getting nowhere. 
The code is about 180 lines so instead of copying it all here, I will just put the main function that calls on the different ones used for the detection and tracking. If you need the whole code the please tell me.


def main ():
    loadShape()
    camera = cv2.VideoCapture("IR-Tracking.mov")
    total_start_time = time.time()
    fps_start_time = time.time()
    fps = 0
    total_fps = 0
    while makeIteration(camera):
        time_now = time.time()
        fps = fps + 1
        if time_now - fps_start_time > 1:
           print "FPS:", fps
           fps_start_time = time_now
           fps = 0

    seconds = int(time.time() - total_start_time)
    print "Total matches:",total_matches, "in", seconds, "seconds"

if __name__ == '__main__':
    main()
If it helps, I am using python 2.7 and not 3.

Hope anyone can help me. thnax
Reply


Messages In This Thread
Python Threading - by Amro_Al - Oct-30-2016, 09:55 AM
RE: Python Threading - by Ofnuts - Oct-30-2016, 10:48 AM
RE: Python Threading - by Amro_Al - Oct-30-2016, 12:50 PM
RE: Python Threading - by Ofnuts - Oct-30-2016, 03:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Concurrent futures threading running at same speed as non-threading billykid999 13 1,927 May-03-2023, 08:22 AM
Last Post: billykid999
  Tutorials on sockets, threading and multi-threading? muzikman 2 2,150 Oct-01-2021, 08:32 PM
Last Post: muzikman
  Can I open\use threading in Python? korenron 2 1,827 Jun-30-2021, 10:42 AM
Last Post: korenron
  Embedding python cause crash when use boost::asio multi threading udvatt108 0 1,735 Oct-04-2020, 03:15 PM
Last Post: udvatt108
  Python - Keyboard module - Threading problem ppel123 1 3,108 Apr-13-2020, 04:49 PM
Last Post: deanhystad
  Help Threading python robot lucandmendes 0 9,944 May-03-2018, 02:42 PM
Last Post: lucandmendes
  Problem with Python, MySQL and Multi-threading queries zagk 1 11,931 Jul-01-2017, 12:15 AM
Last Post: zagk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020