Ejemplo n.º 1
0
     else:
         floor = floor_finder(code)
         print(floor)
         start = floor[1]
     print(i)
     path = path_to_take[i]
     if floor[0] in path_to_take:
         if floor[0] in inter:
             # print(path)
             for inte in inter:
                 if inte == floor[0]:
                     turn = turn_finder(path_to_take, inte)
                     # print("turn is {}".format(turn))
                     if turn is not None or turn != 'None':
                         print("turn is{}".format(turn))
                         arduino.flush_input()
                         arduino.write('stop')
                         sleep(6)
                         arduino.flush_input()
                         arduino.write(str(turn))
                         sleep(3)
                         arduino.write('line')
                         # message = arduino.readline()
                         # print(message)
                         break
     else:
         path_to_take, inter = path_finder(start, end)
         i = 0
         arduino.write('line')
 sleep(2)
 arduino.write('stop')
Ejemplo n.º 2
0
    # Look for faces in the image
    faces = face_cascade.detectMultiScale(gray, 1.5, 2)

    if faces is not ():
      # Display face detection on a led
      GPIO.output(FACE_DETECTION_STATUS_PIN, True)

      # Look for the biggest face
      biggest_face = get_biggest_face(faces)

      # Compute pan-tilt angle to adjust centring
      ax, ay = get_compensation_angle(biggest_face)

      # Update angles values
      angle_x = angle_x + ax
      angle_y = angle_y + ay
      servo_x.write(angle_x)
      servo_y.write(angle_y)

    else:
      GPIO.output(FACE_DETECTION_STATUS_PIN, False)

  except Exception as e:
    print e
    camera.stop_recording()
    GPIO.output(FACE_DETECTION_STATUS_PIN, False)
    GPIO.cleanup()
    connection.flush_input()
    connection.close()
    sys.exit(0)