当前位置: 首页>>代码示例>>Python>>正文


Python utils.IkaUtils类代码示例

本文整理汇总了Python中ikalog.utils.IkaUtils的典型用法代码示例。如果您正苦于以下问题:Python IkaUtils类的具体用法?Python IkaUtils怎么用?Python IkaUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IkaUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _http_request_func

    def _http_request_func(self, path, payload):
        url_api = '%s%s' % (self.base_uri, path)
        http_headers = {
            'Content-Type': 'application/x-msgpack',
        }
        mp_payload = ''.join(map(chr, umsgpack.packb(payload)))

        try:
            pool = urllib3.PoolManager(timeout=3.0)
            req = pool.urlopen(
                'POST',
                url_api,
                headers=http_headers,
                body=mp_payload,
            )
            return json.loads(req.data.decode('utf-8'))

        except urllib3.exceptions.MaxRetryError:
            fallback = self._fallback  # or .... or ...

            if fallback:
                IkaUtils.dprint(
                    '%s: Remote API Error. Falling back to local mode' % self)
                return self._local_request_func(path, payload)

        raise Exception(
            'API Error: Failed to connect to API endpoint. (No fallback)')
开发者ID:clovervidia,项目名称:IkaLog,代码行数:27,代码来源:client.py

示例2: test_get_game_offset_msec

 def test_get_game_offset_msec(self):
     mock_context = {'game': {}, 'engine': {}}
     self.assertIsNone(IkaUtils.get_game_offset_msec(mock_context))
     mock_context['engine']['msec'] = 1234567
     self.assertIsNone(IkaUtils.get_game_offset_msec(mock_context))
     mock_context['game']['start_offset_msec'] = 1000000
     self.assertEqual(234567, IkaUtils.get_game_offset_msec(mock_context))
开发者ID:hasegaw,项目名称:IkaLog,代码行数:7,代码来源:test_ikautils.py

示例3: init_for_cvfile

def init_for_cvfile(args, capture):
    if not capture.is_active():
        IkaUtils.dprint('Failed to initialize with: %s' % capture._source_file)
        sys.exit(1)

    pos_msec = args.get('time_msec') or time_to_msec(args.get('time') or '0:0')
    if pos_msec:
        capture.set_pos_msec(pos_msec)
开发者ID:syptn,项目名称:IkaLog,代码行数:8,代码来源:IkaLog.py

示例4: __init__

 def __init__(self, bbox=None):
     '''
     bbox -- bbox Crop bounding box as (x, y, w, h)
     '''
     self._check_import()
     self._bbox = bbox
     self._launch = self._time()
     IkaUtils.dprint('%s: initalizing screen capture' % (self))
开发者ID:apricot385,项目名称:IkaLog,代码行数:8,代码来源:screencapture.py

示例5: evaluate

    def evaluate(self, img_bgr=None, img_gray=None):
        # if not hasattr(self, '_warned_evaluate_is_deprecated'):

        if not self._warned_evaluate_is_deprecated:

            IkaUtils.dprint('%s: evaluate() is depricated.' % self)
            self._warned_evaluate_is_deprecated = True

        return self(img_bgr=img_bgr, img_gray=img_gray)
开发者ID:clovervidia,项目名称:IkaLog,代码行数:9,代码来源:filters.py

示例6: write_answer_file

    def write_answer_file(self, video_file, record):
        answer_fullpath = self.answer_filename(video_file, self.answer_type, None)

        f = open(answer_fullpath, "w")
        f.write(json.dumps(record))
        f.close()

        IkaUtils.dprint("wrote answer file %s" % answer_fullpath)
        return True
开发者ID:Bochozkar,项目名称:IkaLog,代码行数:9,代码来源:ResultDetail.py

示例7: IkaUI_main

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

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

    engine = IkaEngine(keep_alive=True)
    engine.close_session_at_eof = True
    engine.set_capture(input_plugin)

    # 設定画面を持つ各種 Output Plugin
    # -> 設定画面の生成とプラグインリストへの登録
    outputs_with_gui = [
        outputs.CSV(),
        # outputs.Fluentd(),
        outputs.JSON(),
        # outputs.Hue(),
        outputs.OBS(),
        outputs.Twitter(),
        outputs.Screenshot(),
        outputs.Boyomi(),
        outputs.Slack(),
        outputs.StatInk(),
        outputs.DebugVideoWriter(),
        outputs.WebSocketServer(),
    ]
    gui = IkaLogGUI(engine, outputs_with_gui)

    plugins = []

    # とりあえずデバッグ用にコンソールプラグイン
    plugins.append(outputs.Console())

    # 各パネルをプラグインしてイベントを受信する
    plugins.append(gui.preview)
    plugins.append(gui.last_result)

    # 設定画面を持つ input plugin もイベントを受信する
    plugins.append(input_plugin)

    # UI 自体もイベントを受信
    plugins.append(gui)

    plugins.extend(outputs_with_gui)

    # 本当に困ったときのデバッグログ増加モード
    if 'IKALOG_DEBUG' in os.environ:
        plugins.append(outputs.DebugLog())

    # プラグインリストを登録
    engine.set_plugins(plugins)

    gui.run()
    application.MainLoop()

    IkaUtils.dprint(_('Bye!'))
开发者ID:hasegaw,项目名称:IkaLog,代码行数:56,代码来源:IkaUI.py

示例8: read_raw

    def read_raw(self):
        from PIL import ImageGrab

        try:
            img = ImageGrab.grab(None)
        except TypeError:
            # なぜ発生することがあるのか、よくわからない
            IkaUtils.dprint('%s: Failed to grab desktop image' % self)
            return None

        img = np.asarray(img)
        return img
开发者ID:joythegreat,项目名称:IkaLog,代码行数:12,代码来源:screencapture.py

示例9: read_frame

    def read_frame(self):
        try:
            self.lock.acquire()
            if not self.is_active():
                return None

            next_tick = None
            img = self._read_frame_func()

            # Skip some frames for performance.
            try:
                if self.cap_recorded_video:
                    self._skip_frame_recorded()
                else:
                    next_tick = self._skip_frame_realtime()
            except EOFError:
                pass  # EOFError should be captured by the next cycle.

        finally:
            self.lock.release()

        if img is None:
            return None

        if self.cap_optimal_input_resolution:
            res720p = (img.shape[0] == 720) and (img.shape[1] == 1280)
            res1080p = (img.shape[0] == 1080) and (img.shape[1] == 1920)

            if not (res720p or res1080p):
                IkaUtils.dprint(
                    'Invalid input resolution (%dx%d). Acceptable res: 1280x720 or 1920x1080' %
                    (img.shape[1], img.shape[0])
                )
                return None

        if next_tick is not None:
            self.last_tick = next_tick

        # need stratch?
        stratch = (
            img.shape[0] != self.output_geometry[0] or
            img.shape[1] != self.output_geometry[1])

        if stratch:
            img = cv2.resize(
                img,
                (self.output_geometry[1], self.output_geometry[0]),
                # fixme
            )

        img = self._offset_filter.execute(img)
        return img
开发者ID:hasegaw,项目名称:IkaLog,代码行数:52,代码来源:input.py

示例10: test_weapon2text

    def test_weapon2text(self):
        ### Weapons
        weapon = 'bamboo14mk3'

        # English
        self.assertEqual('Bamboozler 14 Mk III',
                         IkaUtils.weapon2text(weapon, languages='en'))

        # Japanese
        self.assertEqual('14式竹筒銃・丙',
                         IkaUtils.weapon2text(weapon, languages='ja'))

        # Fallback to English
        self.assertEqual('Bamboozler 14 Mk III',
                         IkaUtils.weapon2text(weapon, languages='??'))

        # Multiple languages
        self.assertEqual('14式竹筒銃・丙',
                         IkaUtils.weapon2text(weapon, languages=['ja', 'en']))

        ### Invalid weapons
        weapon = 'kyubanbomb'  # Suction Bomb
        self.assertEqual('?', IkaUtils.weapon2text(weapon, languages='en'))
        self.assertEqual('?', IkaUtils.weapon2text(weapon, languages='ja'))

        ### Unkonwn
        unknown_weapon = 'unknown'
        self.assertEqual('?', IkaUtils.weapon2text(unknown_weapon))
        self.assertEqual('<:=',
                         IkaUtils.weapon2text(unknown_weapon, unknown='<:='))
开发者ID:clovervidia,项目名称:IkaLog,代码行数:30,代码来源:test_ikautils.py

示例11: test_lobby2text

    def test_lobby2text(self):
        lobby = 'tag'

        # English
        self.assertEqual('Squad Battle',
                         IkaUtils.lobby2text(lobby, languages='en'))

        # Japanese
        self.assertEqual('タッグマッチ',
                         IkaUtils.lobby2text(lobby, languages='ja'))

        # Fallback to English
        self.assertEqual('Squad Battle',
                         IkaUtils.lobby2text(lobby, languages='??'))

        # Multiple languages
        self.assertEqual('タッグマッチ',
                         IkaUtils.lobby2text(lobby, languages=['ja', 'en']))

        ### Invalid lobby type
        lobby = 'nawabari'  # Turf War
        self.assertEqual('?', IkaUtils.lobby2text(lobby, languages='en'))
        self.assertEqual('?', IkaUtils.lobby2text(lobby, languages='ja'))

        ### Unkonwn
        unknown_lobby = 'unknown'
        self.assertEqual('?', IkaUtils.lobby2text(unknown_lobby))
        self.assertEqual('<:=',
                         IkaUtils.lobby2text(unknown_lobby, unknown='<:='))
开发者ID:clovervidia,项目名称:IkaLog,代码行数:29,代码来源:test_ikautils.py

示例12: test_get_file_name

    def test_get_file_name(self):
        mock_context = {'game': {'index': 0},
                        'engine': {'source_file': None}}

        self.assertIsNone(IkaUtils.get_file_name(None, mock_context))
        self.assertEqual('/tmp/statink.msgpack',
                         IkaUtils.get_file_name('/tmp/statink.msgpack',
                                                mock_context))
        mock_context['game']['index'] = 1
        self.assertEqual('/tmp/statink-1.msgpack',
                         IkaUtils.get_file_name('/tmp/statink.msgpack',
                                                mock_context))
        mock_context['game']['index'] = 10
        self.assertEqual('/tmp/statink-10.msgpack',
                         IkaUtils.get_file_name('/tmp/statink.msgpack',
                                                mock_context))
        mock_context['game']['index'] = 1
        self.assertEqual('/tmp/video.mp4-1.statink',
                         IkaUtils.get_file_name('/tmp/video.mp4.statink',
                                                mock_context))

        self.assertEqual('/tmp/video.mp4-1.statink',
                         IkaUtils.get_file_name('/tmp/video.mp4.statink',
                                                mock_context))

        mock_context['engine']['source_file'] = None
        mock_context['game']['index'] = 0
        self.assertEqual('__INPUT_FILE__.statink',
                         IkaUtils.get_file_name('__INPUT_FILE__.statink',
                                                mock_context))

        mock_context['engine']['source_file'] = None
        mock_context['game']['index'] = 2
        self.assertEqual('__INPUT_FILE__-2.statink',
                         IkaUtils.get_file_name('__INPUT_FILE__.statink',
                                                mock_context))

        mock_context['engine']['source_file'] = '/tmp/video.mp4'
        mock_context['game']['index'] = 0
        self.assertEqual('/tmp/video.mp4.statink',
                         IkaUtils.get_file_name('__INPUT_FILE__.statink',
                                                mock_context))

        mock_context['engine']['source_file'] = '/tmp/video.mp4'
        mock_context['game']['index'] = 3
        self.assertEqual('/tmp/video.mp4-3.statink',
                         IkaUtils.get_file_name('__INPUT_FILE__.statink',
                                                mock_context))
开发者ID:clovervidia,项目名称:IkaLog,代码行数:48,代码来源:test_ikautils.py

示例13: composite_payload

    def composite_payload(self, context):
        payload = {
            # 'id': game_id,
            #'recognition_source': filename,
            'recognition_at': int(time.time()),
            'agent': 'IkaLog re-recognition',
            'agent_version': IKALOG_VERSION,
            'players': [],
        }

        me = IkaUtils.getMyEntryFromContext(context)

        for e in context['game']['players']:
            player = {}
            player['team'] = 'my' if (e['team'] == me['team']) else 'his'
            player['is_me'] = 'yes' if e['me'] else 'no'
            player['weapon'] = e['weapon']
            payload['players'].append(player)

            _set_values(
                [  # 'type', 'stat.ink Field', 'IkaLog Field'
                    ['int', 'rank_in_team', 'rank_in_team'],
                    ['int', 'kill', 'kills'],
                    ['int', 'death', 'deaths'],
                    ['int', 'level', 'rank'],
                    ['int', 'point', 'score'],
                    ['str_lower', 'rank', 'udemae_pre'],
                ], player, e)

        return payload
开发者ID:clovervidia,项目名称:IkaLog,代码行数:30,代码来源:reprocess_screenshots.py

示例14: test_copy_context

    def test_copy_context(self):
        mock_context = {
            'engine': {
                'engine': self,
                'source_file': 'video.mp4',
                'service': {'call_plugins_later': self.test_copy_context},
            },
            'game': {
                'map': 'kinmedai',
                'rule': 'area',
            }}

        copied_context = IkaUtils.copy_context(mock_context)
        copied_context['engine']['source_file'] = 'movie.ts'
        copied_context['game']['map'] = 'hokke'
        copied_context['game']['rule'] = 'nawabari'
        self.assertEqual('video.mp4', mock_context['engine']['source_file'])
        self.assertEqual('movie.ts', copied_context['engine']['source_file'])

        self.assertIsNotNone(mock_context['engine']['engine'])
        self.assertIsNotNone(
            mock_context['engine']['service'].get('call_plugins_later'))
        self.assertEqual('kinmedai', mock_context['game']['map'])
        self.assertEqual('area', mock_context['game']['rule'])

        self.assertIsNone(copied_context['engine']['engine'])
        self.assertIsNone(
            copied_context['engine']['service'].get('call_plugins_later'))
        self.assertEqual('hokke', copied_context['game']['map'])
        self.assertEqual('nawabari', copied_context['game']['rule'])
开发者ID:clovervidia,项目名称:IkaLog,代码行数:30,代码来源:test_ikautils.py

示例15: test_getMyEntryFromContext

    def test_getMyEntryFromContext(self):
        context = {'game': {}}
        self.assertIsNone(IkaUtils.getMyEntryFromContext(context))

        context['game']['players'] = [
            {'me': False, 'team': 1, 'rank_in_team': 1},
            {'me': False, 'team': 1, 'rank_in_team': 2},
            {'me': False, 'team': 2, 'rank_in_team': 1},
            {'me': False, 'team': 2, 'rank_in_team': 2},
        ]
        self.assertIsNone(IkaUtils.getMyEntryFromContext(context))

        context['game']['players'][2]['me'] = True
        me = IkaUtils.getMyEntryFromContext(context)
        self.assertEqual(2, me['team'])
        self.assertEqual(1, me['rank_in_team'])
开发者ID:clovervidia,项目名称:IkaLog,代码行数:16,代码来源:test_ikautils.py


注:本文中的ikalog.utils.IkaUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。