-
Notifications
You must be signed in to change notification settings - Fork 1
/
model_3d_manager.py
83 lines (62 loc) · 2.33 KB
/
model_3d_manager.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import cv2 as cv
import numpy as np
import random
import visual_debug
import config
# ---------------------------------------------------------------------------
# Sampling input edges, edges represented by end points in 3D space
def read_3d_model():
ctrl_edges = []
ctrl_edges = artificial_pts(ctrl_edges)
# visual_debug.visualize_3d_lines(ctrl_edges)
return ctrl_edges
# ---------------------------------------------------------------------------
def artificial_pts(m_arr):
m_arr.append([0, 0, 0, 3, 0, 0])
m_arr.append([3, 0, 0, 3, 3, 0])
m_arr.append([3, 3, 0, 0, 3, 0])
m_arr.append([0, 3, 0, 0, 0, 0])
m_arr.append([0, 0, 3, 3, 0, 3])
m_arr.append([3, 0, 3, 3, 3, 3])
m_arr.append([3, 3, 3, 0, 3, 3])
m_arr.append([0, 3, 3, 0, 0, 3])
m_arr.append([0, 0, 0, 0, 0, 3])
m_arr.append([3, 0, 0, 3, 0, 3])
m_arr.append([0, 3, 0, 0, 3, 3])
m_arr.append([3, 3, 0, 3, 3, 3])
return m_arr
def artificial_k_mat():
k_mat = [[config.K_FX, 0, config.K_CX, 0],
[0, config.K_FY, config.K_CY, 0],
[0, 0, 1, 0]]
k_mat = np.asarray(k_mat)
return k_mat
def rand_rot_trans():
rotations = [random.randrange(config.RAND_ROT_LIMIT),
random.randrange(config.RAND_ROT_LIMIT),
random.randrange(config.RAND_ROT_LIMIT)]
translations = [random.randrange(config.RAND_TRANS_LIMIT),
random.randrange(config.RAND_TRANS_LIMIT),
random.randrange(config.RAND_TRANS_LIMIT)]
return rotations, translations
def model_edges():
ctrl_edges = []
ctrl_edges.append([1, -2, 3, 1, -2, -3])
ctrl_edges.append([1, -2, -3, 1, 2, -3])
ctrl_edges.append([1, 2, -3, 1, 2, 3])
ctrl_edges.append([1, -2, 3, 1, 2, 3])
ctrl_edges.append([-1, -2, 3, -1, -2, -3])
# ctrl_edges.append([-1, -2, -3, -1, 2, -3])
# ctrl_edges.append([-1, 2, -3, -1, 2, 3])
ctrl_edges.append([-1, 2, 3, -1, -2, 3])
ctrl_edges.append([1, -2, 3, -1, -2, 3])
ctrl_edges.append([1, -2, -3, -1, -2, -3])
# ctrl_edges.append([1, 2, -3, -1, 2, -3])
# ctrl_edges.append([1, 2, 3, -1, 2, 3])
return ctrl_edges
def camera_mat_gen():
k_mat = [[config.K_FX, 0, config.K_CX, 0],
[0, config.K_FY, config.K_CY, 0],
[0, 0, 1, 0]]
k_mat = np.asarray(k_mat)
return k_mat