def process_video(self, video_path, min_score_threshold, output_path, save_images):
    video_name = Path(video_path).stem
    video = cv2.VideoCapture(video_path)
    log_name = os.path.join(output_path, f'{video_name}_log.txt')
    with open(log_name, 'a') as log_file:
        frames = []
        while video.isOpened():
            (ret, frame) = video.read()
            if (not ret):
                break
            frame_number = len(frames)
            print('At Frame:', frame_number)
            (frame, boxes) = self.draw_boxes_for_image(frame, min_score_threshold)
            (height, width, layers) = frame.shape
            detector.log_boxes(frame_number, boxes, log_file, width, height)
            if save_images:
                frame_path = os.path.join(output_path, f'{video_name}_frame_{frame_number}.png')
                print('Saving image at', frame_path)
                vis_util.save_image_array_as_png(frame, frame_path)
            frames.append(frame)
        if save_images:
            out_video_path = os.path.join(output_path, f'{video_name}.avi')
            print('Saving video at', out_video_path)
            images_to_video(frames, out_video_path, 30)
    video.release()
    cv2.destroyAllWindows()
def process_video(self, video_path, min_score_threshold, output_path, save_images):
    video_name = Path(video_path).stem
    video = cv2.VideoCapture(video_path)
    log_name = os.path.join(output_path, f'{video_name}_log.txt')
    with open(log_name, 'a') as log_file:
        frames = []
        while video.isOpened():
            (ret, frame) = video.read()
            if (not ret):
                break
            frame_number = len(frames)
            print('At Frame:', frame_number)
            (frame, boxes) = self.draw_boxes_for_image(frame, min_score_threshold)
            (height, width, layers) = frame.shape
            detector.log_boxes(frame_number, boxes, log_file, width, height)
            if save_images:
                frame_path = os.path.join(output_path, f'{video_name}_frame_{frame_number}.png')
                print('Saving image at', frame_path)
                vis_util.save_image_array_as_png(frame, frame_path)
            frames.append(frame)
        if save_images:
            out_video_path = os.path.join(output_path, f'{video_name}.avi')
            print('Saving video at', out_video_path)
            images_to_video(frames, out_video_path, 30)
    video.release()
    cv2.destroyAllWindows()