baseline_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 from classifier import classifier
00031 
00032 import util as ut #Uses: load_pickle, getTime
00033 import numpy as np
00034 
00035 import processor ###
00036 
00037 # Other Imports (classify_baseline_code):
00038 #    x   import hrl_tilting_hokuyo.processing_3d as p3d
00039 #        import hrl_tilting_hokuyo.occupancy_grid_3d as og3d [for occupancy_grid_3d()]
00040 #    x   import hrl_tilting_hokuyo.display_3d_mayavi as d3m
00041 
00042 
00043 class baseline_classifier(classifier):
00044     '''
00045     classdocs
00046     '''
00047 
00048 
00049     #def __init__(selfparams):
00050     #    '''
00051     #    Constructor
00052     #    '''
00053         
00054     
00055     def test(self, feature_data = None):
00056         #test on current scan:
00057         print ut.getTime(), 'test on:', self.processor.scan_dataset.id    
00058             
00059         if feature_data == None:
00060             filename = self.processor.get_features_filename()
00061             dict = ut.load_pickle(filename)
00062         else:
00063             dict = feature_data
00064         
00065         baseline_labels = self.classify_baseline_code()
00066     
00067         return baseline_labels, self.test_results(dict, baseline_labels)  
00068     
00069     
00070     def classify_baseline_code(self):
00071         ###import hrl_tilting_hokuyo.processing_3d as p3d
00072         ###import hrl_tilting_hokuyo.display_3d_mayavi as d3m
00073         import hrl_tilting_hokuyo.occupancy_grid_3d as og3d
00074 
00075         pt = np.matrix(self.processor.point_of_interest).T
00076         #define VOI
00077         width_half = self.processor.voi_width / 2.0
00078         brf = pt+np.matrix([-width_half,-width_half,-width_half]).T
00079         tlb = pt+np.matrix([width_half, width_half, width_half]).T
00080         resolution = np.matrix([0.1,0.1,0.0025]).T
00081         max_dist = 15
00082         min_dist = -15
00083         gr = og3d.occupancy_grid_3d(brf,tlb,resolution)
00084         print 'filling grid...'
00085         gr.fill_grid(self.processor.pts3d_bound)
00086         print '...filled.'
00087         gr.to_binary(1)
00088         l = gr.find_plane_indices(assume_plane=True,hmin=0.3,hmax=2)
00089         z_min = min(l)*gr.resolution[2,0]+gr.brf[2,0]
00090         z_max = max(l)*gr.resolution[2,0]+gr.brf[2,0]
00091         
00092         pts = np.asarray(self.processor.pts3d_bound)
00093         conditions_surface = np.multiply(pts[2,:] > z_min, pts[2,:] < z_max)
00094         print 'cf',conditions_surface
00095         conditions_clutter = np.invert(conditions_surface)
00096         conditions_surface = np.multiply(conditions_surface, np.array(self.processor.map_polys) > 0)
00097         print 'cf',conditions_surface
00098         idx_surface = np.where(conditions_surface)
00099         conditions_clutter = np.multiply(conditions_clutter, np.array(self.processor.map_polys) > 0)
00100         idx_clutter = np.where(conditions_clutter)
00101         
00102         n, m = np.shape(self.processor.pts3d_bound)
00103         print n,m
00104         labels = np.zeros(m)
00105         print np.shape(labels), labels
00106         print np.shape(idx_surface), idx_surface
00107         labels[idx_surface] = processor.LABEL_SURFACE
00108         labels[idx_clutter] = processor.LABEL_CLUTTER
00109         
00110         print labels
00111         
00112         return labels     
00113          
00114     


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