ナンバープレートの画像読み取りでは、
を行う
※ Windows での展開(解凍)のためのソフトには,「7-Zip」などがある.
Windows のコマンドプロンプトで次を実行する
cd <openalpr-2.3.0-win-64bit.zip を展開(解凍)したディレクトリ> alpr -c us samples\us-1.jpg
※ うまく認識できない場合は、「No license plate found.」と表示される。
元画像 samples\us-1.jpg を下に示す。
この章は書きかけです
参考 Web ページ:https://github.com/openalpr/openalpr/tree/master/src/bindings/python
システム Python を使うことができる(その場合,Python のインストールは行わない)
システム Python を用いるときは,pip, setuptools の更新は次のコマンドで行う.
sudo apt -y update sudo apt -y install python3-pip python3-setuptools
Ubuntu で,システム Python 以外の Python をインストールしたい場合は pyenv が便利である: 別ページで説明している.
Python の URL: http://www.python.org/
【Python, pip の使い方】
Python, pip は,次のコマンドで起動できる.
【Python 開発環境のインストール】
JupyterLab, spyder, nteract (Python 開発環境) のインストールは, Windows でコマンドプロンプトを管理者として実行し, 次のコマンドを実行.
python -m pip install -U pip setuptools jupyterlab jupyter jupyter-console jupytext nteract_on_jupyter spyder
詳しくは,: 別ページで説明している.
JupyterLab, spyder, nteract (Python 開発環境) のインストール: : 別ページで説明している.
Windows での OpenALPR のインストール手順は、 別のページで説明している.
OpenALPR は、分かりやすいディレクトリに展開(解凍)すること。
python -m pip install -U numpy scipy
端末で,次のコマンドを実行.
バージョン番号が表示されれば OK.下の図とは違うバージョンが表示されることがある.
python -c "import numpy; print( numpy.__version__ )"
2
※ Windows での展開(解凍)のためのソフトには,「7-Zip」などがある.
この .zip ファイルは,e:\Downloads\openalpr-master\openalpr-master に展開(解凍)したものとして,説明を続けるので,適切に読み替えてください.
e: cd e:\Downloads\openalpr-master\openalpr-master
cd src\bindings\python python setup.py install
エラーメッセージが出ていなければOK
Python プログラムを動かすために, Windows では「python」, Ubuntu では「python3」などのコマンドを使う.
あるいは, 開発環境や Python コンソール(Jupyter Qt Console,Spyder,PyCharm,PyScripter など)の利用も便利である.
あるいは,オンラインで動くGoogle Colaboratory のノートブックの利用も,場合によっては便利である.
「D:/openalpr-2.3.0-win-64bit/openalpr_64」のところは、OpenALPR システムを展開(解凍)したディレクトリを設定すること
from openalpr import Alpr
alpr = Alpr("us", "D:/openalpr-2.3.0-win-64bit/openalpr_64/openalpr.conf", "D:/openalpr-2.3.0-win-64bit/openalpr_64/runtime_data")
if not alpr.is_loaded():
print("Error loading OpenALPR")
sys.exit(1)
alpr.set_top_n(20)
alpr.set_default_region("md")
results = alpr.recognize_file("/path/to/image.jpg")
i = 0
for plate in results['results']:
i += 1
print("Plate #%d" % i)
print(" %12s %12s" % ("Plate", "Confidence"))
for candidate in plate['candidates']:
prefix = "-"
if candidate['matches_template']:
prefix = "*"
print(" %s %12s%12f" % (prefix, candidate['plate'], candidate['confidence']))
# Call when completely done to release memory
alpr.unload()