def recoginize_deadly_weapons(self, payload): h = payload['sample_height'] images = self._unpack_deadly_weapons_image(payload) lang = payload['game_language'] deadly_weapon_recoginizer = DeadlyWeaponRecoginizer(lang) votes = {} for image in images: weapon_id = deadly_weapon_recoginizer.predict(image) votes[weapon_id] = votes.get(weapon_id, 0) + 1 best_result = (None, 0) for weapon_id in votes.keys(): if votes[weapon_id] > best_result[1]: best_result = (weapon_id, votes[weapon_id]) response_payload = { 'status': 'ok', 'deadly_weapon': best_result[0], 'score': best_result[1], 'total': len(images), } return response_payload
# 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 cv2 import os import sys base_dir = sys.argv[1] from ikalog.utils.character_recoginizer import DeadlyWeaponRecoginizer recoginizer = DeadlyWeaponRecoginizer() 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 = recoginizer.match(img) if not (answer in results): results[answer] = [] distance = 0 results[answer].append({ 'filename': filename, 'distance': distance
# 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 cv2 import os import sys base_dir = sys.argv[1] from ikalog.utils.character_recoginizer import DeadlyWeaponRecoginizer recoginizer = DeadlyWeaponRecoginizer() 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 = recoginizer.match(img) if not (answer in results): results[answer] = [] distance = 0 results[answer].append( { 'filename': filename, 'distance': distance } ) for reason in sorted(results):