def test_statink_weapon_name2(self): # 画像認識された時に得られる文字列を stat.ink キーに正しく変換 # できるかテスト statink = self._load_StatInk() from ikalog.utils import IkaGlyphRecoginizer weapons = IkaGlyphRecoginizer() weapons.load_model_from_file('data/weapons.knn.data') for weapon_ja in weapons.weapon_names: assert statink.encode_weapon_name(weapon_ja)
# 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 IkaGlyphRecoginizer weapons = IkaGlyphRecoginizer() weapons.load_model_from_file('data/weapons.knn.data') 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 } )