Skip to content

#KL26-124 動画作成スクリプト - #35

Open
sadomiya-sousi wants to merge 61 commits into
mainfrom
ticket-KL26-124
Open

#KL26-124 動画作成スクリプト#35
sadomiya-sousi wants to merge 61 commits into
mainfrom
ticket-KL26-124

Conversation

@sadomiya-sousi

@sadomiya-sousi sadomiya-sousi commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

チェックリスト

  • clang-format している
  • コーディング規約に準じている
  • チケットの完了条件を満たしている

変更点

追加

  • scripts/create_videoディレクトリ
  • tcreateVdeo.py
    • 動画作成のための実行ファイル。画像の解像度やフレームなどのoptionはファイルを直接編集することでも変更可能です
  • common/utils.hとcpp
    -- 便利関数をまとめたたクラス
  • common/MultiThread.h
  • tests/MultiThreadTest.cpp
  • camera_server/test/MultiThreadFramseSaveTest
    変更
  • Makefile
  • camera_server/modules/utils/FrameSave.hとcpp
  • Makefile.camera
    -- commonの全ての.cppをコンパイルに含めるように

動作テスト

実機で画像を保存。手元のPCで動画作成

実験方法

実験結果

添付資料

作成した動画
https://app.notion.com/p/uom-katlab/387dd5b1cc18806e8effe1826db68694?source=copy_link

@sadomiya-sousi

Copy link
Copy Markdown
Contributor Author

opencvで動画を作成する代わりに,FFmpegで動画化することで高速化を目指す。
ファイルを保存する時に,動画上で表示する情報もファイル名として加える。これによりLogを使用するよりも走行中の判定処理への遅延を低下を目指す
指摘があればお願いします。

@sadomiya-sousi sadomiya-sousi changed the title Ticket kl26 124 #Ticket-KL26-124 動画作成スクリプトの実装 Jun 24, 2026
@sadomiya-sousi sadomiya-sousi changed the title #Ticket-KL26-124 動画作成スクリプトの実装 #Ticket-KL26-124 動画作成スクリプト Jun 24, 2026
@sadomiya-sousi sadomiya-sousi changed the title #Ticket-KL26-124 動画作成スクリプト #KL26-124 動画作成スクリプト Jun 29, 2026
@HaruArima08

Copy link
Copy Markdown
Collaborator

EtRobocon2026.cppを書き換えたままpushしちゃってるからCIのテストが終了しなくなってる。
元の状態に戻してpushお願いします🙏

@takuchi17

takuchi17 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

あれ、今の実装だと、その時に検出したBBoxを描画するだけ?

調整に使いたいから、実際に見てるところに加えて、その時指定してるtargetXとか、ROIとかも一緒に描画したいって話で進んでたと思うんだけど。

仕様から再確認した方が良さそうです。
見間違いもしくは途中ならごめん。

@sadomiya-sousi

sadomiya-sousi commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

詰まったので仕様の再確認と意見欲しいです。
ROIも描画しました。
targetXCordinateを描画するなら、走行プロセスの持ってるtargetXCordinateを知る必要がある
    1.ソケット通信を拡張しやり取りするか
    2.カメラサーバー側のClockと走行プログラムのClockのズレを解消かRobotのタイムスタンプに絞る?
そもそも、タイムスタンプのズレを気にしてファイル名に描画に必要な情報を加えたのでタイムスタンプを解消できれば嬉しい?2ならcsvの保存したLogにある情報なら全部を描画出来るようになるかも?

@takuchi17 takuchi17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

保存を並列化したって話があったけど、それを実装できてそうには見えなかった(??)

コミット履歴には変更の痕跡があった。

このコミットでは画像処理のクラスでFrameSaveの関数自体を別スレッドで実行するようにしてたけど、FrameSaveの関数の頭からお尻までをthreadで囲めば使う側は並列化を意識せずに呼び出すだけでよくなるのかな?

(余裕があれば、並列化を取り入れるついでに、処理を別スレッドで実行するためのthreadラッパークラスみたいなのをcommonに作ってもらえるとありがたいです。簡単に並列化できるようになれば今後助かる。これはできればの話なので、スルーしてもいいです。)

Comment thread Makefile Outdated
@@ -1,3 +1,4 @@
SHELL := /bin/bash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは使ってないから不要?

@sadomiya-sousi sadomiya-sousi Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

実機でsourceコマンドを使うために追記しました。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourceコマンドを使わずに直接python環境を指定するように変更したので消去しました。

@sadomiya-sousi

Copy link
Copy Markdown
Contributor Author

保存を並列化したって話があったけど、それを実装できてそうには見えなかった(??)

コミット履歴には変更の痕跡があった。

このコミットでは画像処理のクラスでFrameSaveの関数自体を別スレッドで実行するようにしてたけど、FrameSaveの関数の頭からお尻までをthreadで囲めば使う側は並列化を意識せずに呼び出すだけでよくなるのかな?

(余裕があれば、並列化を取り入れるついでに、処理を別スレッドで実行するためのthreadラッパークラスみたいなのをcommonに作ってもらえるとありがたいです。簡単に並列化できるようになれば今後助かる。これはできればの話なので、スルーしてもいいです。)

別のPRで関数を並列で実行するラッパークラスを上げます。お願いします。

@sadomiya-sousi
sadomiya-sousi requested a review from a team July 18, 2026 12:12

@HaruArima08 HaruArima08 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

遅くなリました🙇
確認と修正お願いします。

Comment thread camera_server/modules/utils/FrameSave.cpp Outdated
Comment thread camera_server/modules/utils/FrameSave.cpp Outdated
Comment thread camera_server/modules/utils/FrameSave.cpp Outdated
Comment thread camera_server/modules/utils/FrameSave.cpp Outdated
Comment thread scripts/create_video/createLineTraceVideo.py
Comment thread scripts/create_video/createLineTraceVideo.py Outdated

@takuchi17 takuchi17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

対応ありがとう。
軽微な修正お願いします🙇

Comment thread camera_server/modules/utils/FrameSave.cpp
Comment thread camera_server/modules/utils/FrameSave.cpp
Comment thread camera_server/modules/utils/FrameSave.h Outdated
Comment on lines +40 to +46

/**
* @brief 値をint型にキャストして文字列に変換するヘルパー関数
* @param value 変換する値
* @return std::string 変換後の文字列
*/
static std::string toStrInt(double value);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この関数はcommonにutils.hみたいなの作って置いといていいかもね

Comment thread common/MultiThread.h Outdated
Comment on lines +21 to +26
* @example
* 静的メンバ関数の場合:
* MultiThread::wrap(FrameSave::save, frame, filePath, fileName);
* メンバ関数の場合:
* MultiThread::wrap(&class名::メンバ関数, &インスタンス, 引数1,引数2, 引数3...)
* 引数が参照型の場合はstd::ref()でのキャストが必要

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

良いコメントだと思います👌

@@ -0,0 +1,410 @@
"""
@file createVideo.py
@brief 保存された連続JPEG画像から、BoundingBox・文字を描画しつつ、FFmpegを利用し並列プロセスで高速に動画を作成する

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントは、このくらいの粒度でよさそう

Suggested change
@brief 保存された連続JPEG画像からBoundingBox・文字を描画しつつFFmpegを利用し並列プロセスで高速に動画を作成する
@brief 保存された連続JPEG画像から走行ログ可視化動画を作成する

Comment thread tests/MultiThreadTest.cpp Outdated
void memberFunc(DummyClassB& b) { b.value = 100; }
};

// 7. 他のクラスの参照を引数に持つメンバ関数を非同期で実行するテスト

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 7. 他のクラスの参照を引数に持つメンバ関数を非同期で実行するテスト
// 他のクラスの参照を引数に持つメンバ関数を非同期で実行するテスト

Comment thread tests/MultiThreadTest.cpp Outdated

namespace etrobocon2026_test {

TEST(MultiThreadTest, WrapFrameSave) {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FrameSave::save()を非同期で実行できる仕様に対応したテストケースです。
追加し忘れてました。

@sadomiya-sousi

sadomiya-sousi commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

同一の名前空間に同じ関数名がある場合、型推論できずエラーになるのでexampleを修正しました

@HaruArima08 HaruArima08 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

対応ありがとうございます🙏
昨年の動画作成よりも進化してると思います!
LGTM

@sadomiya-sousi

sadomiya-sousi commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

exampleを修正。呼び出し元のスコープを抜けた状態で実行すると、segamantation faultに
呼び出しには0~1ms。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants