Ejemplo n.º 1
0
    def connectToEyePi(self, image):

        # try1: cv2.threshold(img,127,255,cv2.THRESH_BINARY)
        # try2:
        print('i see faces')
        try:
            self.face_connection_thread_running = True
            input = EyePiInput()
            # input.image = cv2.threshold(image,127,255,cv2.THRESH_BINARY)
            input.image = pickle.dumps(obj=image,
                                       protocol=None,
                                       fix_imports=False)

            actions = dict()
            weather_input = WeatherInput()
            weather_input.location = 'Amsterdam,nl'
            actionParameter = pickle.dumps(obj=weather_input,
                                           protocol=None,
                                           fix_imports=False)
            actions[ActionEnum.WEATHER] = actionParameter
            input.action = actions

            input.deviceToken = self.device_token
            output = ConnectEyePi().handleRequest(input)
            time.sleep(10)
            if output.ok:
                print('ok, yay, I know you')
                self.cap.release()
                cv2.destroyAllWindows()
                self.face_connection_thread_running = False
            else:
                self.face_connection_thread_running = False
        except Exception as ex:
            print('exception catched %s' % ex)
Ejemplo n.º 2
0
 def __get_request_token(uniquename, deviceToken):
     eyeInput = EyePiInput()
     actions = dict()
     actions[ActionEnum.LOGIN] = pickle.dumps(obj=uniquename,
                                              protocol=None,
                                              fix_imports=False)
     eyeInput.action = actions
     eyeInput.person = uniquename
     eyeInput.deviceToken = deviceToken
     return ShortTermTokenMemoryClient().getToken(eyeInput)
Ejemplo n.º 3
0
    def make_weather_call(self):
        input = EyePiInput()
        input.deviceToken = self.__devicetoken
        input.token = self.__token
        actions = dict()
        actions[ActionEnum.WEATHER] = self.__person.autorisations[ActionEnum.WEATHER].module_config
        input.action = actions

        output = ConnectEyePi().handleRequest(input)
        print(output)
        print(self.__unpickle_action(output.data, ActionEnum.WEATHER))
        if output.ok:
            self.__token = output.token
Ejemplo n.º 4
0
    def make_phone_call(self):
        config = self.__unpickle(self.__person.autorisations[ActionEnum.PHONE].module_config)
        phone_input = GetStatus()
        phone_input.email = config.email

        input = EyePiInput()
        input.deviceToken = self.__devicetoken
        input.token = self.__token
        actions = dict()
        actions[ActionEnum.PHONE] = self.__pickle(phone_input)
        input.action = actions

        output = ConnectEyePi().handleRequest(input)
        print(output)
        print(self.__unpickle_action(output.data, ActionEnum.PHONE))
        if output.ok:
            self.__token = output.token
Ejemplo n.º 5
0
    def make_agenda_call(self):
        config = self.__unpickle(self.__person.autorisations[ActionEnum.AGENDA].module_config)
        agenda_input = GetItemsActionInput()
        agenda_input.email = config.email

        input = EyePiInput()
        input.deviceToken = self.__devicetoken
        input.token = self.__token
        actions = dict()
        actions[ActionEnum.AGENDA] = self.__pickle(agenda_input)
        input.action = actions

        output = ConnectEyePi().handleRequest(input)
        print(output)
        print(self.__unpickle_action(output.data, ActionEnum.AGENDA))
        if output.ok:
            print("output = ok")
            self.__token = output.token
Ejemplo n.º 6
0
    print('image == ' + filename)
    file = open(filename, 'rb')
    readfile = file.read()

    nparr = np.fromstring(readfile, np.uint8)
    image = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
    input.image = pickle.dumps(obj=image, protocol=None, fix_imports=False)

    actions = dict()
    weather_input = WeatherInput()
    weather_input.location = 'Amsterdam,nl'
    actionParameter = pickle.dumps(obj=weather_input,
                                   protocol=None,
                                   fix_imports=False)
    actions[ActionEnum.WEATHER] = actionParameter
    input.action = actions
    #parameter = GenericObject()
    #parameter.stringValue = "%s" % 'Amsterdam,nl'

    input.deviceToken = device_token
    #input.action = ActionEnum.WEATHER
    #input.actionParameters = parameter

    output = ConnectEyePi().handleRequest(input)
    print(output)
    if output.ok:
        for face in output.personCollection:
            confirm_input = ConfirmInput()
            confirm_input.image = face.image
            confirm_input.person = face.person
            ConnectEyePi().confimFace(confirm_input)