def timeMessage(timeSlot): data = [] with open(csvFile, 'rb') as f: # opening the file to read for i in csv.reader(f): data.append(i) data1 = [] for index, i in enumerate(data): # making candidate list if i[1] == timeSlot: j = int(i[3]) * randint(9, 11) data1.append(i + [j] + [index]) maxNum = 0 for i in data1: # decision if i[5] > maxNum: maxNum = i[5] ansNum = i[6] data[ansNum][4] = int(data[ansNum][4]) + 1 # adding counter with open(csvFile, 'wb') as f: # opening the file to overwrite csv.writer(f).writerows(data) # AquesTalk print data[ansNum][2] bezelie.movePit(-20, 1) subprocess.call('/home/pi/aquestalkpi/AquesTalkPi -s 120 "' + data[ansNum][2] + '" | aplay', shell=True) sleep(0.5) bezelie.movePit(0, 1) sleep(2)
minSize=(200, 200), maxSize=(400, 400)) # scaleFactor 大きな値にすると速度が早くなり、精度が落ちる。1.1〜1.9ぐらい。 # minNeighbors 小さな値にするほど顔が検出されやすくなる。通常は3〜6。 # minSize 検出する顔の最小サイズ。解像度に合わせて修正してください。 # maxSize 検出する顔の最大サイズ。解像度に合わせて修正してください。 if len(facerect) > 0: # 顔が検出された場合の処理 for rect in facerect: # 顔の場所に四角を表示 # rect[0:2]:長方形の左上の座標, rect[2:4]:長方形の横と高さ # rect[0:2]+rect[2:4]:長方形の右下の座標 cv2.rectangle(stream.array, tuple(rect[0:2]), tuple(rect[0:2] + rect[2:4]), (0, 255, 0), thickness=4) bezelie.movePit(-15) # 背伸びをさせる sleep(0.2) bezelie.moveRot(10) sleep(0.2) bezelie.moveRot(-10) sleep(0.4) bezelie.moveRot(0) bezeTalk("long") #subprocess.call('/home/pi/aquestalkpi/AquesTalkPi -s 120 "こんにちわー" | aplay', shell=True) sleep(0.5) bezelie.movePit(0, 1) sleep(0.2) # pygameで画像を表示 pygame_imshow(stream.array)
# Centering All Servos bezelie.centering() # Main Loop try: with picamera.PiCamera() as camera: camera.resolution = (800, 480) # Change this number for your display camera.rotation = 180 # comment out if your screen upside down camera.start_preview() time.sleep(0.2) pit = 0 while (True): bezelie.moveRot(-15) bezelie.moveYaw(-40, 2) sensorCheck() time.sleep(1) bezelie.moveRot(15) bezelie.moveYaw(40, 2) sensorCheck() time.sleep(1) pit += 10 if pit > 10: pit = -20 bezelie.movePit(pit) time.sleep(1) except KeyboardInterrupt: print " Interrupted by Keyboard" GPIO.cleanup()
# -*- coding: utf-8 -*- # Bezelie Sample Code for Raspberry Pi : Talking Test by AquesTalk Pi from time import sleep import subprocess import bezelie # Get Started bezelie.centering() # Main Loop try: while (True): bezelie.movePit(20, 1) subprocess.call( '/home/pi/aquestalkpi/AquesTalkPi -s 120 "こんにちわー" | aplay', shell=True) sleep(0.5) bezelie.movePit(0, 1) sleep(2) except KeyboardInterrupt: print ' Interrupted by Keyboard'
# Bezelie Sample Code for Raspberry Pi : Servo Movement Test from time import sleep import bezelie # Set Up bezelie.centering() # Main Loop try: while (True): bezelie.movePit (30, 2) sleep (0.2) bezelie.movePit (-30, 1) sleep (0.2) bezelie.movePit (0) sleep (0.5) bezelie.moveRot (30, 1) sleep (0.2) bezelie.moveRot (-30, 1) sleep (0.2) bezelie.moveRot (0) sleep (0.5) bezelie.moveYaw (40) sleep (0.2)
if dist < 80: # flying # mode = 2 print ("フライングだよー") subprocess.call('/home/pi/aquestalkpi/AquesTalkPi -s 120 "フライングー" | aplay', shell=True) time.sleep(1) continue time.sleep(0.1) while True: distA = round(get_distance(),1) if distA > 10 and distA < 200: break bezelie.movePit (-20) i = distB - distA print i subprocess.call('/home/pi/aquestalkpi/AquesTalkPi -s 120 "記録" | aplay', shell=True) # time.sleep(0.5) subprocess.call('/home/pi/aquestalkpi/AquesTalkPi -s 120 "'+ str(i) +'" | aplay', shell=True) # time.sleep(0.5) subprocess.call('/home/pi/aquestalkpi/AquesTalkPi -s 120 "メートル" | aplay', shell=True) time.sleep(0.5) if i < 10: print ("失敗でーす") subprocess.call('/home/pi/aquestalkpi/AquesTalkPi -s 120 "あなた、駄目な人ですね" | aplay', shell=True) time.sleep(1) elif i < 20: print ("まぁまぁかな") subprocess.call('/home/pi/aquestalkpi/AquesTalkPi -s 120 "ふつーだね" | aplay', shell=True)
while GPIO.input(echo_pin) != value and count > 0: count -= 1 def get_distance(): send_trigger_pulse() wait_for_echo(True, 10000) start = time.time() wait_for_echo(False, 10000) finish = time.time() pulse_len = finish - start distance = pulse_len / 0.000058 return (distance) # Main Loop try: while True: print(round(get_distance(), 1)) if get_distance() < actionDistance: bezelie.movePit(-30) time.sleep(0.5) bezelie.movePit(0, 4) time.sleep(0.5) else: time.sleep(0.5) except KeyboardInterrupt: print " Interrupted by Keyboard" GPIO.cleanup()