-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (31 loc) · 1.21 KB
/
main.py
File metadata and controls
43 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from PlotUtils import plot_image_grid
from ImageGenerator import ImageGenerator
from VirtualCamera import VirtualCamera as VC
from SphereAlgoirthms import fibonacci_sphere
from Canvas import Canvas
from Scene import Scene
import numpy as np
import MeshLoader
import os
import matplotlib.pyplot as plt
def main():
mesh_file = os.path.join('','duck','mesh.ply')
mesh = MeshLoader.MeshFromPlyFile(mesh_file, default_color=(0.5, 0.5, 0.5))
image_size = (640,480)
# Create a virtual camera:
fx, fy = 572.4114, 573.5704 # Focal lengths
cx, cy = 325.2611, 242.0489 # Central point
K = VC.create_camera_matrix(fx, fy, cx, cy)
vc = VC(K, image_size=image_size)
# Randomize lighting confitions:
canvas = Canvas(image_size=image_size, background_color=(0, 0, 0))
canvas.load_mesh_on_canvas(mesh)
ambient_light = np.random.uniform(0.05, 0.40)
ambient_light = 100
directional_light_vector = np.random.uniform(-1, 1, size=3)
scene = Scene(vc,ambient_light,directional_light_vector)
ig = ImageGenerator(scene,canvas,fibonacci_sphere)
rgb_images = ig.generate_image(10)
figure = plot_image_grid([rgb_images], transpose=True)
if __name__ == "__main__":
main()