4
1

More than 1 year has passed since last update.

dlibのimglabを使ってアノテーションしてみた

Last updated at Posted at 2021-12-12

物体検出のための学習データを準備するために、dlibのimglabを使ってみた。

環境構築

software version
mac BigSur 11.6
python 3.8.2
pip 21.3.1

作業用の仮想環境はpipenvで構築しました。

mkdir dliblab
cd dliblab
pipenv --python 3.8

アノテーションする画像の準備

適当な顔写真を準備してfacesというディレクトリに保存しました。

導入作業

homebrewでcmakeをインストール。

brew install cmake

続いてdlibをダウンロード。

image.png

ダウンロードしたdlibを作業用ディレクトリ(dliblab)に置いてimglabをbuildします。

cd dlib-19.22/tools/imglab
mkdir build
cd build
cmake ..
cmake --build . --config Release

準備した画像ディレクトリを指定してxmlリストを作成。

./imglab -c ~/work/tests/dliblab/faces/all.xml ~/work/tests/dliblab/faces

作成したall.xmlを指定してimglabを起動。

./imglab ~/work/tests/dliblab/faces/all.xml

xquartzが起動してimglabのGUIが表示される。
image.png

shiftを押しながらドラッグするとマークすることができる。
image.png

マークし終わったら[File]-[Save As]を選択し、ファイル名を入力して保存。
(traning.xmlで保存しました)
image.png

traning.xmlを見るとマークの座標情報が記録されていました。

<?xml version='1.0' encoding='ISO-8859-1'?>
<?xml-stylesheet type='text/xsl' href='image_metadata_stylesheet.xsl'?>
<dataset>
<name>imglab dataset</name>
<comment>Created by imglab tool.</comment>
<images>
  <image file='Balloon.jpg'>
    <box top='16' left='68' width='48' height='65'/>
  </image>
  <image file='Girl.jpg'>
    <box top='6' left='40' width='75' height='94'/>
  </image>
  <image file='Lenna.jpg'>
    <box top='13' left='36' width='75' height='102'/>
  </image>
</images>
</dataset>

こうやってアノテーションするのかー、と学びになりました。
作成したxmlファイルを使って学習器を作成するのは次のステップとして今回はここまでにしたいと思います。

↓続き書きました。

参考

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1