Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 from hrl_lib.util import getTime
00032
00033 import processor
00034
00035 class classifier(object):
00036 '''
00037 classdocs
00038 '''
00039
00040 processor = None
00041 features = 'all'
00042
00043 def __init__(self, processor, features):
00044 '''
00045 Constructor
00046 '''
00047 self.processor = processor
00048 self.features = features
00049
00050
00051 def train(self):
00052 return None
00053
00054
00055 def test(self, feature_data = None):
00056 return None
00057
00058
00059 def test_results(self, dict, labels):
00060 current_set_size = dict['set_size']
00061 count_correct = 0
00062 count_clutter_correct = 0
00063 count_surface_correct = 0
00064 count_clutter = 0
00065 count_surface = 0
00066 count = 0
00067 for index in dict['point_indices']:
00068 label = labels[index]
00069
00070 if label == dict['labels'][count]:
00071 count_correct += 1
00072
00073 if dict['labels'][count] == processor.LABEL_CLUTTER:
00074 count_clutter += 1
00075 if label == dict['labels'][count]:
00076 count_clutter_correct += 1
00077 if dict['labels'][count] == processor.LABEL_SURFACE:
00078 count_surface += 1
00079 if label == dict['labels'][count]:
00080 count_surface_correct += 1
00081
00082 count += 1
00083
00084 print getTime(), '##########################################'
00085 print getTime(), '####tested on ', self.features, '###########################'
00086 print getTime(), '==================================='
00087 print getTime(), 'percent in total: surface:',(float(count_surface)/float(current_set_size)*100), '%, clutter:',(float(count_clutter)/float(current_set_size)*100),'%'
00088 print getTime(), '#points surface:',count_surface,'clutter:',count_clutter
00089 print getTime(), '#points correct: surface:',count_surface_correct,'clutter:',count_clutter_correct
00090 if count_surface > 0:
00091 percent_surface_correct = float(count_surface_correct)/float(count_surface) * 100
00092 else:
00093 percent_surface_correct = 100
00094 if count_clutter > 0:
00095 percent_clutter_correct = float(count_clutter_correct)/float(count_clutter) * 100
00096 else:
00097 percent_clutter_correct = 100
00098 print getTime(), '#percent correct: surface:',percent_surface_correct,'clutter:',percent_clutter_correct
00099 print getTime(), '==================================='
00100 print getTime(), '##########################################'
00101 testresults = (count_surface, count_clutter,count_surface_correct, count_clutter_correct, percent_surface_correct, percent_clutter_correct)
00102
00103 return testresults
00104
00105
00106
00107 def get_filename(self):
00108 return self.processor.config.path+'/classifier_'+self.features+'_'+self.processor.feature_type+'_k'+str(self.processor.feature_neighborhood)+'_r'+str(self.processor.feature_radius)+'.XML'
00109
00110 def save(self):
00111 return None
00112
00113
00114 def load(self):
00115 return None
00116
00117