@ -20,7 +20,7 @@ import ctypes 
			
		
	
		
			
				
					from  ctypes  import  c_int64  
			
		
	
		
			
				
					from  server  import  run_server ,  RTSPServer ,  get_local_ip  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					showTrack  =  Tru e 
			
		
	
		
			
				
					showTrack  =  Fals e 
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					class  Core ( QThread ) :  
			
		
	
		
			
				
					    newFrame  =  pyqtSignal ( object ,  int ,  bool ,  ctypes . c_int64 )  
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -79,35 +79,32 @@ class Core(QThread): 
			
		
	
		
			
				
					            self . set_source ( 0 )  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    def  __stream ( self ) :  
			
		
	
		
			
				
					        # return  
			
		
	
		
			
				
					        """ Continuous streaming of the video source. """  
			
		
	
		
			
				
					        while  self . __is_streaming :  
			
		
	
		
			
				
					            try :  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					                frame_0  =  self . __video_sources [ 0 ] . get_frame ( )  
			
		
	
		
			
				
					                frame_1  =  self . __video_sources [ 1 ] . get_frame ( )  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					                if  frame_1  is  not  None :  
			
		
	
		
			
				
					                    if  self . __is_tracking  and  self . __tracker  is  not  None  and  self . __processing_id  ==  1 :  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					                        if  self . __tracker_roi  is  not  None :  
			
		
	
		
			
				
					                            x ,  y ,  w ,  h  =  map ( int ,  self . __tracker_roi )  
			
		
	
		
			
				
					                            box_color  =  ( 0 ,  255 ,  255 )  if  self . __tracker__succ  else  ( 255 ,  0 ,  0 )  
			
		
	
		
			
				
					                            cv2 . rectangle ( frame_1 ,  ( x ,  y ) ,  ( x  +  w ,  y  +  h ) ,  box_color ,  2 )  
			
		
	
		
			
				
					                            print ( frame_1 . shape )  
			
		
	
		
			
				
					                    self . __rtspserver_1 . update_frame ( frame_1 )  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					                if  frame_0  is  not  None :  
			
		
	
		
			
				
					                    if  self . __is_tracking  and  self . __tracker  is  not  None  and  self . __processing_id  ==  0 :  
			
		
	
		
			
				
					                        if  self . __tracker_roi  is  not  None :  
			
		
	
		
			
				
					                            x ,  y ,  w ,  h  =  map ( int ,  self . __tracker_roi )  
			
		
	
		
			
				
					                            box_color  =  ( 0 ,  255 ,  255 )  if  self . __tracker__succ  else  ( 255 ,  0 ,  0 )  
			
		
	
		
			
				
					                            cv2 . rectangle ( frame_0 ,  ( x ,  y ) ,  ( x  +  w ,  y  +  h ) ,  box_color ,  2 )  
			
		
	
		
			
				
					                            print ( frame_0 . shape )  
			
		
	
		
			
				
					                    self . __rtspserver_0 . update_frame ( frame_0 )  
			
		
	
		
			
				
					                if  self . __is_tracking :  
			
		
	
		
			
				
					                    # Only update the non-tracking source  
			
		
	
		
			
				
					                    if  self . __processing_id  ==  0 :  
			
		
	
		
			
				
					                        if  frame_1  is  not  None :  
			
		
	
		
			
				
					                            self . __rtspserver_1 . update_frame ( frame_1 )  
			
		
	
		
			
				
					                    elif  self . __processing_id  ==  1 :  
			
		
	
		
			
				
					                        if  frame_0  is  not  None :  
			
		
	
		
			
				
					                            self . __rtspserver_0 . update_frame ( frame_0 )  
			
		
	
		
			
				
					                else :  
			
		
	
		
			
				
					                    # Update both sources if not tracking  
			
		
	
		
			
				
					                    if  frame_0  is  not  None :  
			
		
	
		
			
				
					                        self . __rtspserver_0 . update_frame ( frame_0 )  
			
		
	
		
			
				
					                    if  frame_1  is  not  None :  
			
		
	
		
			
				
					                        self . __rtspserver_1 . update_frame ( frame_1 )  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					                sleep ( 0.03 )  
			
		
	
		
			
				
					                # self.__tracker_roi = None  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            except  Exception  as  e :  
			
		
	
		
			
				
					                print ( e )  
			
		
	
		
			
				
					                sleep ( 0.1 )  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -167,6 +164,17 @@ class Core(QThread): 
			
		
	
		
			
				
					            self . __tracker_roi  =  bbox  
			
		
	
		
			
				
					            self . __tracker__succ  =  success  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            if  frame  is  not  None :  
			
		
	
		
			
				
					                if  self . __is_tracking  and  self . __tracker  is  not  None  and  self . __tracker_roi  is  not  None  :  
			
		
	
		
			
				
					                    x ,  y ,  w ,  h  =  map ( int ,  self . __tracker_roi )  
			
		
	
		
			
				
					                    box_color  =  ( 0 ,  255 ,  255 )  if  self . __tracker__succ  else  ( 255 ,  0 ,  0 )  
			
		
	
		
			
				
					                    cv2 . rectangle ( frame ,  ( x ,  y ) ,  ( x  +  w ,  y  +  h ) ,  box_color ,  2 )  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					                    if  self . __processing_id  ==  1 :  
			
		
	
		
			
				
					                        self . __rtspserver_1 . update_frame ( frame )  
			
		
	
		
			
				
					                    elif  self . __processing_id  ==  0 :  
			
		
	
		
			
				
					                        self . __rtspserver_0 . update_frame ( frame )  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            if  bbox  is  not  None :  
			
		
	
		
			
				
					                center  =  bbox [ : 2 ]  +  bbox [ 2 : ]  / /  2  
			
		
	
		
			
				
					                self . coordsUpdated . emit ( self . __processing_id ,  center ,  success )