コード例 #1
0
ファイル: learn_weapons.py プロジェクト: ymmtmdk/IkaLog
    f = open('weapons.html', 'w')
    f.write('<p>%s</p>' % s)
    for weapon in sorted(sort_zumi.keys()):
        f.write('<h3>%s</h3>' % weapon)
        print('<h3>%s</h3>' % weapon)
        for t in sorted(sort_zumi[weapon]):
            f.write('<font size=-4>%s</font><img src=%s alt="%s">' %
                    (t[0], t[1], t[0]))
            print('<font size=-4>%s</font><img src=%s alt="%s">' %
                  (t[0], t[1], t[0]))

    f.close()
    return s


weapons = WeaponRecoginizer()

learnImageGroup(weapons, "14式竹筒銃・甲", dir="14式竹筒銃・甲")
learnImageGroup(weapons, "14式竹筒銃・乙", dir="14式竹筒銃・乙")
learnImageGroup(weapons, "3Kスコープ", dir="3Kスコープ")
learnImageGroup(weapons, "3Kスコープカスタム", dir="3Kスコープカスタム")
learnImageGroup(weapons, "L3リールガン", dir="L3リールガン")
learnImageGroup(weapons, "L3リールガンD", dir="L3リールガンD")
learnImageGroup(weapons, "H3リールガン", dir="H3リールガン")
learnImageGroup(weapons, "H3リールガンD", dir="H3リールガンD")
learnImageGroup(weapons, "N-ZAP85", dir="N-ZAP85")
learnImageGroup(weapons, "N-ZAP89", dir="N-ZAP89")
learnImageGroup(weapons, "オクタシューターレプリカ", dir="オクタシューター")
learnImageGroup(weapons, "カーボンローラー", dir="カーボンローラー")
learnImageGroup(weapons, "カーボンローラーデコ", dir="カーボンローラーデコ")
learnImageGroup(weapons, "ガロン52", dir="ガロン52")
コード例 #2
0
ファイル: sort_weapons.py プロジェクト: itoyama/IkaLog
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

import cv2
import os
import sys

sys.path.append('.')
base_dir = sys.argv[1]

from ikalog.utils import WeaponRecoginizer

weapons = WeaponRecoginizer()
weapons.load_model_from_file()
weapons.knn_train()

results = {}
for root, dirs, files in os.walk(base_dir):
    l = []
    for file in files:
        if file.endswith(".png"):
            filename = os.path.join(root, file)
            img = cv2.imread(filename)
            answer, distance = weapons.match(img)
            if not (answer in results):
                results[answer] = []

            results[answer].append( { 'filename': filename, 'distance': distance } )
コード例 #3
0
ファイル: sort_weapons.py プロジェクト: xerosbeat/IkaLog
#  ======
#  Copyright (C) 2015 Takeshi HASEGAWA
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

import os
import sys

sys.path.append('.')
base_dir = sys.argv[1]

from ikalog.utils import WeaponRecoginizer

weapons = WeaponRecoginizer()
weapons.load_model_from_file()
weapons.knn_train()

weapons.test_samples_from_directory(base_dir)
weapons.dump_test_results_html(short=True)
コード例 #4
0
ファイル: learn_weapons.py プロジェクト: clovervidia/IkaLog
    # file にリスト書き出し
    f = open('weapons.html', 'w')
    f.write('<p>%s</p>' % s)
    for weapon in sorted(sort_zumi.keys()):
        f.write('<h3>%s</h3>' % weapon)
        print('<h3>%s</h3>' % weapon)
        for t in sorted(sort_zumi[weapon]):
            f.write('<font size=-4>%s</font><img src=%s alt="%s">' %
                    (t[0], t[1], t[0]))
            print('<font size=-4>%s</font><img src=%s alt="%s">' %
                  (t[0], t[1], t[0]))

    f.close()
    return s

weapons = WeaponRecoginizer()

for key in constants.weapons.keys():
    learnImageGroup(weapons, key, dir=key)

weapons.knn_train_from_group()
weapons.save_model_to_file()
weapons.knn_reset()
weapons.load_model_from_file()
weapons.knn_train()
if 1:
    s = loopbackTest()
    print(s)
    sys.exit()
コード例 #5
0
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

import cv2
import os
import sys

sys.path.append('.')
base_dir = sys.argv[1]

from ikalog.utils import WeaponRecoginizer

weapons = WeaponRecoginizer()
weapons.load_model_from_file()
weapons.knn_train()

results = {}
for root, dirs, files in os.walk(base_dir):
    l = []
    for file in files:
        if file.endswith(".png"):
            filename = os.path.join(root, file)
            img = cv2.imread(filename)
            answer, distance = weapons.match(img)
            if not (answer in results):
                results[answer] = []

            results[answer].append({