# CHECK CONNECTION WITH SFN try: resp = requests.get(url) except requests.exceptions.RequestException as e: print('WOO THERE, Something went wrong, error:' + str(e)) else: print(resp.text, resp.status_code) if resp.ok: while True: cam = random.randint(0, len(configs) - 1) for mess_type in message_locations: mess = tools.load_json_txt(mess_type[0], mess_type[1]) cam_conf = configs[cam] print(mess['type_module']) mess['camera_ids'][0] = cam_conf['camera_id'] # ADD IF STATEMENTS FOR EACH MODULE TYPE if mess['type_module'] == 'fighting_detection': mess['timestamp'] = str(arrow.utcnow()) mess['confidence'] == random.randint(0, 10) / 10 elif mess['type_module'] == 'crowd_density_local': mess['timestamp1'] = str(arrow.utcnow()) elif mess['type_module'] == 'flow': mess['timestamp'] = str(arrow.utcnow()) elif mess['type_module'] == 'action_recognition': mess['timestamp'] = str(arrow.utcnow()) elif mess['type_module'] == 'object_detection':
evaluating = False visualise = True # GET LIST OF MESSAGES AT FILE LOCATION messages = [] for f in sorted(os.listdir(folder_location)): ext = os.path.splitext(f)[1] if ext.lower().endswith('.txt'): messages.append(os.path.join(folder_location, f)) if evaluating: analyser = GetCrowd('001') for i in messages: file_name = os.path.splitext(i)[0] message = tools.load_json_txt(location=i) f = cv2.imread(file_name + '_frame.jpeg') frame = cv2.imread(file_name + '_frame.jpeg') # density = cv2.imread(file_name + '_density.jpeg') # settings_location = dataset_folder + 'CONFIG/ORIGINAL/' # config = tools.load_settings(settings_location, message['camera_ids'][0]) # cv2.rectangle(f, (5, 5), (375, 60), blk, -1) # cv2.putText(f, 'Camera Name: {}'.format(message['camera_ids'][0]), (5, 20), font, 0.5, wht, 1, cv2.LINE_AA) # cv2.putText(f, 'Number of People: {}'.format(message['density_count']), (5, 35), font, 0.5, wht, 1, cv2.LINE_AA) # cv2.putText(f, 'Time: {}'.format(message['timestamp_1']), (5, 50), font, 0.5, wht, 1, cv2.LINE_AA) # # key = cv2.waitKey(1) & 0xFF # cv2.imshow('frame', frame) # cv2.imwrite(os.path.join(save_folder, os.path.split(file_name)[1] + '_frame.jpeg'), f)