示例#1
0
parser = OptionParser()
parser.add_option("--models-dir", type="string", dest="models_dir")
parser.add_option("--train-data-dir", type="string", dest="train_data_dir")
parser.add_option("--classifier-file", type="string", dest="classifier_file")
parser.add_option("--fern-depth", type="int", dest="fern_depth", default=14)
parser.add_option("--num-ferns", type="int", dest="num_ferns", default=50)

options, args = parser.parse_args()

if options.models_dir == None or  options.train_data_dir == None or options.classifier_file == None:
		print 'Please specify models and training data directories and classifier file'
		sys.exit(-1)


models = d.get_model_names(options.models_dir)

models = [ name + ':' + o for name in models for o in d.orientations]
models.append('not_an_object')

classifier = fern.fern_classifier.from_parameters(fern_depth=options.fern_depth, num_ferns=options.num_ferns, class_labels=models)

num_scenes = json.load(open(options.train_data_dir+'dataset.json'))['num_scenes']


for i in range(num_scenes):
	print 'Processing image', i
	depth_image = spm.imread(options.train_data_dir+str(i)+'.depth.png', True)
	idx_image = spm.imread(options.train_data_dir+str(i)+'.idx.png')
	scene_list = json.load(open(options.train_data_dir+str(i)+'.json'))
	
示例#2
0
#!/usr/bin/env python
import sys
import json
import fern
import numpy as np
import scipy.misc as spm
from scipy.ndimage import find_objects, label, map_coordinates
from depth_util import compute_points, get_model_names
import pylab


models_dir = 'models/'
train_data_dir = 'training_data/'

models = get_model_names(models_dir)

classifier = fern.fern_classifier.from_parameters(fern_depth=12, num_ferns=50, class_labels=models)

num_scenes = json.load(open(train_data_dir+'dataset.json'))['num_scenes']


for i in range(num_scenes):
	depth_image = spm.imread(train_data_dir+str(i)+'.depth.png', True)
	points = compute_points(depth_image)
	
	scene_obj = json.load(open(train_data_dir + str(i) + '.json'))
	camera_matrix = np.array(scene_obj['camera_matrix'])
	actor_matrix = np.array(scene_obj['actor_matrix'])
	m = scene_obj['model']
	
	plane_normal = camera_matrix[0:3,2]