コード例 #1
0
def CameraCatch(path='Kamii_Sinogi/'):
    light.set_light("white", "still", True)
    with picamera.PiCamera() as camera:
        camera.start_preview()
        time.sleep(1)
        camera.capture(path + 'Face/stp.jpg')
        face_token = FaceDetect(path + 'Face/stp.jpg')
    light.set_solid(False)
    light.set_light("blue", "still")
    return face_token
コード例 #2
0
def CameraJudge(setname='Sinogi', judgetimes=3, path='Kamii_Sinogi/'):
    light.set_light("white", "still")
    path = HistorySave(path + 'Face/history/')
    with picamera.PiCamera() as camera:
        camera.start_preview()
        time.sleep(1)
        for now in range(0, judgetimes):
            camera.capture(path + '%d' % now + '.jpg')
            unknownface = FaceDetect(path + '%d' % now + '.jpg')
            possibleface = FaceSearch(unknownface, 'Sinogi')
            if (FaceCompare(unknownface, possibleface) == 0): return 0
            time.sleep(0.5)
    return 1
コード例 #3
0
                     file_open.close()
 time_now = time.localtime()
 # for i in setting["autoctrl_open"]:
 #     if cmp(time_now[3:4], i):
 #         with open('/home/pi/Kamii_Sinogi/Face/source/setting.json','w') as file_open:
 #             setting["sys_control"] = True
 #             json.dump(setting, file_open)
 #         file_open.close()
 # for i in setting["autoctrl_close"]:
 #     if cmp(time_now[3:4],i):
 #         with open('/home/pi/Kamii_Sinogi/Face/source/setting.json','w') as file_close:
 #             setting["sys_control"] = False
 #             json.dump(setting,file_close)
 #         file_close.close()
 if setting["sys_control"]==False:
     light.set_light("black","still")
     continue
 operate.angle_qingxie = setting["steer_angle"]
 operate.unlock_direction = setting["unlock_direction"]
 if opt.CameraJudge() == True:
     if setting["safety_mode"] == 0:
         bluetooth_check = True
     elif setting["safety_mode"] == 1:
         bluetooth_check = False
     elif setting["safety_mode"] == 2:
         bluetooth_check = bluetooth.sys_bluetooth()
     light.set_light("qing","sblink")
     if bluetooth_check == True:
         if setting["unlock_direction"] != 1:
             operate.op_operate(setting["steer_angle"], 'r')
         elif setting['unlock_direction'] == 1:
コード例 #4
0
def op_operate(angle_qingxie=-15, unlock_direction='r'):

    angle_rarm_close = 90
    angle_larm_close = 90
    angle_body_close = 0
    angle_leg_close = 0

    angle_rarm_open = -90
    angle_larm_open = -90
    angle_body_open = -angle_qingxie
    angle_leg_open = -angle_qingxie

    unlock = Adafruit_PCA9685.PCA9685()
    leg = Adafruit_PCA9685.PCA9685()
    body = Adafruit_PCA9685.PCA9685()
    larm = Adafruit_PCA9685.PCA9685()
    rarm = Adafruit_PCA9685.PCA9685()

    port_rarm = 5
    port_larm = 4
    port_body = 2
    port_leg = 1
    port_unlock = 0

    unlock.set_pwm_freq(60)
    leg.set_pwm_freq(60)
    body.set_pwm_freq(60)
    larm.set_pwm_freq(60)
    rarm.set_pwm_freq(60)

    light.set_light("green","sblink",True)
    op_set_angle(larm, port_larm, angle_larm_open)
    op_set_angle(rarm, port_rarm, angle_rarm_open)
    print 'Moving servo on arm to open.'
    time.sleep(time_sleep)
    op_set_angle(body, port_body, angle_body_open)
    print 'Moving servo on body to open.'
    op_set_angle(leg, port_leg, angle_leg_open)
    print 'Moving servo on leg to open.'
    # time.sleep(time_sleep)

    if unlock_direction == 'r':
        unlock.set_pwm(port_unlock, 0, num_runlock)
    elif unlock_direction == 'l':
        unlock.set_pwm(port_unlock, 0, num_lunlock)
    print 'Unlock.'

    light.set_light("green","still",True)
    time.sleep(time_wait)
    unlock.set_pwm(port_unlock, 0, num_lock)
    print 'Lock.'

    light.set_light("blue","still",True)

    op_set_angle(larm, port_larm, angle_larm_close)
    op_set_angle(rarm, port_rarm, angle_rarm_close)
    time.sleep(4*time_sleep)
    print 'Moving servo on arm to close.'
    op_set_angle(body, port_body, angle_body_close)
    print 'Moving servo on body to close.'
    op_set_angle(leg, port_leg, angle_leg_close)
    print 'Moving servo on leg to close.'
    time.sleep(time_sleep)
    light.set_solid(False)