Coder Social home page Coder Social logo

vrchat-io's People

Contributors

geson-anko avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

vrchat-io's Issues

`MultiInput` Controller Wrapperクラス

タスク内容

OSCのInputControllerクラスをラップし、複数のコマンドを送信するラッパークラスを実装します。
一度に送るコマンドには重複を認めません。そのためdictを用います。また、その変数名はactionsとします。(commandsを使うとTypoが発生しやすいため)

スケッチ

controller/wrappers/osc/multi_input_wrapper.py

class MultiInputWrapper(ControllerWrapper):
    def command(self, actions: dict[str, Any]) -> None:
        ...

達成条件

  • ラッパークラスが実装された
  • テストコードが実装された。

v0.1.0リリースに向けたリポジトリの整備

タスク内容

基本的な機能は完成したため、リリースに向けてドキュメントを加筆修正します。

達成条件

  • README.mdを修正
    • Work in progressを削除
    • # Supported platformsにWindowsとLinuxを追記
    • VideoCaptureの説明を実際の実装に関することに修正。またWrapperについて追記
    • InputControllerを実際の挙動に変更。command_and_resetは非推奨のため削除。変わりにRESET_VALUESについてを追記
    • InputControllerWrapperについて追記
    • Future FeaturesのVideo Capture, OSC Input, etc...を削除
  • pyproject.tomlを修正
    • versionを0.1.0
    • descriptionにREADMEの最初の文を書く
  • Contributing.md
    • poetryで管理してるよ
    • 各コンポーネントの作り方
    • 新しい種類の情報のIOは抽象クラスを作ってね

`BackgroundCapture` VideoCapture Wrapper

タスク内容

VideoCaptureread処理をバックグラウンドスレッドで実行するVideoCapture Wrapperクラスを実装します。
これにより、read処理の待ち時間を無視することができます。しかし、このクラスのreadで返される値は必ず遅れた値が返されることに注意してください。

機能

  • ラップ前クラスのreadをバックグラウンドで実行し、返されたフレームを保存しておく
  • 共有と更新がブッキングしないようにlockを実装する
  • is_updatedプロパティで更新を確認できる機能
  • バックグラウンドスレッドでのエラーをキャプチャできる機能

達成条件

  • BackgroundCapture クラスが実装された
  • テストコードが実装された

`Resize` FrameWrapper

タスク内容

VideoCaptureクラスから得られた画像を指定された解像度にリサイズするラッパークラスです。

機能

  • リサイズ後の画像のサイズ(width, height)を指定する
  • cv2.resizeを用いてサイズを変える
  • 変換後の画像を返す

スケッチ

wrappers/resize_wrapper.py

class Resize(FrameWrapper):
    def __init__(self, video_capture, size: tuple[int, int]):
        ...
    def process_frame(self, frame):
        return cv2.resize(frame, self.size)

達成条件

  • Resize Frame Wrapperクラスが実装された
  • テストコードが実装された

VideoCaptureクラスの`cv2.VideoCapture`の隠蔽

タスク内容

現在引数にcv2.VideoCaptureクラスを直接受け取るようになっているが、cameraのdevice index も受け取れるようにする。
内部的にcv2.VideoCaptureをインスタンス化する。

...
    def __init__(
        self,
        camera: cv2.VideoCapture | int,
        ...

達成条件

  • 隠蔽が行われた
  • テストが行われた。

`RatioCrop` FrameWrapper

タスク内容

VideoCaptureクラスから得られた画像を特定のアスペクト比に合うようにクロップするラッパークラスです。

機能

  • 画像の比を指定する
  • 切り取る範囲を指定したAnchor Modeと得られたフレームに基づいて算出する
  • 切り取られた画像を返す

Anchor Modeの種類

  • Center (実装予定)
image
  • TopLeft
image
  • TopRight
image
  • BottomLeft
image
  • BottomRight
image

スケッチ

wrappers/ratio_crop.py

class RatioCrop(FrameWrapper):
    """このクラスはキャプチャされた画像を特定のアスペクト比に合うようにクロップするVideoCaptureのラッパークラスです。"""
    def __init__(self, video_capture, ratio: tuple[int, int], anchor_mode: Literal["center"] = "center" ):
        ...
    def process_frame(self, frame):
        if self.anchor_mode == "center":
           top, bottom, left, right = compute_center_crop_rect(frame, ratio)
        else:
            raise NotImplementedError
        return frame[top: bottom, left: right]

    @property
    def aspect_ratio(self):
        width, height = self.ratio
        return width / height

達成条件

  • RatioCrop ラッパークラスが実装された
    • anchor modeの実装
    • center
    • topleft
    • topright
    • bottomleft
    • bottomright
  • RatioCropのテストコードが実装された
    • center
    • topleft
    • topright
    • bottomleft
    • bottomright

`AxesLocomotion` Controller Wrapper

タスク内容

MultiInputWrapperクラス #15 をラップし、AxesのLocomotion操作(Vertical, Horizontal, LookHorizontal)のみを送信可能にするクラスを実装します。初期値は全てNoneであり、操作する項目だけ送信するような実装にします(冗長か?)
RESET_VALUESは独自に実装し、*RESET_VALUESの展開形式を用いる予定です。

スケッチ

controller/wrappers/osc/axes_locomotion_wrapper.py

RESET_VALUES = [0.0, 0.0, 0.0] # vertical, horizontal, look_horizontal

class AxesLocomotionWrapper(ControllerWrapper):
    def __init__(self, controller: MultiInputWrapper):
        self._controller = MultiInputController

    def command(self, vertical = None, horizontal = None, look_horizontal = None) -> None:
        ...

達成条件

  • ラッパークラスが実装された
  • テストコードが実装された。

OSC Input Controllerのリファクタリング

タスク内容

  1. VRChatに操作命令を送る抽象クラスControllerabc/controller.pyに実装。抽象メソッドはcommand(self, *args, **kwds).
  2. ラッパー用基底クラスControllerWrapperabc/controller.pyに実装。
  3. osc/input_controller.pyを抽象クラスの継承したInputControllerクラスに。
  4. osc/input_controller.py -> controller/osc/input_controller.py: addresses.pyの中身はinput_controller.pyに書く
  5. 定数RESET_VALUES: dictにリセット用のコマンド値を保存。 input_controller.pyの中に書く
  6. InputController.command_and_resetのリセットのデフォ値をNoneにし、特に指定されない場合はRESET_VALUESから値を取得。RESET_VALUESに値が記述されていない場合はKeyError
    冗長かつreset機能は実際にはあまり使わないため、この案は廃止
  7. 変更後のテストコードを実装

スケッチ

abc/controller.py

class Controller(ABC):
   @abstract_method
   def command(self, *args, **kwds) -> Any:
        ...

class ControllerWrapper(Controller):
    def __init__(self, controller, *args, **kwds) -> None:
        self._controller = controller    

controller/osc/input_controller.py

class Axes:
   ...

class Buttons:
   ...

RESET_COMMANDS = {
   Axes.Vertical: 0,
   ...
}

class InputController(Controller):
    ...
   def command(self, address, value) -> None:
       ...

達成条件

  • タスク1
  • タスク2
  • タスク3
  • タスク4
  • タスク5
  • タスク6
  • タスク7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.