def init(self, parameters, inputs, outputs): try: ### data parameters self.img_size = (parameters.img_size, parameters.img_size) # Detection probability threshold. self.conf_thresh = parameters.conf_thresh # Number of People self.number_people = 0 # Person Index for Model self.person_index = parameters.person_index ### Fall parameters self.min_non_dets = parameters.min_non_dets self.box_size_thresh = (parameters.box_size_thresh, parameters.box_size_thresh) self.anks_shdr_thresh = parameters.anks_shdr_thresh self.dist_hist = parameters.dist_hist self.dist_count = parameters.dist_count self.fall_interval = parameters.fall_interval self.fall_time = -1 # Load model from the specified directory. print("loading the model...") self.model = panoramasdk.model() self.model.open(parameters.object_detector, 1) print("Detector loaded") self.pose_model = panoramasdk.model() self.pose_model.open(parameters.pose_model, 1) print("Pose model loaded") # Create input and output arrays. class_info = self.model.get_output(0) prob_info = self.model.get_output(1) rect_info = self.model.get_output(2) # Create pose output arrays heatmap_info = self.pose_model.get_output(0) self.class_array = np.empty(class_info.get_dims(), dtype=class_info.get_type()) self.prob_array = np.empty(prob_info.get_dims(), dtype=prob_info.get_type()) self.rect_array = np.empty(rect_info.get_dims(), dtype=rect_info.get_type()) self.heatmaps_array = np.empty(heatmap_info.get_dims(), dtype=heatmap_info.get_type()) # Fall tracking variables self.xpart_tracker, self.ypart_tracker = reset_tracker() self.frame_num, self.frame_prev, self.frame_curr, self.zero_dets = reset_counts() self.fall_idx = -1 self.master_idx = -1 return True except Exception as e: print("Exception: {}".format(e)) return False
def init(self, parameters, inputs, outputs): try: # Frame Number self.frame_num = 0 # Load model from the specified directory print("loading model") self.action_detection_model = panoramasdk.model() self.action_detection_model.open(parameters.action_detection, 1) print("model loaded") # panorama SDK specific declarations self.class_name_list = [] self.class_prob_list = [] class_info = self.action_detection_model.get_output(0) self.class_array = np.empty(class_info.get_dims(), dtype=class_info.get_type()) # Set up Timer self.time_start = time.time() self.seconds_to_wash = 120 # Misc self.list_actions = [] self.message = '' return True except Exception as e: print("Exception: {}".format(e)) return False
def init(self, parameters, inputs, outputs): try: self.frame_num = 0 self.class_name_list = [] self.class_prob_list = [] # Detection probability threshold. self.threshold = parameters.threshold # Load model from the specified directory. print("loading model") self.model = panoramasdk.model() self.model.open(parameters.action_detection, 1) print("model loaded") class_info = self.model.get_output(0) self.class_array = np.empty(class_info.get_dims(), dtype=class_info.get_type()) return True except Exception as e: print("Exception: {}".format(e)) return False
def init(self, parameters, inputs, outputs): try: # Frame Number Initialization self.frame_num = 0 # Index for pokemon from parameters self.index = parameters.pokemon_index # Set threshold for model from parameters self.threshold = parameters.threshold # set number of pokemon self.number_pokemon = 0 # Load model from the specified directory. print("loading the model...") self.model = panoramasdk.model() self.model.open(parameters.pokemon_detection, 1) print("model loaded") # Create input and output arrays. class_info = self.model.get_output(0) prob_info = self.model.get_output(1) rect_info = self.model.get_output(2) self.class_array = np.empty(class_info.get_dims(), dtype=class_info.get_type()) self.prob_array = np.empty(prob_info.get_dims(), dtype=prob_info.get_type()) self.rect_array = np.empty(rect_info.get_dims(), dtype=rect_info.get_type()) return True except Exception as e: print("Exception: {}".format(e)) return False
def init(self, parameters, inputs, outputs): try: self.threshold = parameters.threshold self.person_index = parameters.person_index self.threshold = parameters.threshold self.frame_num = 0 self.number_people = 0 self.colours = np.random.rand(32, 3) print("Loading model: " + parameters.people_counter) self.model = panoramasdk.model() self.model.open(parameters.people_counter, 1) print("Creating input and output arrays") class_info = self.model.get_output(0) prob_info = self.model.get_output(1) rect_info = self.model.get_output(2) self.class_array = np.empty(class_info.get_dims(), dtype=class_info.get_type()) self.prob_array = np.empty(prob_info.get_dims(), dtype=prob_info.get_type()) self.rect_array = np.empty(rect_info.get_dims(), dtype=rect_info.get_type()) self.mjpegserver = PanoramaMJPEGServer() print("Initialization complete") return True except Exception as e: print("Exception: {}".format(e)) return False
def init(self, parameters, inputs, outputs): """ This is the init method where you can declare variables that will be used in this class and initialize any objects if necessary. Args: Input parameters from the application configuration on the console. Input stream object that is created and passed in from mediapipeline. Output stream object that send data stream to panoramasdk data sink. Returns: Boolean. """ try: # Detection probability threshold. self.threshold = parameters.threshold self.person_index = parameters.person_index self.boxes = [] self.frame_num = 0 self.send_images = True # SD Code 2 self._batch_frame_count = [0] * len(inputs.video_in) self._frame_count = [0] * len(inputs.video_in) self._cam_standing_people = [[]] * len(inputs.video_in) self._curr_refs = [[]] * len(inputs.video_in) self._total_size_mask_count = [0] * len(inputs.video_in) self._cam_left = [-1] * len(inputs.video_in) self._size_mask = [[]] * len(inputs.video_in) # Load model from the specified directory. self.model = panoramasdk.model() self.model.open(parameters.people_counter, 1) class_info = self.model.get_output(0) prob_info = self.model.get_output(1) rect_info = self.model.get_output(2) self.class_array = np.empty(class_info.get_dims(), dtype=class_info.get_type()) self.prob_array = np.empty(prob_info.get_dims(), dtype=prob_info.get_type()) self.rect_array = np.empty(rect_info.get_dims(), dtype=rect_info.get_type()) return True except Exception as e: print("Exception: {}".format(e)) return False
def init(self, parameters, inputs, outputs): print('init()') try: self.input_size = parameters.input_size self.class_names = CLASSES self.threshold = parameters.threshold self.keep_ratio = KEEP_RATIO self.use_cv2_rect = USE_CV2_RECT self.frame_num = 0 bars = '-\|/' bar_format = '{} ' + MODEL_DISPLAY_NAME + ' {}' self.progress_bars = [bar_format.format(c, c) for c in bars] self.progress_bars_count = len(self.progress_bars) self.processor = utils.Processor(self.class_names, self.input_size, threshold=self.threshold, keep_ratio=self.keep_ratio) # Load model from the specified directory. print(f'Loading model {parameters.model}') start = time.time() self.model = panoramasdk.model() self.model.open(parameters.model, 1) print(f'Model loaded in {int(time.time() - start)} seconds') # Create output arrays info_0 = self.model.get_output(0) info_1 = self.model.get_output(1) info_2 = self.model.get_output(2) self.pred_0 = np.empty(info_0.get_dims(), dtype=info_0.get_type()) self.pred_1 = np.empty(info_1.get_dims(), dtype=info_1.get_type()) self.pred_2 = np.empty(info_2.get_dims(), dtype=info_2.get_type()) # Use all the model outputs self.predictions = [self.pred_0, self.pred_1, self.pred_2] return True except Exception as e: print("Exception: {}".format(e)) return False
def init(self, parameters, inputs, outputs): try: self.frame_num = 0 # Load model from the specified directory. print("loading the model...") self.model = panoramasdk.model() self.model.open(parameters.classifier, 1) print("model loaded") # Create input and output arrays. prob_info = self.model.get_output(0) self.prob_array = np.empty(prob_info.get_dims(), dtype=prob_info.get_type()) self.classes = get_classes() return True except Exception as e: print("Exception: {}".format(e)) return False
def init(self, parameters, inputs, outputs): try: # Detection probability threshold. self.threshold = parameters.threshold # Frame Number Initialization self.frame_num = 0 # Number of People self.number_people = 0 # Bounding Box Colors self.colours = np.random.rand(32, 3) # Person Index for Model from parameters self.person_index = parameters.person_index # Set threshold for model from parameters self.threshold = parameters.threshold # Create stream buffer. self.buffered_media = {} self.buffered_image = {} # Load model from the specified directory. print("loading the model...") self.model = panoramasdk.model() self.model.open(parameters.people_counter, 1) print("model loaded") # Create input and output arrays. class_info = self.model.get_output(0) prob_info = self.model.get_output(1) rect_info = self.model.get_output(2) self.class_array = np.empty(class_info.get_dims(), dtype=class_info.get_type()) self.prob_array = np.empty(prob_info.get_dims(), dtype=prob_info.get_type()) self.rect_array = np.empty(rect_info.get_dims(), dtype=rect_info.get_type()) return True except Exception as e: print("Exception: {}".format(e)) return False
def init(self, parameters, inputs, outputs): print('init()') try: # NOTE: these are specific to the alarm server self.consecutive_coyote_frames = 0 self.consecutive_coyote_threshold = 5 self.warning_server_url = "http://garage.home.com/trigger" self.input_size = parameters.input_size self.class_names = CLASSES self.processor = utils.Processor( self.class_names, self.input_size, keep_ratio=True) self.threshold = parameters.threshold self.frame_num = 0 # Load model from the specified directory. print(f'Loading model {parameters.model}') start = time.time() self.model = panoramasdk.model() self.model.open(parameters.model, 1) print(f'Model loaded in {int(time.time() - start)} seconds') # Create output arrays info_0 = self.model.get_output(0) info_1 = self.model.get_output(1) info_2 = self.model.get_output(2) self.pred_0 = np.empty(info_0.get_dims(), dtype=info_0.get_type()) self.pred_1 = np.empty(info_1.get_dims(), dtype=info_1.get_type()) self.pred_2 = np.empty(info_2.get_dims(), dtype=info_2.get_type()) # Use all the model outputs self.predictions = [self.pred_0, self.pred_1, self.pred_2] return True except Exception as e: print("Exception: {}".format(e)) return False