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 import util as ut #Local function. Uses only: getTime
00031 import processor #Used for LABEL_CLUTTER, LABEL_SURFACE, config.path, and feature_type
00032 
00033 
00034 class classifier(object):
00035     '''
00036     classdocs
00037     '''
00038 
00039     processor = None
00040     features = 'all'
00041 
00042     def __init__(self, processor, features):
00043         '''
00044         Constructor
00045         '''
00046         self.processor = processor
00047         self.features = features
00048         
00049         
00050     def train(self):
00051         return None
00052     
00053     #abstract
00054     def test(self, feature_data = None):
00055         return None
00056     
00057     #dict are the loaded features including the ground truth, labels the algorithm output
00058     def test_results(self, dict, labels):
00059         current_set_size = dict['set_size']
00060         count_correct = 0
00061         count_clutter_correct = 0
00062         count_surface_correct = 0
00063         count_clutter = 0
00064         count_surface = 0
00065         count = 0
00066         for index in dict['point_indices']:
00067             label = labels[index]
00068             
00069             if label == dict['labels'][count]:
00070                 count_correct += 1
00071                 
00072             if dict['labels'][count] == processor.LABEL_CLUTTER:
00073                 count_clutter += 1
00074                 if label == dict['labels'][count]:
00075                     count_clutter_correct += 1
00076             if dict['labels'][count] == processor.LABEL_SURFACE:
00077                 count_surface += 1
00078                 if label == dict['labels'][count]:
00079                     count_surface_correct += 1                    
00080 
00081             count += 1        
00082         
00083         print ut.getTime(), '##########################################'
00084         print ut.getTime(), '####tested on ', self.features, '###########################'
00085         print ut.getTime(), '==================================='
00086         print ut.getTime(), 'percent in total: surface:',(float(count_surface)/float(current_set_size)*100), '%, clutter:',(float(count_clutter)/float(current_set_size)*100),'%'
00087         print ut.getTime(), '#points surface:',count_surface,'clutter:',count_clutter
00088         print ut.getTime(), '#points correct: surface:',count_surface_correct,'clutter:',count_clutter_correct
00089         if count_surface > 0:
00090             percent_surface_correct = float(count_surface_correct)/float(count_surface) * 100
00091         else:
00092             percent_surface_correct = 100
00093         if count_clutter > 0:
00094             percent_clutter_correct = float(count_clutter_correct)/float(count_clutter) * 100
00095         else:
00096             percent_clutter_correct = 100
00097         print ut.getTime(), '#percent correct: surface:',percent_surface_correct,'clutter:',percent_clutter_correct
00098         print ut.getTime(), '==================================='
00099         print ut.getTime(), '##########################################'
00100         testresults = (count_surface, count_clutter,count_surface_correct, count_clutter_correct, percent_surface_correct, percent_clutter_correct)
00101     
00102         return testresults  
00103         
00104         
00105         
00106     def get_filename(self):
00107         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'
00108     
00109     def save(self):
00110         return None
00111             
00112     
00113     def load(self):
00114         return None
00115         
00116         


clutter_segmentation
Author(s): Jason Okerman, Martin Schuster, Advisors: Prof. Charlie Kemp and Jim Regh, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 12:07:15