VRChat IO is a library for inputting data into and getting data from VRChat. (For AI, Machine Learnings.)
VRChat IOは、VRChatにデータを入力したり、VRChatから取得したりするためのライブラリです。
- Windows 10, 11
- Linux (Ubuntu, Debian, Arch Linux, etc...)
pip install "git+https://github.com/Geson-anko/vrchat-io.git@main"
or clone this repository and run following command in the directory. (Installing from source.)
# ./vrchat-io
pip install -e .
-
Steamからインストール
-
VRChatを起動する
Note: Steamの起動オプションに
-screen-width <pixel> -screen-height <pixel>
を設定すると常に同じサイズで出力されるので便利です。 起動オプション参考: https://docs.vrchat.com/docs/launch-options -
OSCを有効化する: https://docs.vrchat.com/docs/osc-overview
Note: 起動オプションで
inPort:outIP:outPort
を設定できます。
VRChatの映像をキャプチャし、Pythonから取得するためにOBSの仮想カメラを用います。
-
Download and Install OBS: https://obsproject.com
-
仮想カメラをインストール
-
Windows:
- obs-virtualcamをインストール: https://github.com/Avasam/obs-virtual-cam/releases
ツール -> VirtualCam
から仮想カメラを開始。
-
Linux (仮想カメラが無い場合):
v4l2loopback
をインストール: https://linuxgamecast.com/2021/07/obs-linux-basics-virtual-webcam/- OBSを再起動して 仮想カメラを開始
-
-
VRChatのウィンドウをキャプチャする。
cam = VideoCapture(...)
frame = cam.read()
-
OpenCVVideoCapture
cv2.VideoCapture
の簡易ラッパーです。read
メソッドを用いて画像を読み出します。 取得する画像のwidth
,height
は指定できますが、などはあくまでも期待される値であり、実際に得られる画像とは異なる場合があることに注意してください。
画像を任意のアスペクト比、解像度で必ず取得したい場合はvrchat_io.vrchat_io.vision.wrappers
内部のRatioCropWrapperやResizeWrapperを用いてください。
-
OSC Input Controller
python-osc
のSimpleUDPClient
のラッパークラスです。OSCで送信し操作できる項目に関してはvrchat-io.controller.osc
のAxes
やButtons
の属性として列挙されているのでそれを用いてください。InputControllerに関するDemoファイルはこちらです。
このInputControllerにも
Wrapper
クラスが用意されており、インターフェイスをラップすることで目的に応じて使いやすくすることができます。DEMOファイルはこちらです。
cap = AudioCapture(...)
frames = cap.read() # (frame_size, channels)
-
SoundcardAudioCapture
soundcard
のラッパークラスです。read
メソッドで指定されたサイズのframe数を読み取って返します。
(Implement below things in the future.)
- Audio Capture: 統一されたAPIを定義し、VRChatの音声をキャプチャします。
- OSC Output
機能追加やバグ修正は大歓迎です!詳しくはCONTRIBUTING.mdを参照願います