LoginSignup
0
3

More than 1 year has passed since last update.

OBS Studioの仮想カメラがOpenCVで取得できない場合の対処法

Last updated at Posted at 2021-08-12

環境

  • Windows 10
  • Python 3.8.7
  • OpenCV on Wheels 4.5.1.48
  • OBS Studio 27.0.1
  • OBS Virtualcam 2.0.5

問題

OBS Studio組み込みの仮想カメラをOpenCVで取得しようとすると、黒い画面が表示されてしまいます。

import cv2

capture = cv2.VideoCapture(0)  # 数字は環境によって異なります

while True:
    ret, frame = capture.read()
    cv2.imshow("capture", frame)
    if cv2.waitKey(1) & 0xFF == ord("q"):  # qで終了
        break

capture.release()
cv2.destroyAllWindows()

image.png

対処法

OpenCVはNV12フォーマットをサポートしていないようなので、OBS Studio組み込みの仮想カメラは使用せず、以下のOBS Virtualcamプラグインを導入するとうまくいきます。ソースコードの変更は不要です。

image.png

参考

0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3