correct = 0.0 correct_object = 0.0 num_classificatons = 0 num_object_classificatons = 0 for i in range(num_scenes): print 'Processing image', i depth_image = spm.imread(options.test_data_dir+str(i)+'.depth.png', True) idx_image = spm.imread(options.test_data_dir+str(i)+'.idx.png') scene_list = json.load(open(options.test_data_dir+str(i)+'.json')) #pylab.imshow(depth_image) #pylab.show() idx_to_object = { x['idx']:x['model']+':'+d.matrix2orientation(np.array(x['transform'])) for x in scene_list if x['model'] != 'Wall' and x['model'] != 'Floor'} labels, num_labels = d.segment_image(depth_image, idx_image, scene_list) obj = d.extract_segments(depth_image, labels, idx_image) comb = d.get_random_combinations(depth_image, labels, obj, 4, idx_to_object) print 'Found', len(comb), 'possible objects' #comb = sorted(comb, key=lambda x: -x[3]) for c in comb: num_classificatons += 1 pred, dist = classifier.classify(c[0]) #print dist ''' if pred != 'not_an_object':
depth_image = spm.imread(test_fitting_data_dir+str(i)+'.depth.png', True) idx_image = spm.imread(test_fitting_data_dir+str(i)+'.idx.png') #plt.imshow(depth_image) #plt.show() for obj in scene_list: if obj['model'] == 'Wall' or obj['model'] == 'Floor': continue object_depth_image = depth_image.copy() object_depth_image[idx_image != obj['idx']] = 0 model_transform_true = np.array(obj['transform']) label = d.matrix2orientation(model_transform_true) #print label #plt.imshow(object_depth_image) #plt.show() model = models_sdf[obj['model']] v, u = np.nonzero(object_depth_image != 0) depth = depth_image[(v,u)]/1000.0 points = np.vstack([depth*u, depth*v, depth]) model_points = np.dot(d.K_default_inv, points) centroid = np.mean(model_points, axis=1) model_transform = d.orientation2matrix(label)