Skip to content

en_Installation_CLI

Takeshi HASEGAWA edited this page Jan 12, 2016 · 9 revisions

IkaLog CLI installation

NOTE: Before this procedure, install Python3 in your environment. See en_Home for applicable procedures.

Clone the IkaLog repository from GitHub

dhcp44-82:work hasegaw$ git clone [email protected]:hasegaw/IkaLog.git
# If you prefer HTTPS rather than SSH, "git clone https://github.com/hasegaw/IkaLog.git"

Cloning into 'IkaLog'...
remote: Counting objects: 2494, done.
remote: Compressing objects: 100% (101/101), done.
remote: Total 2494 (delta 54), reused 0 (delta 0), pack-reused 2393
Receiving objects: 100% (2494/2494), 3.08 MiB | 1.46 MiB/s, done.
Resolving deltas: 100% (1686/1686), done.
Checking connectivity... done.

dhcp44-82:work hasegaw$ cd IkaLog

dhcp44-82:IkaLog hasegaw$ ls -l
total 96
-rw-r--r--   1 hasegaw  staff   2948 Oct 22 14:27 INSTALL
-rw-r--r--   1 hasegaw  staff   4183 Oct 22 14:27 IkaConfig.py.sample
-rw-r--r--   1 hasegaw  staff   1117 Oct 22 14:27 IkaLog.py
-rw-r--r--   1 hasegaw  staff   8913 Oct 22 14:27 IkaUI.py
-rw-r--r--   1 hasegaw  staff  10174 Oct 22 14:27 LICENSE
-rw-r--r--   1 hasegaw  staff    424 Oct 22 14:27 README.md
drwxr-xr-x   8 hasegaw  staff    272 Oct 22 14:27 data
drwxr-xr-x   3 hasegaw  staff    102 Oct 22 14:27 debug_videos
drwxr-xr-x   7 hasegaw  staff    238 Oct 22 14:27 doc
drwxr-xr-x  11 hasegaw  staff    374 Oct 22 14:27 ikalog
drwxr-xr-x   4 hasegaw  staff    136 Oct 22 14:27 lib
drwxr-xr-x  33 hasegaw  staff   1122 Oct 22 14:27 masks
drwxr-xr-x   3 hasegaw  staff    102 Oct 22 14:27 screenshots
-rw-r--r--   1 hasegaw  staff   1893 Oct 22 14:27 setup.py
drwxr-xr-x   8 hasegaw  staff    272 Oct 22 14:27 test
drwxr-xr-x  10 hasegaw  staff    340 Oct 22 14:27 tools

Make a config file

dhcp44-82:IkaLog hasegaw$ cp IkaConfig.py.sample IkaConfig.py
dhcp44-82:IkaLog hasegaw$ vim IkaConfig.py

Sample of IkaConfig.py for Developers

import sys

import ikalog.inputs as inputs
import ikalog.outputs as outputs
from ikalog.utils import IkaUtils

class IkaConfig:

    def config(self):
        if len(sys.argv) > 1: # Video player mode if IkaLog.py had arguments
            print('input from sys.args')
            source = inputs.CVFile()
            source.start_video_file(sys.argv[1])
        else:
            if IkaUtils.isWindows():
                source = inputs.CVCapture()
                source.start_camera(1)                        # Index of camera device
            else:
                source = inputs.AVFoundationCapture()
                source.start_camera(0)                        # Index of camera device

        source.need_resize = True

        OutputPlugins = [
            outputs.Screen(wait_ms=1, size=(640, 360)),
            outputs.Console(),
            outputs.DebugLog(dir='./debug/', screenshot=False),
            source,
        ]

        print(OutputPlugins)

        return [source, OutputPlugins]

if __name__ == "__main__":
    obj = IkaConfig()
    print(obj.config())

Process a sample video in dropbox

If you have IkaConfig.py above, you can process a movie from Dropbox:

dhcp44-82:IkaLog_github hasegaw$ python3 IkaLog.py https://dl.dropboxusercontent.com/u/14421778/IkaLog/ikalog_sample.mp4

Output Example

input from sys.args
<ikalog.inputs.cvcapture.CVCapture object at 0x105b7d358>: initalizing pre-recorded video file https://dl.dropboxusercontent.com/u/14421778/IkaLog/ikalog_sample.mp4
[<ikalog.outputs.preview.Screen object at 0x105b7d3c8>, <ikalog.outputs.console.Console object at 0x105b7d5f8>, <ikalog.outputs.json.JSON object at 0x109ae34e0>, <ikalog.outputs.debug.DebugLog object at 0x109b66d68>, <ikalog.inputs.cvcapture.CVCapture object at 0x105b7d358>]
start model.train 972
done model.train
Loaded weapons recoginization model.
[event] 00:00 on_lobby_matched  Lobby_type: tag, team_members: 2
ゲームスタート。マップ アロワナモール ルール ガチホコバトル
[event] 00:10 on_game_start
<ikalog.scenes.game.game_start.GameStart object at 0x10d6612e8>: switching to state _state_default
プレイヤーをたおした!
[event] 00:44 on_game_killed
[event] 00:53 on_game_finish
[event] 01:00 on_result_judge  judge: win, knockout: None
ゲーム終了。 ステージ:アロワナモール ルール:ガチホコバトル 勝ち 1K/0D 使用ブキ:デュアルスイーパーカスタム チーム内順位: 2 プレイ前ウデマエ B
[event] 01:07 on_game_individual_result
[event] 01:16 on_result_udemae  {'udemae_str_after': 'b', 'udemae_exp_after': 36, 'udemae_exp': 24, 'udemae_str': 'b'}
  img_cash: (image)
  exp: 4472576
  level: 43
  cash: 1820744
  img_exp: (image)
  img_level: (image)
  gear 0 : img_name
  gear 0 : img_main
  gear 0 : img_sub3
  gear 0 : img_sub1
  gear 0 : img_sub2
  gear 1 : img_name
  gear 1 : img_main
  gear 1 : img_sub3
  gear 1 : img_sub1
  gear 1 : img_sub2
  gear 2 : img_name
  gear 2 : img_main
  gear 2 : img_sub3
  gear 2 : img_sub1
  gear 2 : img_sub2
[event] 01:23 on_result_gears
[event] 01:27 on_lobby_matching  Lobby_type: tag
Watchdog fired. Closing current session
ゲームセッション終了
[event] 01:27 on_game_session_end  death_reasons = {}
Traceback (most recent call last):
  File "IkaLog.py", line 41, in <module>
    engine.run()
  File "/Users/hasegaw/work/IkaLog_github8/ikalog/engine.py", line 222, in run
    self.process_frame()
  File "/Users/hasegaw/work/IkaLog_github8/ikalog/engine.py", line 174, in process_frame
    frame, t = self.read_next_frame(skip_frames=skip_frames)
  File "/Users/hasegaw/work/IkaLog_github8/ikalog/engine.py", line 82, in read_next_frame
    frame, t = self.capture.read()
  File "/Users/hasegaw/work/IkaLog_github8/ikalog/inputs/cvfile.py", line 59, in read
    raise EOFError
EOFError

EOFError is expected at the end of file.

If you can't play the movie, you may have issues in your OpenCV 3.x installation (e.g. missed --with-ffmpeg)