def __init__(self): super().__init__() self.ui = loadUi( 'tracking.ui', self ) #Load .ui file that define the window layout(buttons, tick boxoex...) self.setMouseTracking( True) #allow mouse tracking(use during manual mode) self.manual_mode = False #set manual mode to false to start in tracking face mode self.LED_ON = True #set LED on mode self.CameraID = 0 #define camera ID, first camera = ID 0, second ID 1 and so on self.rec = True #allows to start camera recording self.cap = cv2.VideoCapture( self.CameraID) #define open CV camera recording self.cap.set(3, 960) #set capture width self.cap.set(4, 540) #set capture height #The bigger the image is, the longer the processing is goint to take to process it ## My computer is a bit shit so I kept it quite small . self.min_tilt = 22 #minimum tilt angle in degree (up/down angle) self.max_tilt = 80 #maximum tilt angle in degree self.current_tilt = 0 #current tilt (info received from arduino and displayed in LCD numbers) self.target_tilt = 90 #the tilt angle you need to reach self.min_pan = 80 #minimum pan angle in degree(left/ right angle) self.max_pan = 100 #maximum pan angle in degree self.current_pan = 80 #current pan (info received from arduino and displayed in LCD numbers) self.target_pan = 90 #the pan angle you need to reach self.roam_target_pan = 90 self.roam_target_tilt = 90 self.roam_pause = 40 #amount of frame the camera is going to pause for when roam tilt or pan target reached self.roam_pause_count = self.roam_pause #current pause frame count self.is_connected = False #boolean defining if arduino is connected self.InvertPan = False #allows pan to be inverted self.InvertTilt = False #allows tilt to be inverted self.face_detected = False #define if a face is detected self.target_locked = False #define if detected face is close enough to the center of the captured image self.max_target_distance = 40 #minimum distance between face/center of image for setting target locked self.max_empty_frame = 50 #number of empty frame (no face detected) detected before starting roaming self.empty_frame_number = self.max_empty_frame #current empty frame count self.ard = comm_ard.ard_connect( self) #create object allowing communicationn with arduino self.initUI() #set up UI( see below )
def __init__(self): super().__init__() self.ui = loadUi('tracking.ui', self) self.setMouseTracking(True) self.manual_mode = False self.LED_ON = True self.CameraID = 0 self.rec = True self.cap = cv2.VideoCapture(self.CameraID) self.cap.set(3, 960) self.cap.set(4, 540) self.min_tilt = 22 self.current_tilt = 0 self.target_tilt = 90 self.min_pan = 80 self.max_pan = 100 self.current_pan = 80 self.target_pan = 90 self.roam_target_pan = 90 self.roam_target_tilt = 90 self.roam_pause = 40 self.roam_pause_count = self.roam_pause self.is_connected = False self.InvertPan = False self.InvertTilt = False self.face_detected = False self.target_locked = False self.max_target_distance = 40 self.max_empty_frame = 50 self.empty_frame_number = self.max_empty_frame self.ard = comm_ard.ard_connect(self) self.initUI() )
def __init__(self): super().__init__() self.ui = loadUi('tracking.ui', self) self.LCameraID = 0 self.RCameraID = 1 self.rec = True self.capL = cv2.VideoCapture(self.LCameraID) self.capR = cv2.VideoCapture(self.RCameraID) self.capL.set(3, 1920) self.capL.set(4, 1080) self.capR.set(3, 1920) self.capR.set(4, 1080) self.f = 100.0 # focal length in inches, have to calculate this with the camera we get self.j = 4.0 # distance between cameras in inches; have to measure and/or plan for this self.w = 3.0 # distance between cameras and servos in inches; have to measure and/or plan for this self.xL = 0.0 self.xR = 0.0 self.calculated_dist = sys.maxsize # distance from cameras in inches self.calculated_angle = 90.0 # angle to object from center of cameras self.is_connected = False self.face_detected = False self.max_empty_frame = 50 self.empty_frame_number = self.max_empty_frame self.ard = comm_ard.ard_connect(self) self.initUI()