0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OpenCV for Unityを使ってバーチャル動画背景メーカーを作った話

Last updated at Posted at 2020-08-31

記事の概要

OpenCV for Unityという95ドルのアセットを用いて、ZOOMなどのバーチャル動画背景を作成するデスクトップアプリを作りました。
http://virtual-background-movie-maker.tilda.ws/
こちらのサイトにアプリの説明やダウンロードするリンク先を載せています。

作った背景

ZOOMなどのビデオ通話に使う、バーチャル「画像」背景作成アプリはあるのですが、バーチャル「動画」背景作成アプリはまだありませんでした。
そこでバーチャル動画背景メーカーを作ることになったのです。

使用した技術

OpenCV for Unity

https://assetstore.unity.com/packages/tools/integration/opencv-for-unity-21088
OpenCV for Unityにある「VideoWriter」というSceneに、録画して動画を作成する機能があったので、これをそのまま使用しました。
注意しなければならない点は、保存する動画のコーデックです。OpenCV for UnityのReadme.pdfに書かれている動画のコーデック形式を拡張する設定をします。
VideoWriter.csの以下の関数の部分を書き換え、保存する形式を「.mp4」に変える必要があります。

VideoWriter.cs
writer.open(savePath, VideoWriter.fourcc('H', '2', '6', '4'), 30, new Size(Screen.width, Screen.height));

こうすることで保存した動画をそのままZOOMのバーチャル動画背景として読み込ませることができます。

StandaloneFileBrowser

https://github.com/gkngkc/UnityStandaloneFileBrowser#readme
この機能を使うことで、ユーザーが持っている画像や動画のファイルを動的に読み込ませることができます。

AfterEffectのアニメーションフォント

アルファベットで名前を表示する部分に使用しました。

CharTweener

https://github.com/mdechatech/CharTweener
TextMeshProの文字を1文字ずつずらして動かすために使いました。

HSV Color Picker

https://github.com/judah4/HSV-Color-Picker-Unity
文字の色を選択するカラーピッカーのアセットです。

感想

OpenCV for Unityを使うことで、動画作成デスクトップアプリを作ることができました。
OpenCV for Unityは95ドルの有料アセットなのですが、これを使わないでUnityのデスクトップアプリ内で動画を作成する方法を見つけることはできませんでした。
今回はZOOM向けのバーチャル動画背景作成アプリとしましたが、他にも応用できると思います。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?