classifier.py
Go to the documentation of this file.
00001 #
00002 # Copyright (c) 2010, Georgia Tech Research Corporation
00003 # All rights reserved.
00004 #
00005 # Redistribution and use in source and binary forms, with or without
00006 # modification, are permitted provided that the following conditions are met:
00007 #     * Redistributions of source code must retain the above copyright
00008 #       notice, this list of conditions and the following disclaimer.
00009 #     * Redistributions in binary form must reproduce the above copyright
00010 #       notice, this list of conditions and the following disclaimer in the
00011 #       documentation and/or other materials provided with the distribution.
00012 #     * Neither the name of the Georgia Tech Research Corporation nor the
00013 #       names of its contributors may be used to endorse or promote products
00014 #       derived from this software without specific prior written permission.
00015 #
00016 # THIS SOFTWARE IS PROVIDED BY GEORGIA TECH RESEARCH CORPORATION ''AS IS'' AND
00017 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 # DISCLAIMED. IN NO EVENT SHALL GEORGIA TECH BE LIABLE FOR ANY DIRECT, INDIRECT,
00020 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00021 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00022 # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00023 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00024 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00025 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 #
00027 
00028 #  \author Martin Schuster (Healthcare Robotics Lab, Georgia Tech.)
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     #abstract
00055     def test(self, feature_data = None):
00056         return None
00057     
00058     #dict are the loaded features including the ground truth, labels the algorithm output
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         


laser_camera_segmentation
Author(s): Martin Schuster, Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 11:56:44