예제 #1
0
    def _test_engine(self, mp4_filename, game_lang=None):
        from ikalog.utils import Localization
        if game_lang:
            Localization.set_game_languages(game_lang)

        from ikalog.inputs import CVFile
        from ikalog.engine import IkaEngine
        from ikalog.outputs.preview import Screen
        from ikalog.outputs.debug import DebugLog

        self.errors = []
        source = CVFile()
        source.start_video_file(mp4_filename)
        source.need_resize = True
        outputPlugins = [
            self,
            Screen(0, size=(640, 360)),
            # DebugLog(dir='./debug/', screenshot=True),
        ]

        self.engine = IkaEngine()

        self.engine.set_capture(source)
        self.engine.set_plugins(outputPlugins)
        self.engine.pause(False)

        print('Engine started')
        try:
            self.engine.run()
        except EOFError:
            pass
        print('Engine stopped')

        # 期待されたイベントが全て発生しているか確認
        for event_name in list(self.event_tickets.keys()):
            if self.event_tickets[event_name] is None:
                continue
            assert self.event_tickets[
                event_name] == 0, 'Missed event %s? %s tickets remained.' % (
                    event_name, self.event_tickets[event_name])

        assert len(self.errors) == 0, '\n'.join(self.errors)

        # unreference the engine
        engine = self.engine
        self.engine = None
        return engine
예제 #2
0
    def _test_engine(self, mp4_filename,game_lang=None):
        from ikalog.utils import Localization
        if game_lang:
            Localization.set_game_languages(game_lang)

        from ikalog.inputs import CVFile
        from ikalog.engine import IkaEngine
        from ikalog.outputs.preview import Screen
        from ikalog.outputs.debug import DebugLog

        self.errors = []
        source = CVFile()
        source.start_video_file(mp4_filename)
        source.need_resize = True
        outputPlugins = [
            self,
            Screen(0, size=(640, 360)),
            # DebugLog(dir='./debug/', screenshot=True),
        ]

        self.engine = IkaEngine()

        self.engine.set_capture(source)
        self.engine.set_plugins(outputPlugins)
        self.engine.pause(False)

        print('Engine started')
        try:
            self.engine.run()
        except EOFError:
            pass
        print('Engine stopped')

        # 期待されたイベントが全て発生しているか確認
        for event_name in list(self.event_tickets.keys()):
            if self.event_tickets[event_name] is None:
                continue
            assert self.event_tickets[event_name] == 0, 'Missed event %s? %s tickets remained.' % (
                event_name, self.event_tickets[event_name])

        assert len(self.errors) == 0, '\n'.join(self.errors)

        # unreference the engine
        engine = self.engine
        self.engine = None
        return engine
예제 #3
0
    def recoginize_deadly_weapons(self, deadly_weapons_list):
        if len(deadly_weapons_list) == 0:
            return None
        images = self.pack_deadly_weapons_image(deadly_weapons_list)

        payload = {
            'game_language': Localization.get_game_languages()[0],
            'sample_height': deadly_weapons_list[0].shape[0],
            'sample_width': deadly_weapons_list[0].shape[1],
            'samples': cv2.imencode('.png', images)[1].tostring()
        }

        response = self._request_func(
            '/api/v1/recoginizer/deadly_weapon',
            payload,
        )

        if response.get('status', None) != 'ok':
            return {'status': 'error'}

        return response
예제 #4
0
    def recoginize_deadly_weapons(self, deadly_weapons_list):
        if len(deadly_weapons_list) == 0:
            return None
        images = self.pack_deadly_weapons_image(deadly_weapons_list)

        payload = {
            'game_language': Localization.get_game_languages()[0],
            'sample_height': deadly_weapons_list[0].shape[0],
            'sample_width': deadly_weapons_list[0].shape[1],
            'samples': cv2.imencode('.png', images)[1].tostring()
        }

        response = self._request_func(
            '/api/v1/recoginizer/deadly_weapon',
            payload,
        )

        if response.get('status', None) != 'ok':
            return {'status': 'error'}

        return response
예제 #5
0
파일: preview.py 프로젝트: xerosbeat/IkaLog
#  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 copy
import os.path
import threading

import wx
import cv2

from ikalog.utils import Localization
from ikalog.ui.events import *

_ = Localization.gettext_translation('IkaUI', fallback=True).gettext


class FileDropTarget(wx.FileDropTarget):
    def __init__(self, observer):
        wx.FileDropTarget.__init__(self)
        self.observer = observer

    def OnDropFiles(self, x, y, filenames):
        self.observer.on_drop_files(x, y, filenames)
        return True


class InputFilePanel(wx.Panel):
    def __init__(self, *args, **kwargs):
        wx.Panel.__init__(self, *args, **kwargs)
예제 #6
0
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

import gettext
import os
import sys
import time

import cv2
import numpy as np

from ikalog.inputs.filters import WarpFilter
from ikalog.utils import IkaUtils, Localization

_ = Localization.gettext_translation('screencapture', fallback=True).gettext


class ScreenCapture(object):
    ''' ScreenCapture input plugin
    This plugin depends on python-pillow ( https://pillow.readthedocs.org/ ).
    This plugin now supports only IkaLog.py.
    You can use this plugin if you modify IkaConfig.py
    ```
from ikalog.inputs.screencapture import ScreenCapture

class IkaConfig:
    def config(self):
        source = ScreenCapture()
    ```
    '''
예제 #7
0
파일: IkaLog.py 프로젝트: itoyama/IkaLog
#
#  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.
#

from ikalog.utils import Localization, IkaUtils
Localization.print_language_settings()

import signal
from ikalog.engine import *
from IkaConfig import *
from ikalog.utils import *


engine = IkaEngine()

def signal_handler(num, frame):
    IkaUtils.dprint('IkaLog: got signal %d' % num)
    if num == 2:
        engine.stop()

signal.signal(signal.SIGINT, signal_handler)
예제 #8
0
파일: IkaUI.py 프로젝트: hasegaw/IkaLog
#  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 gettext
import os
import sys
import time
import traceback

import wx

from ikalog.utils import IkaUtils, Localization

Localization.print_language_settings()

# from ikalog.engine import *
from ikalog import outputs
from ikalog.engine import *
from ikalog.ui.panel import *
from ikalog.ui import VideoCapture, IkaLogGUI

_ = Localization.gettext_translation('IkaUI', fallback=True).gettext


def IkaUI_main():
    IkaUtils.dprint(_('Hello!'))

    application = wx.App()
    input_plugin = VideoCapture()
예제 #9
0
#
#  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.
#

from ikalog.utils import Localization, IkaUtils
Localization.print_language_settings()

import argparse
import signal
import sys
import time
from ikalog import inputs
from ikalog.engine import IkaEngine
from ikalog.utils import config_loader



def signal_handler(num, frame):
    IkaUtils.dprint('IkaLog: got signal %d' % num)
    if num == 2:
        engine.stop()
예제 #10
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 copy
import threading

import wx
import cv2

from ikalog.utils import Localization

_ = Localization.gettext_translation('IkaUI', fallback=True).gettext

class PreviewPanel(wx.Panel):

    def SetEventHandlerEnable(self, obj, enable):
        orig_state = obj.GetEvtHandlerEnabled()
        obj.SetEvtHandlerEnabled(enable)
        return orig_state


    def on_amarec16x10_warning(self, context, params):
        self._amarec16x10_warning = params['enabled']

    def on_show_preview(self, context):
        self.lock.acquire()
예제 #11
0
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

import gettext
import os
import sys
import time

import cv2
import numpy as np

from ikalog.inputs.filters import WarpFilter
from ikalog.utils import IkaUtils, Localization

_ = Localization.gettext_translation('screencapture', fallback=True).gettext

class ScreenCapture(object):
    ''' ScreenCapture input plugin
    This plugin depends on python-pillow ( https://pillow.readthedocs.org/ ).
    This plugin now supports only IkaLog.py.
    You can use this plugin if you modify IkaConfig.py
    ```
from ikalog.inputs.screencapture import ScreenCapture

class IkaConfig:
    def config(self):
        source = ScreenCapture()
    ```
    '''
    from_file = False
예제 #12
0
#  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 gettext
import os
import sys
import time
import traceback

import wx

from ikalog.utils import IkaUtils, Localization

Localization.print_language_settings()

# from ikalog.engine import *
from ikalog import outputs
from ikalog.engine import *
from ikalog.ui.panel import *
from ikalog.ui import VideoCapture, IkaLogGUI

_ = Localization.gettext_translation('IkaUI', fallback=True).gettext


def IkaUI_main():
    IkaUtils.dprint(_('Hello!'))

    application = wx.App()
    input_plugin = VideoCapture()