def connectObj(self): # 显示图像队列 self.connectedObj = True #server_addr = '0.0.0.0' server_addr = self.server_addr # 检测结果队列 self.obj_queue_0 = Queue() self.obj_queue_1 = Queue() self.obj_queue_2 = Queue() self.obj_queue_3 = Queue() self.obj_queue_4 = Queue() self.obj_queue_5 = Queue() QueueManager.register('obj_0', callable=lambda: self.obj_queue_0) QueueManager.register('obj_1', callable=lambda: self.obj_queue_1) QueueManager.register('obj_2', callable=lambda: self.obj_queue_2) QueueManager.register('obj_3', callable=lambda: self.obj_queue_3) QueueManager.register('obj_4', callable=lambda: self.obj_queue_4) QueueManager.register('obj_5', callable=lambda: self.obj_queue_5) cambar_manager = QueueManager(address=(server_addr, 9112), authkey=b'dihuge') try: cambar_manager.start() except Exception as e: print(e) cambar_manager.connect() self.obj_0 = cambar_manager.obj_0() self.obj_1 = cambar_manager.obj_1() self.obj_2 = cambar_manager.obj_2() self.obj_3 = cambar_manager.obj_3() self.obj_4 = cambar_manager.obj_4() self.obj_5 = cambar_manager.obj_5()
def connectObj(self): while self.connectedObj == False: try: # color result queue QueueManager.register('obj_%d' % self.camId) manager = QueueManager(address=(self.server_addr, 9112), authkey=b'dihuge') manager.connect() # camNum = config['cameras']['camNum'] # for i in range(camNum): # if self.camId == i: # self.obj_sender = eval("manager.obj_%s"%(i)()) if self.camId == 0: self.obj_sender = manager.obj_0() elif self.camId == 1: self.obj_sender = manager.obj_1() elif self.camId == 2: self.obj_sender = manager.obj_2() elif self.camId == 3: self.obj_sender = manager.obj_3() elif self.camId == 4: self.obj_sender = manager.obj_4() elif self.camId == 5: self.obj_sender = manager.obj_5() self.connectedObj = True except Exception as e: print('Obj_ConnectRefuseRec', e) time.sleep(1)