예제 #1
0
    def update(self):
        rgb0 = self.input.rgb
        H, W = self.discdds.get_shape()
        rgb = resize(rgb0, width=W, height=H)

        y0 = UncertainImage(rgb)
        y1 = self.action.predict(y0)
        pred = y1.get_rgba_fill()

        pred2 = resize(pred, height=rgb0.shape[0], width=rgb0.shape[1])
        self.output.prediction = pred2[:, :, :3]
예제 #2
0
 def update(self):
     rgb0 = self.input.rgb
     H, W = self.discdds.get_shape()
     rgb = resize(rgb0, width=W, height=H)
     
     y0 = UncertainImage(rgb)
     y1 = self.action.predict(y0)
     pred = y1.get_rgba_fill()
     
     pred2 = resize(pred, height=rgb0.shape[0], width=rgb0.shape[1])
     self.output.prediction = pred2[:, :, :3]
예제 #3
0
def show_symdiffeo(config, parser):  #@UnusedVariable
    """ Creates a report for symbolically-defined DDS. """
    parser.add_option("-o",
                      "--output",
                      help="Output directory",
                      default='out/dp-show-symdiffeo/')
    parser.add_option("-i", "--id_image", help="ID image.", default='lena')
    parser.add_option("-d", "--id_diffeo", help="ID diffeo.")
    parser.add_option("-r",
                      "--resolution",
                      default=64,
                      help="Resolution (pixels)")
    options, which = parser.parse()

    outdir = options.output
    resolution = int(options.resolution)

    if not which:
        todo = config.symdiffeos.keys()
    else:
        todo = config.symdiffeos.expand_names(which)

    id_image = options.id_image
    image = config.images.instance(id_image)

    image = resize(image, resolution, resolution)

    for id_diffeo in todo:
        diffeo = config.symdiffeos.instance(id_diffeo)
        report = Report(id_diffeo)

        symdiffeo_display(report, image, diffeo, resolution)

        write_report_files(report, basename=os.path.join(outdir, id_diffeo))
예제 #4
0
def show_symdiffeo(config, parser): #@UnusedVariable
    """ Creates a report for symbolically-defined DDS. """
    parser.add_option("-o", "--output", help="Output directory",
                      default='out/dp-show-symdiffeo/')
    parser.add_option("-i", "--id_image", help="ID image.", default='lena')
    parser.add_option("-d", "--id_diffeo", help="ID diffeo.")
    parser.add_option("-r", "--resolution", default=64,
                      help="Resolution (pixels)")
    options, which = parser.parse()
    
    outdir = options.output
    resolution = int(options.resolution)
    
    if not which:
        todo = config.symdiffeos.keys()  
    else:
        todo = config.symdiffeos.expand_names(which)

    id_image = options.id_image
    image = config.images.instance(id_image)
    
    image = resize(image, resolution, resolution) 
    
    for id_diffeo in todo:
        diffeo = config.symdiffeos.instance(id_diffeo) 
        report = Report(id_diffeo)
        
        symdiffeo_display(report, image, diffeo, resolution)

        write_report_files(report, basename=os.path.join(outdir, id_diffeo))    
예제 #5
0
 def update(self):
     rgb0 = self.input.rgb
     pad = self.config.pad
     
     H, W = self.discdds.get_shape()
     rgb = resize(rgb0, width=W, height=H)
     
     y0 = UncertainImage(rgb)
     
     uimages = [a.predict(y0) for a in self.actions]
     
     images = [x.get_rgba_fill()[..., :3] for x in uimages]
     images = [resize(x, height=rgb0.shape[0], width=rgb0.shape[1]) 
               for x in images]
     canvas = make_images_grid(images, pad=pad)
     
     self.output.prediction = canvas
예제 #6
0
 def obs2ui(self, y):
     """ Converts observatiosn from outside in an UncertainImage
         of the right dimensions to deal with this DDS. """
     shape = self.discdds.get_shape()
     y = (y * 255).astype('uint8')
     y = resize(y, width=shape[1], height=shape[0])
     ui = UncertainImage(y)
     return ui
예제 #7
0
 def obs2ui(self, y):
     """ Converts observatiosn from outside in an UncertainImage
         of the right dimensions to deal with this DDS. """
     shape = self.discdds.get_shape()
     y = (y * 255).astype('uint8')
     y = resize(y, width=shape[1], height=shape[0])
     ui = UncertainImage(y)
     return ui
예제 #8
0
 def observations_from_messages(self, messages):
     """ Converts the topics listed here to a class of XX """
     from procgraph_ros.conversions import ros2rgb
     msg = messages[self.topic]
     rgb = ros2rgb(msg)       
     rgb2 = resize(rgb, width=self.shape[1], height=self.shape[0])
     rgb2 = np.clip(rgb2 / 255.0, 0, 1) 
     return rgb2
예제 #9
0
    def update(self):
        rgb0 = self.input.rgb
        pad = self.config.pad

        H, W = self.discdds.get_shape()
        rgb = resize(rgb0, width=W, height=H)

        y0 = UncertainImage(rgb)

        uimages = [a.predict(y0) for a in self.actions]

        images = [x.get_rgba_fill()[..., :3] for x in uimages]
        images = [
            resize(x, height=rgb0.shape[0], width=rgb0.shape[1])
            for x in images
        ]
        canvas = make_images_grid(images, pad=pad)

        self.output.prediction = canvas
예제 #10
0
def discdds_make_test_cases(config, outdir, id_discdds,
                            id_image, num_cases, plan_length):
    # Get the DiffeoSystem
    discdds = config.discdds.instance(id_discdds)
    # Get the RGB image
    rgb = config.images.instance(id_image)
    
    shape = discdds.get_shape()
    rgb = resize(rgb, shape[1], shape[0])       
    assert rgb.shape[0] == shape[0]
    assert rgb.shape[1] == shape[1]
    
    image = UncertainImage(rgb)
    
    for i in range(num_cases):
        tcname = 'tc_%s_%s_d%d_%03d' % (id_discdds, id_image, plan_length, i)
        discdds_make_test_case(outdir, tcname, id_discdds,
                               discdds, image, plan_length)
예제 #11
0
def discdds_make_test_cases(config, outdir, id_discdds, id_image, num_cases,
                            plan_length):
    # Get the DiffeoSystem
    discdds = config.discdds.instance(id_discdds)
    # Get the RGB image
    rgb = config.images.instance(id_image)

    shape = discdds.get_shape()
    rgb = resize(rgb, shape[1], shape[0])
    assert rgb.shape[0] == shape[0]
    assert rgb.shape[1] == shape[1]

    image = UncertainImage(rgb)

    for i in range(num_cases):
        tcname = 'tc_%s_%s_d%d_%03d' % (id_discdds, id_image, plan_length, i)
        discdds_make_test_case(outdir, tcname, id_discdds, discdds, image,
                               plan_length)