Skip to content

Commit

Permalink
update: エラーハンドリングの追加
Browse files Browse the repository at this point in the history
  • Loading branch information
keiya121 committed Nov 10, 2024
1 parent 96aadf6 commit 3b8af42
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions front_camera/front_camera/get_plarail_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
except FileNotFoundError as e:
print(f"Error: {e}")

0 comments on commit 3b8af42

Please sign in to comment.