vrchat-io's People
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
についてを追記 -
InputController
のWrapper
について追記 - Future Featuresの
Video Capture
,OSC Input
,etc...
を削除
-
- pyproject.tomlを修正
- versionを
0.1.0
に - descriptionにREADMEの最初の文を書く
- versionを
- Contributing.md
- poetryで管理してるよ
- 各コンポーネントの作り方
- 新しい種類の情報のIOは抽象クラスを作ってね
`InputController`クラスで直接アドレスから `SimpleUDPClient`を内部的に呼び出す
タスク内容
いちいちOSC Clientを呼び出さなくても良いようにする。
UDPAddressType: TypeAlias = Sequence[str, int]
def __init__(self, client: SimpleUDPClient | UDPAddressType) -> None:
if not isinstance(client, SimpleUDPClient):
client = SimpleUDPClient(client[0], client[1])
self.client = client
達成条件
- 上記のような機能が実装された
- テスト
`BackgroundCapture` VideoCapture Wrapper
タスク内容
VideoCapture
のread
処理をバックグラウンドスレッドで実行する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 (実装予定)
- TopLeft
- TopRight
- BottomLeft
- BottomRight
スケッチ
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のリファクタリング
タスク内容
- VRChatに操作命令を送る抽象クラス
Controller
をabc/controller.py
に実装。抽象メソッドはcommand(self, *args, **kwds)
. - ラッパー用基底クラス
ControllerWrapper
をabc/controller.py
に実装。 osc/input_controller.py
を抽象クラスの継承したInputController
クラスに。osc/input_controller.py
->controller/osc/input_controller.py
:addresses.py
の中身はinput_controller.py
に書く- 定数
RESET_VALUES: dict
にリセット用のコマンド値を保存。input_controller.py
の中に書く InputController.command_and_reset
のリセットのデフォ値をNone
にし、特に指定されない場合はRESET_VALUES
から値を取得。RESET_VALUES
に値が記述されていない場合はKeyError
冗長かつreset機能は実際にはあまり使わないため、この案は廃止- 変更後のテストコードを実装
スケッチ
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.