コード例 #1
1
def main():
	global vid
	global fgbg
	global started
	global otsu
	global totHits
	global spotify
	
	spotify = Spotify()
	totHits = 0
	vid = cv2.VideoCapture(0)
	ret, cap = vid.read()
	started = False
	x,y,w,h = 0,0,75,75
	otsu = False
	
	
	fgbg = cv2.createBackgroundSubtractorMOG2(100, 10, False)
	#Main loop for the script
	while(vid.isOpened()):
		ret, img = vid.read()
		if totHits%20 == 1:
			print "Changing song"
			spotify.next()
		frame = img
		#Place wanted operations here
		if started:
			frame = fgbg.apply(frame)
			frame = cv2.bilateralFilter(frame, 9, 75, 75)
		
		if otsu:
			blur = cv2.GaussianBlur(frame,(7,7),0)
			ret3, frame = cv2.threshold(blur,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
			if not checkSnowBlindness(frame):
				calculateBoxContent(frame[x:x+w,y:y+h])

		cv2.rectangle(frame,(x,y),(x+w,y+h),(255,255,0),1)
		
		frame = cv2.flip(frame, 1)
		cv2.imshow('SpotiVision', frame)
		
		k = cv2.waitKey(30) & 0xff
		if k in keyPresses:
			keyPresses[k](frame)
	quit(1)
コード例 #2
0
ファイル: casifinal.py プロジェクト: tony1908/chepomotix
    elif enviar == '31': 
        PuertoSerie.write('4')
    elif enviar == '30': 
        PuertoSerie.write('5')
    elif enviar == '71' && tempo=='7': 
        PuertoSerie.write('6')
        tempo='6'
    elif enviar == '70' $$ tempo=='6': 
        PuertoSerie.write('7')
        tempo='7'
    elif enviar == '81': 
        PuertoSerie.write('8')
    elif enviar == '80': 
        PuertoSerie.write('9')
    if id_ant!=jsonData[0]['id']:
        if a=='9':
            spotify.playpause()
        elif a== '10':
            for i in range (15):spotify.volumeUp()
        elif a== '11':
            spotify.next()
        elif a== '12':
            for i in range (15):spotify.volumeDown()
        elif a== '13':
            spotify.previous()
        else:
            print enviar
    id_ant=jsonData[0]['id']

    time.sleep(1)