Skip to content

Commit

Permalink
update: プラレール画像切り抜き・アップロード処理をバックグラウンドで実行するように
Browse files Browse the repository at this point in the history
  • Loading branch information
CHIHAYATAKU committed Nov 2, 2024
1 parent cb0ad5a commit 976488e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
6 changes: 1 addition & 5 deletions front_camera/front_camera/get_plarail_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import cv2
import os
from frame_timing_calculator import FrameTimingCalculator
from video_recorder import VideoRecorder


class GetPlarailImage:
Expand Down Expand Up @@ -55,16 +54,13 @@ def extract_target_frame(self, output_path) -> None:


if __name__ == "__main__":
video_recorder = VideoRecorder()
video_recorder.start_camera()

try:
os.makedirs("video_data", exist_ok=True)

# 出力する動画ファイルの名前
# 画像を抽出する動画ファイルの名前
output_video_path = "video_data/recorded_video.mp4"

video_recorder.recording(output_video_path)

finally:
video_recorder.close()
Expand Down
23 changes: 17 additions & 6 deletions module/Motion/CameraAction.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file CameraAction.cpp
* @brief カメラ撮影動作
* @author bizyutyu takahashitom
* @author bizyutyu takahashitom keiya121
*/

#include "CameraAction.h"
Expand All @@ -28,7 +28,7 @@ void CameraAction::run()
makeImageCommand, imageName);
} else if(subject == CameraAction::Subject::PLARAIL) {
sprintf(imageName, "Pla.jpeg");
sprintf(makeImageCommand, "plarail-image");
sprintf(makeImageCommand, "record");
snprintf(cmd, 256, "cd etrobocon2024/front_camera && make %s && cd ../..", makeImageCommand);
}

Expand All @@ -43,13 +43,24 @@ void CameraAction::run()
imageName);
system(cmd);
printf("%s\n", cmd);
} else {
}

// PLARAILが指定された場合には、画像の切り出し処理を行う
if(subject == CameraAction::Subject::PLARAIL) {
snprintf(cmd, 256,
"cd etrobocon2024 && make upload-image FILE_PATH=front_camera/image_data/%s && cd ..",
imageName);
"(cd etrobocon2024/front_camera && make %s && cd ../.., makeImageCommand) &",
imageName);
system(cmd);
printf("%s\n", cmd);
printf("%s\n", cmd);
}

// 画像を無線通信デバイスに送信する
snprintf(cmd, 256,
"(cd etrobocon2024 && make upload-image FILE_PATH=front_camera/image_data/%s && cd ..) &",
imageName);
system(cmd);
printf("%s\n", cmd);

}

void CameraAction::logRunning()
Expand Down

0 comments on commit 976488e

Please sign in to comment.