[PYTHON] I came up with a way to create a 3D model from a photo Part 01 Creating an environment

Domo is Ksuke. I came up with a method to create a 3D model from a photo, and I will create an environment with Part 01. * Caution * </ b> This article only gives the end of what I came up with and tried, so it could end up with abrupt material or Bad End.

What are you doing? </ b>

Take a picture of an object from three sides and make a 3D model from that picture! In detail, you take pictures from the front, sides, and top, and use them to create polygons and textures for your 3D model. In addition, since it is made from 3 photographs, it is assumed that the appearance from other directions is not considered.

Environment </ b> I tried the environment like this. ・ Windows 10 ・ Blender 2.83 ・ Python 3.7

Try

Procedure </ b> 1.blender download 2. Add library to blender python

1.blender download

First, download and install from the URL below. The version is 2.83. https://www.blender.org/download/

2. Add library to blender python

In the installed blender file, open the folder where python.exe is located, referring to the path in the image below, キャプチャ.PNG

On the opened screen, enter "cmd" in the place surrounded by the red frame in the image and press Enter,

Open a screen like this (command prompt). キャプチャ.PNG

Enter the library by hitting the following command at the opened command prompt.

command prompt(Don't copy this ...)


python -m pip install numpy=1.17.0
python -m pip install opencv-python=4.3.0.36
python -m pip install scipy=1.4.1
python -m pip install scikit-learn=0.23.2

キャプチャ.PNG

mistook. .. .. Two equals? .. ..

Even if it is corrected

command prompt(This is ok)


python -m pip install numpy==1.17.0
python -m pip install opencv-python==4.3.0.36
python -m pip install scipy==1.4.1
python -m pip install scikit-learn==0.23.2

キャプチャ.PNG Finished without a hitch. Due to the screen size, only 3 commands are displayed, but it would be nice if "Successfully installed ****" like the red underline appears for each command.

Operation check

Finally, confirmation that the environment has been created successfully.

1. Try to open blender

Click blender.exe to open it. I hope a screen like this appears. キャプチャ.PNG

2. Run python in blender

Press the "Scripting" button surrounded by the red line in the image above to move to the screen where you can execute python. I hope the screen looks like the one below. キャプチャ.PNG

If all goes well, press "new" in the red frame and キャプチャ.PNG

If you paste the "import confirmation source" below in the area of the red frame and press the execute button of the blue frame

import confirmation source


import numpy as np
import cv2
from scipy.spatial import Delaunay
import bpy
import bmesh

print("step01:Creating an environment is success.\n")

・ ・ ・ ・ ・ ・ ・ ・ ・ Nothing changes at first glance.

By the way, it takes some time to see the print of the program in blender. .. .. By doing so, click the blue frame "Toggle System Console" that appears after pressing the red frame "Window" in the image below. キャプチャ.PNG

Then, a window will appear in which the printed version of the program will appear, so if you check the display ... キャプチャ.PNG

The contents of the print of the "import confirmation source" that was executed earlier are shown, and there seems to be no error, so it's okay.

Blender can be opened, and import seems to be no problem, so operation check is complete!

next?

I'm going to try loading an image and displaying vertices in blender.

Recommended Posts