Kazuhito00/Display-Corner-Estimation-Prototype
ディスプレイの4隅を検出するモデルのプロトタイプ
Display-Corner-Estimation-Prototype
ディスプレイの4隅を検出するモデルのプロトタイプです。
ONNXモデルを使用し、複数の入力サイズ(192x192, 384x384, 576x576, 768x768)のモデルを用意しています。
Requirements
opencv-python 4.13.0.90 or later
numpy 2.4.1 or later
onnxruntime 1.23.2 or later ※GPU推論する際は onnxruntime-gpu
Demo
デモの実行方法は以下です。
基本的な使用方法
Webカメラでリアルタイム検出
python sample_inference.pyまたは
python sample_inference.py 0画像ファイルの処理
python sample_inference.py sample.jpg動画ファイルの処理
python sample_inference.py asset/sample.mp4 --output result.mp4コマンドラインオプション
-
--model
使用するONNXモデルのパス
デフォルト:display_corner_estimator/model_384x384.onnx
選択肢:display_corner_estimator/model_192x192.onnxdisplay_corner_estimator/model_384x384.onnxdisplay_corner_estimator/model_576x576.onnxdisplay_corner_estimator/model_768x768.onnx
-
--output
出力ファイルのパス(画像/動画処理時)
デフォルト:なし -
--confidence
コーナー検出の信頼度閾値
デフォルト:0.1
範囲:0.0~1.0 -
--device
実行デバイスの選択
デフォルト:cpu
選択肢:cpu:CPUで実行cuda:NVIDIA GPUで実行(CUDA対応)tensorrt:TensorRTで実行(NVIDIA GPU)dml:DirectMLで実行(Windows、AMD/Intel GPU)auto:自動選択
-
--optimization
ONNX Runtime最適化レベル
デフォルト:all
選択肢:all:すべての最適化を有効化extended:拡張最適化basic:基本最適化none:最適化なし
-
--smooth
座標平滑化の移動平均フレーム数
デフォルト:1(平滑化なし) -
--warp
射影変換を有効化(検出したコーナーを使用して画像を矩形に変換)
デフォルト:無効 -
--warp-width
変換後の画像幅(--warp使用時)
デフォルト:960 -
--warp-height
変換後の画像高さ(--warp使用時)
デフォルト:540 -
--no-show
プレビューウィンドウを表示しない
デフォルト:表示する -
--max-frames
処理する最大フレーム数(動画/Webカメラ用、0=無制限)
デフォルト:0
Architecture
このプロジェクトは以下のコンポーネントで構成されています:
-
display_corner_estimator/: コア推論エンジンとユーティリティ
InferenceEngine: ONNXモデルのラッパークラスpreprocess_frame(): 画像の前処理decode_corner_heatmaps(): ヒートマップからコーナー座標をデコードdraw_corners(): 検出結果の可視化
-
sample_inference.py: エンドツーエンドの推論スクリプト
- Webカメラ、画像、動画の自動判定
- リアルタイム推論
- 射影変換による画像補正
- 検出結果と変換結果の横並び表示
Author
高橋かずひと(https://x.com/KzhtTkhs)
License
Display-Corner-Estimation-Prototype is under Apache-2.0 License.
