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)
try: ## mock! ### # normally a device would properly register itself and keep the token. # But in development case, the cahce is resetted every time. This mock registers the device. device_token = DeviceRegistrator().register_device() ### end mock ### input = EyePiInput() filename = config.file_path + read_image() 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