Esempio n. 1
0
    def init(self):
        # Load Communicator
        if self.server_address != "":
            try:
                self.communicator = Communicator()
                print(self.cam_address, self.cam_address)
                self.communicator.load_client(self.server_address, self.cam_address, self.final_result_pool)
                self.communicator_thread = threading.Thread(target=self.communicator.run)
            except:
                return False, PrintLog.e("Socket communicator failed to load.")

        # Load Object Detector
        try:
            self.object_detector = YOLOv4(self.frame_info_pool, self.object_detection_result_pool, self.final_result_pool,model=self.object_detection_model,
                                          dataset=self.object_detection_dataset, score_threshold=self.score_threshold, nms_threshold=self.nms_threshold)
        except:
            return False, PrintLog.e("Object detector failed to load.")

        # Load Event Detector
        try:
            self.event_manager = EventManager(self.object_detection_result_pool, self.final_result_pool)
            self.event_manager_thread = threading.Thread(target=self.event_manager.run)
        except:
            return False, PrintLog.e("Object detector failed to load.")

        # Load Decoder Manager
        try:
            self.decoder_manager = DecoderManager(self.analysis_fps, self.cam_address, self.frame_info_pool)
            self.decoder_thread = threading.Thread(target=self.decoder_manager.run)
        except:
            return False, PrintLog.e("Decoder manager failed to load.")

        PrintLog.i("Edge analysis module is successfully loaded.")
        return True
def run_ffmpeg(video_path, extract_fps, frame_dir):
    try:
        command = "ffmpeg -y -hide_banner -loglevel panic -i {} -vsync 2 -q:v 0 -vf fps={} {}/%04d.jpg".format(
            video_path, extract_fps, frame_dir)
        os.system(command)
        frame_path_list = sorted(os.listdir(frame_dir))
        PrintLog.i(
            "Frame extraction is successfully completed(path: {}, framecount: {})"
            .format(frame_dir, len(frame_path_list)))
        return frame_path_list
    except:
        PrintLog.e("Frame extraction is failed")
        exit(0)
Esempio n. 3
0
 def __init__(self, cam_address, analysis_fps):
     super().__init__(cam_address)
     self.ret = None
     self.frame = None
     self.frame_number = 0
     self.cam_address = cam_address
     self.video_capture = cv2.VideoCapture(self.cam_address)
     self.fps = 0
     if not self.video_capture.isOpened():
         self.video_capture = None
         PrintLog.e("Invalid URL({})".format(self.cam_address))
     else:
         self.fps = self.video_capture.get(cv2.CAP_PROP_FPS)
     self.analysis_fps = int(self.fps / analysis_fps)