Creating 3D videos from 2D videos using MiDaS and SPM

LKGPトップページに戻る

Midas is a machine learning model that estimates depth from an input image. It can estimate depth values (depth) from arbitrary images.


They are training on the following multiple data sets. As such, it seems to be able to estimate the depth of images other than people.


Basically, MiDaS only creates a depth map from a 2D image, but by combining it with Stereo Photo Maker (SPM), you can also create a 3D movie from a 2D movie.
This section explains how to do that.


1. Build the MiDaS execution environment.
Since it is difficult to run MiDaS on a local PC, I recommend using "Google Colab", a virtual web laptop provided by Google for free.
For more information on how to use Google Colab, please refer to [Creating depth maps from 2D images using Google Colab]
If you have any questions, please search for "How to use Google Colab".
Create a folder named "MiDaS" in your Google Drive, and store the files downloaded from the following site.
Midas
model-f6b98070.pt
model-small-70d6b9c8.pt


2. Create an "input" folder and an "output" folder in the "MiDaS" folder in Google Drive, and store the 2D still image you want to convert in the "input" folder.
If you want to convert 2D video, use SPM to convert the video to sequential numbered still images in advance, and store the sequential numbered still images in the "input" folder.
For more information on how to convert video to sequential images using SPM, please refer to here.
Editing/displaying 3D video in Stereo Photo Maker (SPM)

3. create a new notebook for MiDaS in "Google Colab", and in Edit -> Notebook Settings, set Hardware Acceleration to "GPU".
Mount Google Drive (if you don't know how to mount it, please search for it)
Enter the following command and run it

%cd /content/drive/My Drive/MiDaS
!python run.py

When the process is finished, a depth map image in PNG format with the same file name as the input image will be created in the "output" folder and downloaded to your PC.

4. Use SPM to create a 3D image from a 2D image and a depth map by batch conversion. Please see the following Youtube video for instructions.
Batch conversion of 3D images from 2D and depth map images by SPM
Since the batch conversion is done using the parameters of the previous 2D3D conversion, first convert one set of 2D+Depth to 3D, check the result, and if there is no problem, check [3D Conv.] in the multi conversion dialogue and execute.

5. For how to create a 3D movie from the sequentially numbered 3D still images created above using SPM, please refer to the following page.
Editing/displaying 3D video in Stereo Photo Maker (SPM)