chasank/Image-Rectification のインストールと画像補正の実行(画像補正)(Python を使用)(Windows 上)
chasank/Image-Rectification をインストールし, 画像補正を行う.
画像補正
画像補正は,画像を射影変換することにより,斜め方向からの撮影画像を正面画像に変換する. 意図しないカメラ回転(ロール、ピッチ、ヨー)を含む画像を正面画像に補正できる.
また,AIの事前学習は,通常,正面画像で行われることが多く,画像補正を使うことで,AIの推論をより精度よく行うことができると期待できる.


【文献】
Chaudhury, Krishnendu, Stephen DiVerdi, and Sergey Ioffe. "Auto-rectification of user photos." 2014 IEEE International Conference on Image Processing (ICIP). IEEE, 2014.
【資料】 PDFファイル, パワーポイントファイル
【サイト内の関連ページ】
【関連する外部ページ】
GitHub のページ: https://github.com/chsasank/Image-Rectification
1. Google Colab へのリンク
Google Colaboratory のページ:
次のリンクをクリックすると,Google Colaboratory のノートブックが開く. そして,Google アカウントでログインすると,Google Colaboratory のノートブック内のコード等を編集したり再実行したりができる.編集した場合でも,他の人に影響が出たりということはない.そして,編集後のものを,各自の Google ドライブ内に保存することもできる.
https://colab.research.google.com/drive/11VNfE_9fEZ3IDAh-jSwVkrRVE6ZGJ4iM?usp=sharing
2. 前準備
Python 3.12,Git のインストール(Windows 上)
Pythonは,プログラミング言語の1つ. Gitは,分散型のバージョン管理システム.
【手順】
- Windows で,コマンドプロンプトを管理者権限で起動する(手順:Windowsキーまたはスタートメニュー,「cmd」と入力,右クリックメニューなどで「管理者として実行」を選択)
次のコマンドを実行
次のコマンドは,Python ランチャーとPython 3.12とGitをインストールし,Gitにパスを通すものである.
次のコマンドでインストールされるGitは 「git for Windows」と呼ばれるものであり, Git,MinGW などから構成されている.
reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f REM Python, Git をシステム領域にインストール winget install --scope machine --id Python.Python.3.12 --id Python.Launcher --id Git.Git -e --silent REM Python のパス set "INSTALL_PATH=C:\Program Files\Python312" echo %PATH% | find /i "%INSTALL_PATH%" >nul if errorlevel 1 setx PATH "%PATH%;%INSTALL_PATH%" /M >nul echo %PATH% | find /i "%INSTALL_PATH%\Scripts" >nul if errorlevel 1 setx PATH "%PATH%;%INSTALL_PATH%\Scripts" /M >nul REM Git のパス set "NEW_PATH=C:\Program Files\Git\cmd" if exist "%NEW_PATH%" echo %PATH% | find /i "%NEW_PATH%" >nul if exist "%NEW_PATH%" if errorlevel 1 setx PATH "%PATH%;%NEW_PATH%" /M >nul
【関連する外部ページ】
- Python の公式ページ: https://www.python.org/
- Git の公式ページ: https://git-scm.com/
【サイト内の関連ページ】
【関連項目】 Python, Git バージョン管理システム, Git の利用
3. chasank/Image-Rectification のインストール
- Windows で,コマンドプロンプトを管理者権限で起動する(手順:Windowsキーまたはスタートメニュー,「cmd」と入力,右クリックメニューなどで「管理者として実行」を選択)
- pip の更新と,chasank/Image-Rectification のインストール
* 「 python -m pip install ...」は,Python パッケージをインストールするためのコマンド.
python -m pip install -U --ignore-installed pip cd /d c:%HOMEPATH% rmdir /s /q Image-Rectification git clone --recursive https://github.com/chsasank/Image-Rectification
- 同封の画像ファイル shelf.jpg を使って実行してみる.
次のコマンドを実行
cd /d c:%HOMEPATH% cd Image-Rectification del results\shelf_warped.png python rectification.py results\shelf.jpg
- 実行の結果,result\shelf_warped.png ができる.
results\shelf.jpg と result\shelf_warped.png