def detect_face_with_append(threshold): memento_obj = memento.Memento() new_person_counter = 0 last_res = "" while True: time.sleep(5) print("Debug info: Fetch a picture and search for a face...") res = memento_obj.search_faceset(threshold) if res == last_res: print("Debug info: Same as the last one") continue else: if res == "new_face" and new_person_counter < 20: new_person_counter += 1 new_name = "new_person_" + str(new_person_counter) URL = URL_PRE + "adding_" + new_name # post detection result to web server 5 times for i in range(0, 5): requests.get(url=URL, params=PARAMS) print("Debug info: adding_" + new_name) memento_obj.fetch_images(new_name) memento_obj.append_faceset(new_name) URL = URL_PRE + new_name + "_added" # post detection result to web server 5 times for i in range(0, 5): requests.get(url=URL, params=PARAMS) print("Debug info: " + new_name + "_added") else: URL = URL_PRE + res # post detection result to web server 5 times for i in range(0, 5): requests.get(url=URL, params=PARAMS) print("Debug info: " + res) last_res = res
def detect_face(threshold): memento_obj = memento.Memento() new_person_counter = 0 last_res = "" while True: time.sleep(5) print("Debug info: Fetch a picture and search for a face...") res = memento_obj.search_faceset(threshold) if res == last_res: print("Debug info: Same as the last one") continue else: URL = URL_PRE + res # post detection result to web server 5 times for i in range(0, 5): requests.get(url=URL, params=PARAMS) print("Debug info: " + res) last_res = res
def create_snapshot(self): """ Create a snapshot of the current data, that are defining the petri net, to allow the recreation of a previous state. The data will be cloned to avoid a conflict with references. """ try: # instantiate an object that will define the snapshot state = model_state.ModelState() # check if data are available if self._data != None and self._data.petri_net_data != None: # clone data try: state.data = self.data.petri_net_data.clone() except AttributeError: return state.position = copy.deepcopy(self.data.get_positions()) # issue with NoneTypes because of this the AttributeError will be chaught if self.output != None: try: # clone output data state.output = self.output.clone() except AttributeError: state.output = None else: state.output = None # check if output arguments are available if self.output_args != None: state.output_args = copy.deepcopy(self.output_args) else: state.output_args = None # instantiate an empty memento m = memento.Memento() # assign data to memento m.state = state # attach memento to container self._container.add(m) except TypeError: pass
def clean_new_images(): memento_obj = memento.Memento() memento_obj.clean_new_images()
def rollback_faceset(): memento_obj = memento.Memento() memento_obj.delete_faceset() memento_obj.create_faceset()
def init_faceset(): memento_obj = memento.Memento() memento_obj.image_to_token() memento_obj.set_user_id() memento_obj.delete_faceset() memento_obj.create_faceset()