예제 #1
0
def LoadDatasetBaidu(filename):
    file_list = np.genfromtxt(filename,
                              delimiter=',',
                              names=True,
                              dtype=np.dtype([('image', object),
                                              ('label', int), ('x', float),
                                              ('y', float), ('z', float),
                                              ('rx', float), ('ry', float),
                                              ('rz', float),
                                              ('timestamp', object)]))

    input_images = ImageProcProxy.emptyDataset(file_list.shape[0],
                                               params['input']['width'] * 2,
                                               params['input']['height'])
    orig_image_file = ImageProcProxy.readImageColor(file_list['image'][0])
    image_crop = cv2.resize(
        orig_image_file, (params['input']['width'], params['input']['height']))
    image_gaus = ImageProcProxy.applyGaussian(
        image_crop, params['filter']['gaussian_radius'],
        params['filter']['gaussian_sigma'])
    image_crop_int = ImageProcProxy.convertBGR2INT(image_crop)
    image_gaus_int = ImageProcProxy.convertBGR2INT(image_gaus)
    image_crop_vec = ImageProcProxy.flattenImage(image_crop_int)
    image_gaus_vec = ImageProcProxy.flattenImage(image_gaus_int)
    input_images[0] = ImageProcProxy.concatImages(image_crop_vec,
                                                  image_gaus_vec)
    return file_list.shape[0], input_images.shape[1], file_list.shape[0]
예제 #2
0
    def train(self, memory_size, input_size, num_samples, filename,stereo_mode):
        self.neural_network.memory_size = memory_size   
        self.neural_network.input_size = input_size        
        self.neural_network.AllocateNetworkMemories() 
        file_list = np.genfromtxt(filename, delimiter=',', names=True, dtype=np.dtype([('image',object), 
                                                                                            ('label', int), 
                                                                                            ('x', float), 
                                                                                            ('y', float), 
                                                                                            ('z',float),
                                                                                            ('rx', float), 
                                                                                            ('ry', float), 
                                                                                            ('rz',float), 
                                                                                            ('timestamp', object)]))

        for sample in xrange(file_list.shape[0]):
            if not sample%100:
                print "iterate:",sample
            if not stereo_mode :
                orig_image_file     = ImageProcProxy.readImageColor(file_list['image'][sample])
                image_file          = cv2.resize(orig_image_file, (params['input']['width'],params['input']['height']))
                image_crop          = image_file 
            else:
                image_file          = ImageProcProxy.readImageColor(file_list['image'][sample])
                image_crop          = ImageProcProxy.cropImage(image_file, 0, 0, params['input']['width'], params['input']['height'])
            image_gaus          = ImageProcProxy.applyGaussian(image_crop, 
                                        params['filter']['gaussian_radius'], 
                                        params['filter']['gaussian_sigma'])
            image_crop_int      = ImageProcProxy.convertBGR2INT(image_crop)
            image_gaus_int      = ImageProcProxy.convertBGR2INT(image_gaus)
            image_crop_vec      = ImageProcProxy.flattenImage(image_crop_int)
            image_gaus_vec      = ImageProcProxy.flattenImage(image_gaus_int)
            input_image = ImageProcProxy.concatImages(image_crop_vec, image_gaus_vec)
            input_class = file_list['label'][sample]
            self.neural_network.Train( input_image, input_class, sample)
예제 #3
0
def ProcessImage(image_crop, pixel_range=0):
    x = uniform(-pixel_range, pixel_range)
    y = uniform(-pixel_range, pixel_range)
    image_trans = ImageProcProxy.translateImage(image_crop, x, y)
    #ImageProcProxy.showImageBGR(image_trans)
    image_gaus = ImageProcProxy.applyGaussian(
        image_trans, params['filter']['gaussian_radius'],
        params['filter']['gaussian_sigma'])
    image_crop_int = ImageProcProxy.convertBGR2INT(image_crop)
    image_gaus_int = ImageProcProxy.convertBGR2INT(image_gaus)
    image_crop_vec = ImageProcProxy.flattenImage(image_crop_int)
    image_gaus_vec = ImageProcProxy.flattenImage(image_gaus_int)
    input_image = ImageProcProxy.concatImages(image_crop_vec, image_gaus_vec)

    return input_image
예제 #4
0
def ProcessImage(image_crop, pixel_range=0):
    x = uniform(-pixel_range, pixel_range)
    y = uniform(-pixel_range, pixel_range)
    image_trans         = ImageProcProxy.translateImage(image_crop, x, y)
    #ImageProcProxy.showImageBGR(image_trans)
    image_gaus          = ImageProcProxy.applyGaussian(image_trans, 
                            params['filter']['gaussian_radius'], 
                            params['filter']['gaussian_sigma'])
    image_crop_int      = ImageProcProxy.convertBGR2INT(image_crop)
    image_gaus_int      = ImageProcProxy.convertBGR2INT(image_gaus)
    image_crop_vec      = ImageProcProxy.flattenImage(image_crop_int)
    image_gaus_vec      = ImageProcProxy.flattenImage(image_gaus_int)
    input_image         = ImageProcProxy.concatImages(image_crop_vec, image_gaus_vec)
    
    return input_image
예제 #5
0
def LoadDataset(filename, imagepath):
    file_list = np.genfromtxt(filename, delimiter=',', names=True, dtype=np.dtype([('timestamp', object), ('x', float), ('y', float), ('label', int)]))

    input_images = ImageProcProxy.emptyDataset(file_list.shape[0], 
                                               params['input']['width'] * 2, 
                                               params['input']['height'])
    for sample in xrange(file_list.shape[0]):
        image_file          = ImageProcProxy.readImageColor(imagepath + file_list['timestamp'][sample] + '.bb08.l.png')
        image_crop          = ImageProcProxy.cropImage(image_file, 0, 0, 
                                                       params['input']['width'], 
                                                       params['input']['height'])
        image_gaus          = ImageProcProxy.applyGaussian(image_crop, 
                                    params['filter']['gaussian_radius'], 
                                    params['filter']['gaussian_sigma'])
        image_crop_int      = ImageProcProxy.convertBGR2INT(image_crop)
        image_gaus_int      = ImageProcProxy.convertBGR2INT(image_gaus)
        image_crop_vec      = ImageProcProxy.flattenImage(image_crop_int)
        image_gaus_vec      = ImageProcProxy.flattenImage(image_gaus_int)
        input_images[sample]= ImageProcProxy.concatImages(image_crop_vec, image_gaus_vec)
    return input_images, file_list['label'], file_list['x'], file_list['y']