# 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) # "q"を入力でアプリケーション終了 for e in pygame.event.get():
time.sleep(0.5) # 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"
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: bezelie.centering() time.sleep (1) bezelie.moveRot (-20) time.sleep(0.5) bezelie.moveRot (20) print ("さぁ、始めるよー") subprocess.call('/home/pi/aquestalkpi/AquesTalkPi -s 120 "さぁ、お腹大砲、始めるよー" | aplay', shell=True) time.sleep(1) subprocess.call('/home/pi/aquestalkpi/AquesTalkPi -s 120 "お腹で風を起こそう!" | aplay', shell=True) bezelie.moveRot (0) time.sleep(1) mode = 0 score = 0 while mode == 0: print ("僕から1メートル離れてね") subprocess.call('/home/pi/aquestalkpi/AquesTalkPi -s 120 "僕から1メートル離れてね" | aplay', shell=True) time.sleep(0.5) while True:
# 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) bezelie.moveYaw (-40) sleep (0.2) bezelie.moveYaw (0)
def target(self): while not self.stop_event.is_set(): bezelie.moveRot(-10) bezelie.moveYaw(-40, 4) bezelie.moveRot(10) bezelie.moveYaw(40, 4)