def run(self): global Count,ALPHA,BETA,HeadMoveExitFlagGlobal,GetColumnFlag,StateChangeExitFlagGlobal,Weight print "Creating ALVideoDevice proxy to ", self.IP nameId, camProxy = GetImgRemote.getCamID(self.IP, self.PORT, time.strftime('%X')) # please change the string if can't capture images cv2.namedWindow('img') #cv2.namedWindow('imgSource') WINDOWNAME = 'AdjustColor' cv2.namedWindow(WINDOWNAME) cv2.resizeWindow(WINDOWNAME, 640, 480) FindObject.creatTrackbar(WINDOWNAME, nothing) while True: #time.sleep(0.1) t1=time.clock() img = GetImgRemote.getimages(nameId, camProxy) cv2.imshow("imgSource", img) color = FindObject.getTrackbarValue(WINDOWNAME) if GetColumnFlag is False: newimg, CenterP, Count,Weight = FindObject.FindCoordinate(img, color) else: newimg, CenterP, Count,Weight,GarbageCenter = FindObject.FindGarbage(img,color) if Count > 0: #print CenterP[0][0], CenterP[0][1] # self.memory.insertData("directionSearch", 0) alpha, beta = Focus.FocusObject(CenterP) #print "alpha=", alpha #print "beta=", beta if GetColumnFlag is False: Focus.headMove(self.IP, self.PORT, [alpha, beta]) ALPHA = alpha BETA = beta else: alpha1, beta1 = Focus.FocusObject(GarbageCenter) Focus.headMove(self.IP, self.PORT, [alpha1, beta1]) ALPHA=alpha BETA=beta if Count <= 0: # self.memory.insertData("directionSearch", 0) ALPHA = None BETA = None cv2.imshow("img", newimg) key=cv2.waitKey(1) t2 = time.clock() #print 'vision time:', t2 - t1 if HeadMoveExitFlagGlobal == True: break if key == 27: Focus.headRest(self.IP, self.PORT) self.motion.rest() HeadMoveExitFlagGlobal = True StateChangeExitFlagGlobal = True sentence = "I stop the Head Move!" self.tts.say(str(sentence)) Focus.headRest(self.IP,self.PORT)