Esempio n. 1
0
    def initialize_input(self):

        print('----------------')
        print(self.source, self.source_device)
        if self.source == 'dshow_capture':
            self.capture = inputs.DirectShow()
            self.capture.start_camera(self.source_device)

        elif self.source == 'opencv_capture':
            if IkaUtils.isWindows():
                self.capture = inputs.CVCapture()
                self.capture.start_camera(self.source_device)
            else:  # FIXME
                self.capture = inputs.AVFoundationCapture()

        elif self.source == 'screen':
            self.capture = inputs.ScreenCapture()
            self.capture.calibrate()

        elif self.source == 'amarec':
            self.capture = inputs.CVCapture()
            self.capture.start_camera(self.DEV_AMAREC)

        elif self.source == 'file':
            self.capture = inputs.CVFile()
            self.start_recorded_file(self.File)

        # ToDo reset context['engine']['msec']
        success = True

        print(self.capture)
        return success
Esempio n. 2
0
    def initialize_input(self):

        print('----------------')
        print(self.source, self.source_device)
        if self.source == 'dshow_capture':
            self.capture = inputs.DirectShow()
            self.capture.select_source(name=self.source_device)

        elif self.source == 'opencv_capture':
            self.capture = inputs.CVCapture()
            self.capture.select_source(name=self.source_device)

        elif self.source == 'screen':
            self.capture = inputs.ScreenCapture()
            img = self.capture.capture_screen()
            if img is not None:
                self.capture.auto_calibrate(img)

        elif self.source == 'amarec':
            self.capture = inputs.DirectShow()
            self.capture.select_source(name=self.DEV_AMAREC)

        elif self.source == 'file':
            self.capture = inputs.CVFile()
            self.capture.select_source(name=self.File)

        # ToDo reset context['engine']['msec']
        success = (self.capture is not None)
        if success:
            self.capture.set_frame_rate(10)

        return success
Esempio n. 3
0
    def initialize_input(self):

        print('----------------')
        print(self.source, self.source_device)

        if self.capture:
            # Send a signal to exit the waiting loop.
            self.capture.put_source_file(None)

        if self.source == 'dshow_capture':
            self.capture = inputs.DirectShow()
            self.capture.select_source(name=self.source_device)

        elif self.source == 'opencv_capture':
            self.capture = inputs.CVCapture()
            self.capture.select_source(name=self.source_device)

        elif self.source == 'screen':
            self.capture = inputs.ScreenCapture()
            img = self.capture.capture_screen()
            if img is not None:
                self.capture.auto_calibrate(img)

        elif self.source == 'amarec':
            self.capture = inputs.DirectShow()
            self.capture.select_source(name=self.DEV_AMAREC)

        elif self.source == 'file':
            self.capture = inputs.CVFile()

        # ToDo reset context['engine']['msec']
        success = (self.capture is not None)
        if success:
            self.capture.set_frame_rate(10)
            evt = InputInitializedEvent(source=self.source)
            wx.PostEvent(self.panel, evt)

        return success
Esempio n. 4
0
    def initialize_input(self):
        if self.source == 'camera':
            if 0: #IkaUtils.isOSX():
                self.capture = inputs.AVFoundationCapture()
            else:
                self.capture = inputs.CVCapture()
                self.capture.start_camera(self.source_device)

        elif self.source == 'screen':
            self.capture = inputs.ScreenCapture()
            self.capture.calibrate()

        elif self.source == 'amarec':
            self.capture = inputs.CVCapture()
            self.capture.start_camera(self.DEV_AMAREC)

        elif self.source == 'file':
            self.capture = inputs.CVFile()
            self.start_recorded_file(self.File)

        # ToDo reset context['engine']['msec']
        success = True

        return success
Esempio n. 5
0
def _init_source(opts):
    # 使いたい入力を設定
    source = None

    # Set the input type
    input_type = (opts.get('input') or IkaConfig.INPUT_SOURCE)
    if opts.get('input_file'):
        input_type = 'CVFile'
    if not input_type:
        input_type = 'GStreamer'

    # Set the input arguments
    input_args = (IkaConfig.INPUT_ARGS.get(input_type) or {})

    # パターン1: Windows 上でキャプチャデバイスを利用(DirectShow)
    if input_type == 'DirectShow':
        source = inputs.DirectShow()
        source.select_source(input_args.get('device'))
        return source

    # パターン2: OpenCV VideoCapture 経由でキャプチャデバイスを利用
    if input_type == 'CVCapture':
        source = inputs.CVCapture()
        source.select_source(input_args.get('device'))
        return source

    # パターン3: Windows 上でスクリーンキャプチャを利用
    # 起動時は全画面を取り込み。 C キー押下で画面内にある WiiU 画面を検出
    if input_type == 'ScreenCapture':
        source = inputs.ScreenCapture()
        return source

    # パターン4: Mac 上で AVFoundation を介してキャプチャデバイスを利用
    # 現在 UltraStudio Mini Recorder のみ動作確認
    if input_type == 'AVFoundationCapture':
        source = inputs.AVFoundationCapture()
        source.select_source(input_args.get('source'))
        return source

    # パターン5: OpenCV のビデオファイル読み込み機能を利用する
    # OpenCV が FFMPEG に対応していること
    # 直接ファイルを指定するか、コマンドラインから --input_file で指定可能
    if input_type == 'CVFile':
        source = inputs.CVFile()
        source.select_source(
            name=(opts.get('input_file') or input_args.get('source')))
        source.set_frame_rate(input_args.get('frame_rate'))
        return source

    # パターン6: OpenCV の GStreamerパイプラインからの読み込み機能を利用する
    # ・OpenCV が GStreamer に対応していること
    # ・パイプラインは '$YOUR_STREAM_SOURCE ! videoconvert ! appsink'
    #
    # 例) Blackmagic Design社のキャプチャデバイスのHDMIポートから720p 59.94fpsで取得する場合
    # source = inputs.GStreamer()
    # source.select_source(name='decklinksrc connection=hdmi mode=720p5994 device-number=0 ! videoconvert ! appsink')
    #
    # 例) テストパターンを表示
    if input_type == 'GStreamer':
        source = inputs.GStreamer()
        source.select_source(name=input_args.get('source'))
        return source

    return source