Exemple #1
0
 def _run(self):
     self.logger.info("Starting Up")
     self.startup()
     self.logger.info("Running")
     if self.input_queue is None:
         # this worker is a source, just run
         run_and_catch_exceptions(self.logger, self.run)
         run_and_catch_exceptions(self.logger, self.shutdown)
     else:
         # this worker is monitoring a queue, get each item and call run with it
         for item in iter(self.input_queue.get, 'STOP'):
             run_and_catch_exceptions(self.logger, self.run, item)
         run_and_catch_exceptions(self.logger, self.shutdown)
     self.logger.info("Done running")
    vid_characteristics = pd.read_csv(os.path.join(conf.dirs.output, 'online_samples.csv'))
    camera_list = vid_characteristics.camera.unique()
    n_cameras = len(camera_list)
    camera_to_idx = {camera_list[i]:i for i in range(n_cameras)}

    analysis_group_cameras = [Analysis() for _ in range(n_cameras)]

    analysis_group = Analysis()
    
    for filename in os.listdir(conf.dirs.annotations):
        if filename[-4:] != '.csv':
            continue
        vid_ref = filename[:-4]
        logger.info(f'Starting to process the video {vid_ref}.')
        analysis_group.pr_curves_onevid(vid_ref)
        camera = vid_characteristics[vid_characteristics['video_segment_name'] == vid_ref]['camera'].squeeze()
        analysis_group_cameras[camera_to_idx[camera]].pr_curves_onevid(vid_ref)
        logger.info(f'Done processing {vid_ref}.')

    analysis_group.pr_curves_agg()
    for i in range(n_cameras):
        try:
            analysis_group_cameras[i].pr_curves_agg(camera_list[i])
        except ValueError:
            logger.info(f'No objects for camera {camera_list[i]}!')

if __name__ == "__main__":
    script_name = os.path.basename(__file__).split(".")[0]
    setup(script_name)
    run_and_catch_exceptions(logger, main)