def drawAllRecording(screen, rpt, rpt2, tipThumb,tipThumb2, kThumb,kThumb2, tipIndex,tipIndex2,kIndex,kIndex2,averageX,averageY,averageX2,averageY2,myfont, calibFont,depthFont): # screen.fill(vals.black) if not vals.testTypeFlag: # Normal Recording Mode mouseLabel=myfont.render("Mouse:"+" "+str(vals.mouseModeValue) ,1,(255,255,255)) screen.blit(mouseLabel,(0,80)) clickLabel=myfont.render("Click:"+" "+str(vals.clickValue) ,1,(255,255,255)) screen.blit(clickLabel,(0,95)) Calib1=calibFont.render("tipThumb:"+str(int(vals.depthBuff[0].mean())),1,vals.white) screen.blit(Calib1,(0,115)) Calib2=calibFont.render("kThumb:"+str(int(vals.depthBuff[1].mean())),1,vals.white) screen.blit(Calib2,(0,135)) Calib3=calibFont.render("tipIndex:"+str(int(vals.depthBuff[2].mean())),1,vals.white) screen.blit(Calib3,(0,155)) Calib4=calibFont.render("kIndex:"+str(int(vals.depthBuff[3].mean())),1,vals.white) screen.blit(Calib4,(0,175)) #tipDistance=calibFont.render("Switch-Distance:"+str(int(vals.tipDistance)),1,vals.white) #screen.blit(tipDistance,(0,205)) #clickDistance=calibFont.render("Click-Distance:"+str(int(vals.clickDistance)),1,vals.white) #screen.blit(clickDistance,(0,235)) x,y = rpt[tipIndex][0], rpt[tipIndex][1] z = np.mean(fun.smooth(vals.depthBuff[2].data, window_len = vals.depthBuff[2].size())) distance = getPlaneDistance(vals.planeParam, x, y, z) keyboardTop = vals.planeParam[-1] tipDistance=calibFont.render("Distance:"+str((distance)),1,vals.white) screen.blit(tipDistance,(0,205)) clickDistance=calibFont.render("Keyboard Top:"+str((keyboardTop)),1,vals.white) screen.blit(clickDistance,(0,235)) distance3D=calibFont.render("3D-Distance:"+str(int(vals.dist3D)),1,vals.white) screen.blit(distance3D,(0,255)) box3D=calibFont.render(str(int(vals.boxLimit)),1,vals.white) screen.blit(box3D,(0,285)) #Circles to check on mode switching # if doDepth.checkAllInBox(): # Used to log data if vals.inSwitchBox: pygame.draw.circle(screen, vals.green, (10,325),10) else: pygame.draw.circle(screen, vals.red, (10,325),10) inBox=calibFont.render("in 3dBox",1,vals.white) screen.blit(inBox,(20,325)) vals.inrange, vals.LED1,vals.LED2,vals.LED3,vals.LED4=checkingInRange.rangeChecker(vals.rptList, vals.LED1, vals.LED2,vals.LED3,vals.LED4) if (vals.inrange==1): pygame.draw.circle(screen, vals.green, (10,345),10) else: pygame.draw.circle(screen, vals.red, (10,345),10) inBox=calibFont.render("inrange",1,vals.white) screen.blit(inBox,(20,345)) if (not vals.mouseSwitched_flg): # Used to log data pygame.draw.circle(screen, vals.green, (10,365),10) else: pygame.draw.circle(screen, vals.red, (10,365),10) inBox=calibFont.render("open tips",1,vals.white) screen.blit(inBox,(20,365)) # Show window size which is used to control the sensitivity windowSize = calibFont.render('window size X:{} Y:{}'.format(str(vals.windowX), str(vals.windowY)), 1, vals.white) screen.blit(windowSize, (0, 400)) # Show the buffer size which is modified by the speed in the new feature(shift+f to turn on/off) if vals.featureFlag: buffSize = calibFont.render('current buffer size: {}'.format(str(vals.buff[0].size())), 1, vals.white) else: buffSize = calibFont.render('default buffer size: {}'.format(str(vals.defaultBuffSize)), 1, vals.white) screen.blit(buffSize, (0, 420)) # Show the depth of the four LED : 440, 460, 480, 500 ledDepthKey = ['tipThumb: ', 'knuThumb: ', 'tipIndex: ', 'knuIndex: '] for i in range(len(ledDepthKey)): ledDepth = calibFont.render(ledDepthKey[i] + str(vals.depthBuff[i].back()), 1, vals.white) screen.blit(ledDepth, (0, 440 + i * 20)) if vals.relativeFlag: controlMode = calibFont.render('Relative Mode', 1, vals.white) screen.blit(controlMode, (0, 520)) onKeyboard = calibFont.render('Keyboard Test: ' + str(vals.onKeyboardFlag), 1, vals.white) screen.blit(onKeyboard, (0, 540)) else: controlMode = calibFont.render('Absolute Mode', 1, vals.white) screen.blit(controlMode, (0, 520)) rawXY = calibFont.render('Raw X:{}, Y:{}'.format(rpt[tipIndex][0], rpt[tipIndex][1]), 1, vals.white) screen.blit(rawXY, (0, 560)) traceXY = calibFont.render('Mouse X:{}, Y:{}'.format(int(vals.traceX), int(vals.traceY)), 1, vals.white) screen.blit(traceXY, (0, 580)) smoothTipIndex = np.mean(fun.smooth(vals.depthBuff[2].data, window_len = vals.depthBuff[2].size())) distance = getPlaneDistance(vals.planeParam, rpt[tipIndex][0], rpt[tipIndex][1], smoothTipIndex) tipIndexDepth = calibFont.render('Tip Index Depth: {}'.format(distance), 1, vals.white) screen.blit(tipIndexDepth, (0, 600)) #main circles pygame.draw.circle(screen, vals.red, (rpt[tipIndex][0]/3,rpt[tipIndex][1]/3),10) pygame.draw.circle(screen, vals.blue, (rpt[kIndex][0]/3,rpt[kIndex][1]/3),10) pygame.draw.circle(screen, vals.green, (rpt[tipThumb][0]/3,rpt[tipThumb][1]/3),10) pygame.draw.circle(screen, vals.white, (rpt[kThumb][0]/3,rpt[kThumb][1]/3),10) pygame.draw.circle(screen, vals.gray, (averageX/3,averageY/3),13) pygame.draw.circle(screen, vals.gray, (averageX2/3,averageY2/3),13) pygame.draw.circle(screen, vals.red, (rpt2[tipIndex2][0]/3,rpt2[tipIndex2][1]/3),10) pygame.draw.circle(screen, vals.blue, (rpt2[kIndex2][0]/3,rpt2[kIndex2][1]/3),10) pygame.draw.circle(screen, vals.green, (rpt2[tipThumb2][0]/3,rpt2[tipThumb2][1]/3),10) pygame.draw.circle(screen, vals.white, (rpt2[kThumb2][0]/3,rpt2[kThumb2][1]/3),10) #GUI for depth # pygame.draw.rect(screen, vals.gray, (500,0,1500,1500)) depthGUILeft = int(vals.width * 0.35) depthGUITop = int(vals.height * 0.05) depthGUIWidth = int(vals.width * 0.45) - depthGUILeft depthGUIHeight = int(vals.height * 0.95) - depthGUITop pygame.draw.rect(screen, vals.gray, (depthGUILeft, depthGUITop, depthGUIWidth, depthGUIHeight)) # 0left--1startPos--2green--3white--4red--5blue--6endPos--7label--8right objXPos = np.linspace(depthGUILeft, depthGUILeft + depthGUIWidth, 9) objXPos = [int(x) for x in objXPos] #Creating the lines for i in xrange(11): offsetY = 75 startPos = (objXPos[1], offsetY + i*30) # was 550 endPos = (objXPos[6], offsetY + i*30) # was 650 pygame.draw.line(screen, vals.black, startPos, endPos) depthLabel = depthFont.render( str(5*i), 1, vals.black) screen.blit(depthLabel, (objXPos[7], offsetY + i*30)) #Depth circles. Was 560, 580, 600, 620 pygame.draw.circle(screen, vals.green, (objXPos[2], int(75 + vals.depthBuff[0].mean()*6)), 10) #tipThumb pygame.draw.circle(screen, vals.white, (objXPos[3], int(75 + vals.depthBuff[1].mean()*6)), 10) #kThumb pygame.draw.circle(screen, vals.red, (objXPos[4], int(75 + vals.depthBuff[2].mean()*6)), 10) #tipindex pygame.draw.circle(screen, vals.blue, (objXPos[5], int(75 + vals.depthBuff[3].mean()*6)), 10)#kIndex #The gesture bounds pygame.draw.line(screen,vals.red, (vals.gestureLeftThreshHold/3,0),(vals.gestureLeftThreshHold/3,800)) pygame.draw.line(screen,vals.blue, (0,vals.gestureDownThreshHold/3),(10000,vals.gestureDownThreshHold/3)) pygame.draw.line(screen,vals.yellow, (0,vals.gestureUpThreshHold/3),(10000,vals.gestureUpThreshHold/3)) #Mouses mode drawing if vals.mouse_flg: MouseKeyboard=myfont.render( "Mouse mode",1,(255,255,255)) else: MouseKeyboard=myfont.render( "Keyboard mode",1,(255,255,255)) screen.blit(MouseKeyboard,(0,50)) #input rectangle pygame.draw.line(screen,vals.white, (vals.inputX1/3,vals.inputY1/3), (vals.inputX2/3,vals.inputY1/3)) pygame.draw.line(screen,vals.white, (vals.inputX2/3,vals.inputY1/3), (vals.inputX2/3,vals.inputY2/3)) pygame.draw.line(screen,vals.white, (vals.inputX2/3,vals.inputY2/3), (vals.inputX1/3,vals.inputY2/3)) pygame.draw.line(screen,vals.white, (vals.inputX1/3,vals.inputY2/3), (vals.inputX1/3,vals.inputY1/3)) else: # Testing Recording Mode: Show article text. # I canceled the text input area. testFont = 'textFiles/MonospaceTypewriter.ttf' # Text GUI on the left: show the text if vals.textContent == '': # Read from file try: tcf = open(vals.textContentFile, 'r') vals.textContent = tcf.read() tcf.close() print vals.textContent except: print 'Error: Invalid type content file.' textGUILeft = int(vals.width * 0.05) textGUITop = int(vals.height * 0.05) textGUIWidth = int(vals.width * 0.45) - textGUILeft textGUIHeight = int(vals.height * 0.95) - textGUITop pygame.draw.rect(screen, vals.white, (textGUILeft, textGUITop, textGUIWidth, textGUIHeight)) if vals.textGUI == None: textFontSize = 20 textBorder = 10 vals.textGUI = Reader(unicode(vals.textContent.expandtabs(4), 'utf8'), (textGUILeft + textBorder, textGUITop + textBorder), \ textGUIWidth - 2 * textBorder, textFontSize, height = textGUIHeight - 2 * textBorder, \ font = testFont, fgcolor = (0, 0, 0), hlcolor = (255,10,150,100), split = True) vals.textGUI.show() '''
def run(self): global FLG, coords FLG = 1 m = PyMouse() k = PyKeyboard() #Intialization of Pygame pygameRate=100 os.environ['SDL_VIDEO_iWINDOW_POS'] = "%d,%d" % (0,0) pygame.mixer.pre_init(44100, -16, 2, 2048) # setup mixer to avoid sound lag pygame.init() vals.switchSound = pygame.mixer.Sound('switch.wav') vals.clickSound = pygame.mixer.Sound('click.wav') clock=pygame.time.Clock() myfont=pygame.font.SysFont("monospace",15) calibFont=pygame.font.SysFont("monospace",20) depthFont=pygame.font.SysFont("monospace",10) defaultFont=pygame.font.SysFont("monospace",15) pygame.mixer.init() infoObject = pygame.display.Info() vals.width = infoObject.current_w vals.height = infoObject.current_h # print width, height screen=pygame.display.set_mode((int(vals.width*0.5), vals.height)) global kill #Main loop while kill==False: screen.fill((0,0,0)) rpt=[[int(i2) for i2 in i]for i in coords[0]] rpt2=[[int(i2) for i2 in i]for i in coords[1]] if vals.switchRPT: tmp = rpt rpt = rpt2 rpt2 = tmp if not vals.rec_flg and (vals.calibration or vals.calibLoadFlag): #do calibration or load from file #Receiving data from the threads newList=findingPoints.findDegrees(rpt) #returns in from [(theta1,i1),(theta2,i2)....)] tipIndex, tipIndexAngle, kIndex,kIndexAngle=findingPoints.indexData(newList) tipThumb,tipThumbAngle,kThumb,kThumbAngle=findingPoints.thumbData(newList) averageX,averageY=findingPoints.centerFind(rpt) #the center point #Find out the location of the 2nd Wiimote LEDs newList2=findingPoints.findDegrees(rpt2) #returns in from [(theta1,i1),(theta2,i2)....)] tipIndex2, tipIndexAngle2, kIndex2,kIndexAngle2=findingPoints.indexData(newList2) tipThumb2,tipThumbAngle2,kThumb2,kThumbAngle2=findingPoints.thumbData(newList2) #GUI section #doDraw.drawAllMiniCalibration(miniScreen, rpt, tipIndex, tipThumb,kThumb,kIndex,averageX,averageY,myfont,calibFont,depthFont) doDraw.drawAllCalibration(screen, rpt, tipIndex, tipThumb,kThumb,kIndex,rpt2, tipIndex2, tipThumb2,kThumb2,kIndex2, averageX,averageY,myfont,calibFont,depthFont) if vals.inputCalibration: #Receiving data from the threads newList=findingPoints.findDegrees(rpt) #returns in from [(theta1,i1),(theta2,i2)....)] tipIndex, tipIndexAngle, kIndex,kIndexAngle=findingPoints.indexData(newList) tipThumb,tipThumbAngle,kThumb,kThumbAngle=findingPoints.thumbData(newList) averageX,averageY=findingPoints.centerFind(rpt) #the center point #Find out the location of the 2nd Wiimote LEDs newList2=findingPoints.findDegrees(rpt2) #returns in from [(theta1,i1),(theta2,i2)....)] tipIndex2, tipIndexAngle2, kIndex2,kIndexAngle2=findingPoints.indexData(newList2) tipThumb2,tipThumbAngle2,kThumb2,kThumbAngle2=findingPoints.thumbData(newList2) #GUI section doDraw.drawInputCalibration(screen, rpt, tipIndex, tipThumb,kThumb,kIndex,rpt2, tipIndex2, tipThumb2,kThumb2,kIndex2, averageX,averageY,myfont,calibFont,depthFont) #first "click" get where the rpt index x,y, store it. Second click completes the line, turn into square distClick=fun.distanceVec(\ [rpt[kIndex][0]],\ [rpt[kIndex][1]],\ [rpt[tipThumb][0]],\ [rpt[tipThumb][1]]) #first click if (distClick[0]<vals.clickValue and vals.inputCounter==0): vals.inputX1=rpt[tipIndex][0] vals.inputY1=rpt[tipIndex][1] vals.inputCounter+=1 vals.inputClickStopper=1 print "awef" print vals.inputX1,vals.inputY1 if (distClick[0]>=vals.clickValue and vals.inputClickStopper): vals.inputClickStopper=0 #second click if (distClick[0]<vals.clickValue and vals.inputCounter==1 and not vals.inputClickStopper): vals.inputX2=rpt[tipIndex][0] vals.inputY2=rpt[tipIndex][1] print "hey" print vals.inputX2,vals.inputY2 vals.inputCounter+=1 vals.inputSet=1 if vals.inputSet: #sets the inrange constants if vals.inputX1<=vals.inputX2: vals.leftBound=vals.inputX1 vals.rightBound=vals.inputX2 else: vals.leftBound=vals.inputX2 vals.rightBound=vals.inputX1 if vals.inputY1<=vals.inputY2: vals.upperBound=vals.inputY1 vals.lowerBound=vals.inputY2 else: vals.upperBound=vals.inputY2 vals.lowerBound=vals.inputY1 vals.windowX = vals.rightBound - vals.leftBound vals.windowY = vals.lowerBound - vals.upperBound if vals.rec_flg==1: #Recording #Finding out the location of the LEDs, tipThumb, kThumb.... newList=findingPoints.findDegrees(rpt) #returns in from [(theta1,i1),(theta2,i2)....)] tipIndex, tipIndexAngle, kIndex,kIndexAngle=findingPoints.indexData(newList) tipThumb,tipThumbAngle,kThumb,kThumbAngle=findingPoints.thumbData(newList) averageX,averageY=findingPoints.centerFind(rpt) #the center point #Find out the location of the 2nd Wiimote LEDs newList2=findingPoints.findDegrees(rpt2) #returns in from [(theta1,i1),(theta2,i2)....)] tipIndex2, tipIndexAngle2, kIndex2,kIndexAngle2=findingPoints.indexData(newList2) tipThumb2,tipThumbAngle2,kThumb2,kThumbAngle2=findingPoints.thumbData(newList2) averageX2,averageY2=findingPoints.centerFind(rpt2) #the center point #Check whether LED is in range newRpt=copy.deepcopy(rpt) vals.rptList.append(newRpt) vals.inrange, vals.LED1,vals.LED2,vals.LED3,vals.LED4=checkingInRange.rangeChecker(vals.rptList, vals.LED1, vals.LED2,vals.LED3,vals.LED4) if (vals.inputX1<=rpt[tipIndex][0]<=vals.inputX2 and vals.inputY1<=rpt[tipIndex][1]<=vals.inputY2) or \ (vals.inputX1<=rpt2[tipIndex][0]<=vals.inputX2 and vals.inputY1<=rpt2[tipIndex][1]<=vals.inputY2): vals.inrange=1 #Depth doDepth.findingDepth(rpt, rpt2, tipThumb,tipThumb2, kThumb,kThumb2, tipIndex,tipIndex2,kIndex,kIndex2) #GUI doDraw.drawAllRecording(screen, rpt, rpt2, tipThumb,tipThumb2, kThumb,kThumb2, tipIndex,tipIndex2,kIndex,kIndex2,averageX,averageY,averageX2,averageY2,myfont,calibFont,depthFont) #doDraw.drawAllMiniRecording(miniScreen, rpt, rpt2, tipThumb,tipThumb2, kThumb,kThumb2, tipIndex,tipIndex2,kIndex,kIndex2,averageX,averageY,myfont,calibFont,depthFont) # Only log the depth data in record mode when testing or debugging # if vals.relativeFlag: # if vals.depthBuff[2].size() > 10: # smoothTipIndex = np.mean(fun.smooth(vals.depthBuff[2].data[-10:], window_len = 10)) # else: # smoothTipIndex = np.mean(fun.smooth(vals.depthBuff[2].data, window_len = vals.depthBuff[2].size())) # smoothTipIndex = vals.depthBuff[2].back() # # log the depth and index tip raw coordinate # vals.planeDepthData.append('{}, {}, {}, {}, {}, {}'.format(vals.depthBuff[0].back(), vals.depthBuff[1].back(), \ # smoothTipIndex, vals.depthBuff[3].back(), rpt[tipIndex][0], rpt[tipIndex][1])) #Mouse Events #doMouse.mouseActivities(pygame,rpt, tipIndex,tipThumb,kIndex,kThumb,m,k) doMouse.clientMouseActivities(pygame,rpt,m,k) #Gestures # print doDepth.checkAllAboveBox() # if doDepth.checkAllAboveBox(): # doGestures.gestures(averageX,averageY,k,m) if vals.mouse_flg==1: tipParam = 7 knuParam = 3 if vals.knuckleFlag: fingerX = (rpt[tipIndex][0] * tipParam + rpt[kIndex][0] * knuParam) / (tipParam + knuParam) fingerY = (rpt[tipIndex][1] * tipParam + rpt[kIndex][1] * knuParam) / (tipParam + knuParam) else: fingerX, fingerY = rpt[tipIndex][0], rpt[tipIndex][1] # Relative: if vals.relativeFlag: smoothTipIndex = np.mean(fun.smooth(vals.depthBuff[2].data, window_len = vals.depthBuff[2].size())) keyboardTest = myIsOnKeyboard(fingerX, fingerY, smoothTipIndex) keyboardTest = isOnKeyboard(fingerX, fingerY, smoothTipIndex) if vals.onKeyboardFlag and not keyboardTest: # Hands up vals.fingerBuff[0].erase() vals.fingerBuff[1].erase() # else: # # Hands down # pass vals.onKeyboardFlag = keyboardTest if vals.onKeyboardFlag: vals.fingerBuff[0].put(fingerX) vals.fingerBuff[1].put(fingerY) # Move the mouse if vals.fingerBuff[0].size() >= 2: mouseX, mouseY = finger2MouseRelative(vals.fingerBuff[0].data, \ vals.fingerBuff[1].data, vals.traceX, vals.traceY) vals.buff[0].put(mouseX) vals.buff[1].put(mouseY) smoothX = np.mean(fun.smooth(vals.buff[0].data, window_len = vals.buff[0].size())) smoothY = np.mean(fun.smooth(vals.buff[1].data, window_len = vals.buff[1].size())) # print fingerX, fingerY, mouseX, mouseY vals.traceX, vals.traceY = smoothX, smoothY if not vals.testTypeFlag or (vals.testTypeFlag and vals.testPointFlag): m.move(vals.traceX, vals.traceY) # Absolute: elif not vals.relativeFlag: if not vals.zoom_flg: vals.fX=rpt[tipIndex][0] vals.fY=rpt[tipIndex][1] if ((vals.inputX2-vals.inputX1)==0) or ((vals.inputY2-vals.inputY1)==0): # Use default option mouseX, mouseY = finger2Mouse(fingerX, fingerY, False) # mouseX=(rpt[tipIndex][0]-600)*vals.width/vals.windowX # mouseY=(rpt[tipIndex][1]-150)*vals.height/vals.windowY else: # Use the user prefered window size mouseX, mouseY = finger2Mouse(fingerX, fingerY, True) if not vals.zoom_flg: vals.fingerX=fingerX vals.fingerY=fingerY vals.mouseX=mouseX vals.mouseY=mouseY """Currently we have the setting such that if there is a single LED that is out of range then the mouse wont move. The problem with this is that the range of the mouse gets limited, and some places (such as corners) are difficult/impossible to click. If we eliminate the if statement then this problem won't exist, but then it may start to recognize the knuckle LED as the tip and vice versa. So this is a give or take until we have a better filtering method.""" if (vals.inrange and doDepth.checkIndexInBox()) or vals.mouseState == vals.MOUSE_DRAG: vals.buff[0].put(mouseX) vals.buff[1].put(mouseY) smoothX = np.mean(fun.smooth(vals.buff[0].data, window_len = vals.buff[0].size())) smoothY = np.mean(fun.smooth(vals.buff[1].data, window_len = vals.buff[1].size())) if vals.featureFlag: vals.constBuff[0].put(mouseX) vals.constBuff[1].put(mouseY) sX = np.mean(fun.smooth(vals.constBuff[0].data, window_len = vals.constBuff[0].size())) sY = np.mean(fun.smooth(vals.constBuff[1].data, window_len = vals.constBuff[1].size())) # The speed of the cursor speed = np.sqrt( (sX - vals.traceX)**2 + (sY - vals.traceY)**2 ) if speed < 0.0001: speed = 0.0001 vals.speedBuff.put(speed) vals.smoothSpeed = np.mean(fun.smooth(vals.speedBuff.data, window_len = vals.speedBuff.size())) # Several method to get buffer size from speed: # paramA, paramB = 8.5, 20 # 1) size = A + B / speed # newSize = max(int(paramA + paramB / vals.smoothSpeed), vals.minBuffSize) # 2) size = A + B / sqrt(speed) # newSize = max(int(paramA + paramB / np.sqrt(vals.smoothSpeed)), vals.minBuffSize) # newSize = min(newSize, vals.maxBuffSize) # P1(minSpeed, maxBuff), P2(maxSpeed, minBuff) maxSpeed = 25 minSpeed = 0.1 maxBuff = 35 minBuff = 10 # 3) size = A + B * speed paramB = float(minBuff - maxBuff) / (maxSpeed - minSpeed) paramA = maxBuff - paramB * minSpeed newSize = paramA + paramB * vals.smoothSpeed newSize = max(min(int(newSize), maxBuff), minBuff) vals.buff[0].setBuffSize(newSize) vals.buff[1].setBuffSize(newSize) if not vals.testTypeFlag or (vals.testTypeFlag and vals.testPointFlag): # Record the last trace point vals.traceX, vals.traceY = smoothX, smoothY # if vals.featureFlag:# and vals.mouseState == vals.MOUSE_READY: # # param = 20.0 / speed2 # # vals.traceX = int((vals.traceX * param + smoothX) / (1 + param)) # # vals.traceY = int((vals.traceY * param + smoothY) / (1 + param)) # vals.traceX = np.mean(fun.smooth(vals.buff[0].data[-vals.smoothSize:], window_len = vals.smoothSize)) # vals.traceY = np.mean(fun.smooth(vals.buff[1].data[-vals.smoothSize:], window_len = vals.smoothSize)) # # vals.traceX = (vals.traceX * 4 + smoothX) / 5 # # vals.traceY = (vals.traceY * 4 + smoothY) / 5 m.move(vals.traceX, vals.traceY) # m.move(vals.buff[0].data[-1],vals.buff[1].data[-1]) # m.move(smoothX, smoothY) # m.move(mouseX, mouseY) if vals.wiimoteNum >= vals.wiimoteMaxNum \ and not (vals.calibLoadFlag or vals.calibration or vals.rec_flg): doDraw.drawDefault(screen, defaultFont) eventsObject=pygame.event.get() doEvents.eventHandling(eventsObject) msElapsed=clock.tick(pygameRate) pygame.display.update() if kill==True or vals.quit_FLG: pygame.quit() sys.exit() break for event in eventsObject: if (event.type == QUIT) or (event.type == KEYDOWN and event.key == K_ESCAPE): kill=True pygame.quit() sys.exit() break
rpt=[ [0,0] for i in range(4)] rpt2=[ [0,0] for i in range(4)] #Finding out the location of the LEDs, tipThumb, kThumb.... newList=findingPoints.findDegrees(rpt) #returns in from [(theta1,i1),(theta2,i2)....)] tipIndex, tipIndexAngle, kIndex,kIndexAngle=findingPoints.indexData(newList) tipThumb,tipThumbAngle,kThumb,kThumbAngle=findingPoints.thumbData(newList) averageX,averageY=findingPoints.centerFind(rpt) #the center point #Find out the location of the 2nd Wiimote LEDs newList2=findingPoints.findDegrees(rpt2) #returns in from [(theta1,i1),(theta2,i2)....)] tipIndex2, tipIndexAngle2, kIndex2,kIndexAngle2=findingPoints.indexData(newList2) tipThumb2,tipThumbAngle2,kThumb2,kThumbAngle2=findingPoints.thumbData(newList2) #Check whether LED is in range newRpt=copy.deepcopy(rpt) vals.rptList.append(newRpt) vals.inrange, vals.LED1,vals.LED2,vals.LED3,vals.LED4=checkingInRange.rangeChecker(vals.rptList, vals.LED1, vals.LED2,vals.LED3,vals.LED4) #Depth doDepth.findingDepth(rpt, rpt2, tipThumb,tipThumb2, kThumb,kThumb2, tipIndex,tipIndex2,kIndex,kIndex2) #GUI <<<<<<< HEAD #doDraw.drawAllRecording(screen, rpt, rpt2, tipThumb,tipThumb2, kThumb,kThumb2, tipIndex,tipIndex2,kIndex,kIndex2,averageX,averageY,myfont,calibFont,depthFont) doDraw.drawAllMiniRecording(miniScreen, rpt, rpt2, tipThumb,tipThumb2, kThumb,kThumb2, tipIndex,tipIndex2,kIndex,kIndex2,averageX,averageY,myfont,calibFont,depthFont) #Mouse Events doMouse.mouseActivities(rpt, tipIndex,tipThumb,kIndex,kThumb,m,k) ======= doDraw.drawAllRecording(screen, rpt, rpt2, tipThumb,tipThumb2, kThumb,kThumb2, tipIndex,tipIndex2,kIndex,kIndex2,averageX,averageY) #Mouse Events doMouse.mouseActivities(rpt, tipIndex,tipThumb,kIndex,kThumb) >>>>>>> 098035ea117798cf3908cf721c502fcebf4ee6a2 #Gestures