-
Notifications
You must be signed in to change notification settings - Fork 1
/
construct_images.py
142 lines (120 loc) · 5.36 KB
/
construct_images.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import pymongo as pm
import sqlite3
import os
from utils import createCertificate
import boto
import tabular
from boto.s3.key import Key
def get_modeldb(creates='../ModelBankLibrary.db'):
conn = boto.connect_s3()
bucket = conn.get_bucket('dicarlocox-3dmodels-v1')
k = Key(bucket)
k.key = 'ModelBankLibrary.db'
k.get_contents_to_filename(creates)
def create_mongodb(depends_on = '../ModelBankLibrary.db', creates = '../certificate.txt'):
conn = sqlite3.connect('../ModelBankLibrary.db')
c = conn.cursor()
c.execute('select * from products;')
conn = pm.Connection()
db = conn['dicarlocox_3dmodels']
db.drop_collection('3ds_test_images')
coll = db['3ds_test_images']
for rec in c:
kw = rec[11].split()
kw = [x for x in kw if x]
filename = rec[1] + '_3ds.bmp'
pmrec = {'id':rec[1], 'name':rec[2], 'keywords':kw, 'type':'modelbank','filepath':filename}
coll.insert(pmrec)
X = tb.tabarray(SVfile = '../model_manifests/faces.csv')
for x in X:
rec = {'id':x['ID'],'name':x['ID'],'keywords':['face'],'type':'facegen'}
coll.insert(rec)
X = tb.tabarray(SVfile = '../model_manifests/dosch_antique_furniture.csv')
for x in X:
rec = {'id':x['ID'],'name':x['ID'],'keywords':['furniture','antique'],'type':'dosch'}
coll.insert(rec)
X = tb.tabarray(SVfile = '../model_manifests/dosch_cats.csv')
for x in X:
rec = {'id':x['ID'],'name':x['ID'],'keywords':['feline','cat','animal'],'type':'dosch'}
coll.insert(rec)
X = tb.tabarray(SVfile = '../model_manifests/dosch_clothing_items.csv')
for x in X:
rec = {'id':x['ID'],'name':x['ID'],'keywords':['household','clothing accessory'],'type':'dosch'}
coll.insert(rec)
X = tb.tabarray(SVfile = '../model_manifests/dosch_dogs.csv')
for x in X:
rec = {'id':x['ID'],'name':x['ID'],'keywords':['canine','dog','animal'],'type':'dosch'}
coll.insert(rec)
X = tb.tabarray(SVfile = '../model_manifests/dosch_mammals.csv')
for x in X:
rec = {'id':x['ID'],'name':x['ID'],'keywords':['mammal','animal'],'type':'dosch'}
coll.insert(rec)
X = tb.tabarray(SVfile = '../model_manifests/dosch_mens_clothing.csv')
for x in X:
rec = {'id':x['ID'],'name':x['ID'],'keywords':['mens clothing','clothing'],'type':'dosch'}
coll.insert(rec)
X = tb.tabarray(SVfile = '../model_manifests/dosch_reptiles.csv')
for x in X:
rec = {'id':x['ID'],'name':x['ID'],'keywords':['reptile','animal'],'type':'dosch'}
coll.insert(rec)
X = tb.tabarray(SVfile = '../model_manifests/dosch_ships.csv')
for x in X:
rec = {'id':x['ID'],'name':x['ID'],'keywords':['ship','transportation','boat'],'type':'dosch'}
coll.insert(rec)
X = tb.tabarray(SVfile = '../model_manifests/dosch_womens_clothing.csv')
for x in X:
rec = {'id':x['ID'],'name':x['ID'],'keywords':['womens clothing','clothing'],'type':'dosch'}
coll.insert(rec)
KD = {'flowers':['flowers','plants'],
'electronics':['electronics'],
'buildings':['buildings'],
'household_aids':['household aids','kitchen equipment','appliances'],
'home_appliances':['home appliances'],
'jewelry':['jewelry'],
'job_poses':['human','people','person','body'],
'music_instruments':['music','instrument','musical instrument'],
'tools':['tools','hardware','construction tools'],
'trees':['trees','plants']}
for k in KD:
X = tb.tabarray(SVfile = '../model_manifests/' + k + '.csv')
for x in X:
rec = {'id':x['ID'],'name':x['ID'],'keywords':KD[k],'type':'dosch','filepath':x['ID'] + '.png'}
coll.insert(rec)
createCertificate(creates,'made it')
from canonical_angles import ANGLES
def add_canonical_angles():
conn = pm.Connection()
db = conn['dicarlocox_3dmodels']
coll = db['3ds_test_images']
for (x,a,b,c) in ANGLES:
coll.update({'id':x},{'$set':{'canonical_view':{'rxy':a,'rxz':b,'ryz':c}}})
import tabular as tb
def make_background_db( creates = '../background_certificate.txt',depends_on=('../3d_hdr_backgrounds.csv','../2d_grayscale_backgrounds.csv')):
conn = pm.Connection()
db = conn['dicarlocox_3dmodels']
db.drop_collection('3d_spherical_backgrounds')
coll = db['3d_spherical_backgrounds']
recs = [{'name': 'backlot', 'path':'backlot.tdl'},
{'name': 'apartment', 'path':'apartment.tdl'},
{'name': 'empty room', 'path':'empty_room.tdl'},
{'name': 'office', 'path':'office.tdl'}
]
for rec in recs:
coll.insert(rec)
X = tb.tabarray(SVfile = depends_on[0])
recs = [{'name':x['Path'][:-4],'path':x['Path'],'description':x['Description'],'type':'3d hdr'} for x in X]
for rec in recs:
coll.insert(rec)
X = tb.tabarray(SVfile = depends_on[1])
recs = [{'name':x['Path'][:-4],'path':x['Path'],'type':'2d grayscale'} for x in X]
for rec in recs:
coll.insert(rec)
rec = {'name':'blank gray image','path':'gray.td','type':'blank'}
coll.insert(rec)
if __name__ == '__main__':
if not os.path.exists('Temp'):
os.mkdir('Temp')
os.chdir('Temp')
get_modeldb()
create_mongodb()
#make_background_db()