def testSegmentationMethods(self): print "Test Segmentation Methods" # Test the segmentation independantly of the aligment using the "true" pose # report the confusion matrix or summary statustic (false alarm rate, etc?) temp_outliers = util.get_scan_points_from_file(os.path.join(self.datadir, '1271124950-new.txt')) dists = pointcloud.nearest_neighbour(self.Pall,temp_outliers) outliers_inds2 = dists < 0.01 temp_inliers = self.Pall[np.logical_not(outliers_inds2)] self.assertTrue((temp_outliers.shape[0] + temp_inliers.shape[0]) == self.Pall.shape[0]) self.trueoutliers = poseutil.transformPoints(temp_outliers, poseutil.mat(self.truepose)) self.trueinliers = poseutil.transformPoints(temp_inliers, poseutil.mat(self.truepose)) for method in self.segmenters: seg_name = method.__name__.replace('_', ' ') seg_name = seg_name.replace('segment ', '') print 5*'-', seg_name, 5*'-' # Execute the segmentation algorithm and time it start_seg = time.time() inliers,outliers = method(self.truePoints) taken_seg = time.time() - start_seg # check accuracy and timeliness true_pos, true_neg, false_neg, false_pos = util.segmentation_stats(inliers, outliers, self.trueinliers, self.trueoutliers) self.assertTrue(sum(true_pos) > 0) self.assertTrue(sum(true_neg) > 0) print sum(true_pos), sum(false_pos) print sum(false_neg), sum(true_neg) FPR, MDR, accuracy, specificity = util.segmentation_summary(true_pos, true_neg, false_neg, false_pos, self.trueoutliers.shape[0], self.Pall.shape[0]) print "False +ve rate: ", FPR self.assertTrue(FPR < 0.05) print "Missed detection rate: ", MDR self.assertTrue(MDR < 0.15) print "accuracy: ", accuracy self.assertTrue(accuracy > 0.9) print "specifity: ", specificity self.assertTrue(specificity > 0.9)
def generate_tst_data_from_file(voxel_test_map_file, voxel_test_query_scan_file, voxel_test_query_pose_file): print 'Loading test data from', voxel_test_map_file, '...', Qfile, map_resolution = util.get_mappoints_from_voxel_file(voxel_test_map_file) Pfile = util.get_scan_points_from_file(voxel_test_query_scan_file) Pnew = util.boxfilter(Pfile, (2, 1, 3), (9, 4.5, 7)) guess_pose = util.get_scan_pose_from_file(voxel_test_query_pose_file) print 'Complete' return Pnew, Qfile, guess_pose, map_resolution