-
Notifications
You must be signed in to change notification settings - Fork 42
死因画像の学習
Takeshi HASEGAWA edited this page Oct 22, 2015
·
1 revision
いまのところ学習ツールがありません。 data/deadly_weapons.model がない場合は training/deadly_weapons/ を読んで学習します。
dhcp44-82:IkaLog hasegaw$ find training/deadly_weapons/ | head -30
training/deadly_weapons/
training/deadly_weapons//.DS_Store
training/deadly_weapons//52gal.1.png
training/deadly_weapons//52gal.10.png
training/deadly_weapons//52gal.15.png
training/deadly_weapons//52gal.2.png
training/deadly_weapons//52gal.3.png
training/deadly_weapons//52gal.4.png
training/deadly_weapons//52gal.5.png
training/deadly_weapons//52gal.6.png
training/deadly_weapons//52gal.7.png
training/deadly_weapons//52gal.8.png
training/deadly_weapons//52gal.9.png
training/deadly_weapons//52gal_deco.1.png
training/deadly_weapons//52gal_deco.2.png
training/deadly_weapons//52gal_deco.3.png
training/deadly_weapons//52gal_deco.4.png
training/deadly_weapons//52gal_deco.5.png
training/deadly_weapons//52gal_deco.6.png
training/deadly_weapons//96gal.1.png
training/deadly_weapons//96gal.2.png
training/deadly_weapons//96gal.3.png
training/deadly_weapons//96gal.4.png
training/deadly_weapons//96gal.5.png
training/deadly_weapons//96gal.6.png
training/deadly_weapons//96gal_deco.1.png
training/deadly_weapons//96gal_deco.2.png
training/deadly_weapons//96gal_deco.3.png
training/deadly_weapons//96gal_deco.4.png
training/deadly_weapons//96gal_deco.5.png
ここで配置する画像は ikalog/scenes/in_game.py の recoginize_and_vote_death_reason 関数内で生成できます。
def recoginize_and_vote_death_reason(self, context):
if self.deadly_weapon_recoginizer is None:
return False
img_weapon = context['engine']['frame'][218:218 + 51, 452:452 + 410]
img_weapon_gray = cv2.cvtColor(img_weapon, cv2.COLOR_BGR2GRAY)
ret, img_weapon_b = cv2.threshold(
img_weapon_gray, 230, 255, cv2.THRESH_BINARY)
# (覚) 学習用に保存しておくのはこのデータ
if 0: # (self.time_last_write + 5000 < context['engine']['msec']):
filename = os.path.join(
'training', '_deadly_weapons.%s.png' % time.time())
cv2.imwrite(filename, img_weapon_b)
self.time_last_write = context['engine']['msec']
- 上記部分の if 0: を if 1: にするとやられた時に training/_deadly_weapons.xxx.yyy.png ファイルが生成されます。
- 生成されたファイルから状態のよいものを選んで、 ブキID.適当な数字.png として学習ディレクトリに投入します。
- rm data/deadly_weapons.model
- 次回 IkaLog 起動時にモデルデータ再度生成されます。