From 3b8af4218a55feabf10f30d0e9f077c2bf905462 Mon Sep 17 00:00:00 2001 From: KeiyaNimura Date: Mon, 11 Nov 2024 00:44:45 +0900 Subject: [PATCH] =?UTF-8?q?update:=20=E3=82=A8=E3=83=A9=E3=83=BC=E3=83=8F?= =?UTF-8?q?=E3=83=B3=E3=83=89=E3=83=AA=E3=83=B3=E3=82=B0=E3=81=AE=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../front_camera/get_plarail_image.py | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/front_camera/front_camera/get_plarail_image.py b/front_camera/front_camera/get_plarail_image.py index 89c2112..58020a6 100644 --- a/front_camera/front_camera/get_plarail_image.py +++ b/front_camera/front_camera/get_plarail_image.py @@ -52,15 +52,22 @@ def extract_target_frame(self, output_path) -> None: # キャプチャを解放 cap.release() - if __name__ == "__main__": + try: + os.makedirs("video_data", exist_ok=True) + + # 画像を抽出するための入力動画ファイルのパス + input_video_path = "video_data/recorded_video.mp4" - os.makedirs("video_data", exist_ok=True) + # 動画ファイルの存在チェック + if not os.path.exists(input_video_path): + raise FileNotFoundError(f" '{input_video_path}' is Not Found") - # 画像を抽出する動画ファイルの名前 - output_video_path = "video_data/recorded_video.mp4" + # 画像をPla.jpegとして保存 + os.makedirs("image_data", exist_ok=True) + output_image_path = "image_data/Pla.jpeg" + extractor = GetPlarailImage(input_video_path) + extractor.extract_target_frame(output_image_path) - os.makedirs("image_data", exist_ok=True) - output_image_path = "image_data/Pla.jpeg" - extractor = GetPlarailImage(output_video_path) - extractor.extract_target_frame(output_image_path) \ No newline at end of file + except FileNotFoundError as e: + print(f"Error: {e}") \ No newline at end of file