示例#1
0
    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.width,
                                        transparent=False,
                                        tight=False)

        self.min_score = None
        self.max_score = None
示例#2
0
 def init(self):
     self.plot_generic = PlotGeneric(width=320,
                                     height=240,
                                     transparent=False,
                                     tight=False,
                                     keep=True)
     self.first_timestamp = None
     self.plot_anim = PlotAnim()
     self.nframes = 0
示例#3
0
文件: aer_pf.py 项目: AndreaCensi/rcl
class AERPFPlotter(Block):
    Block.alias('aer_pf_plot')
    Block.config('width', 'Image dimension', default=384)
    Block.input('tracks')
    Block.output('rgb')
    
    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.width,
                                        transparent=False,
                                        tight=False)
        
        
    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)
        
    def plot(self, pylab):
        tracks = self.input.tracks
        track2color = get_track_colors(tracks)  
        for id_track, particles in enumerate_id_track(self.input.tracks):
            color = track2color[id_track]
            plot_particles(pylab, particles, color)
            
        set_viewport_style(pylab)
        pylab.title('Particles')
示例#4
0
class JitteryDisplay(Block):
    Block.alias('jittery_display')

    Block.input('clock')
    Block.output('rgb')
    
    def init(self):
        self.plot_generic = PlotGeneric(width=320,
                                        height=240,
                                        transparent=False,
                                        tight=False,
                                        keep=True)
        self.first_timestamp = None
        self.plot_anim = PlotAnim()
        self.nframes = 0
        
    def update(self):
        if self.first_timestamp is None:
            self.first_timestamp = self.get_input_timestamp(0)
        self.time_since_start = self.get_input_timestamp(0) - self.first_timestamp
        self.nframes += 1
        self.output.rgb = self.plot_generic.get_rgb(self.plot)
        
        
    def plot(self, pylab):
        self.plot_anim.set_pylab(pylab)
        self.plot_anim.text('clock', 0, 1, '%5.2f' % self.time_since_start)
        self.plot_anim.text('frames', 0, 0.5, '%d' % self.nframes)

        self.plot_anim.text('value', 0, 0.24, self.input.clock)
        pylab.axis((-0.2, 1.1, -0.1, 1.1))
示例#5
0
class Bounce(Block):

    Block.alias('bounce')

    Block.config('width', 'Image dimension', default=320)
    Block.config('height', 'Image dimension', default=240)
    Block.config('transparent',
                 'If true, outputs a RGBA image instead of RGB.',
                 default=False)
    Block.config('tight',
                 'Uses "tight" option for creating png (Matplotlib>=1.1).',
                 default=False)

    Block.input('tick')
    Block.output('rgb')

    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.height,
                                        transparent=self.config.transparent,
                                        tight=self.config.tight)

    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)

    def plot(self, pylab):
        t = self.get_input_timestamp(0)
        t0 = t
        t1 = t + 2
        x = np.linspace(t0, t1, 1000)
        y = np.cos(x)
        pylab.plot(x, y)
        pylab.axis((t0, t1, -1.2, +1.2))
示例#6
0
class Bounce(Block):
    
    Block.alias('bounce')

    Block.config('width', 'Image dimension', default=320)
    Block.config('height', 'Image dimension', default=240)
    Block.config('transparent', 'If true, outputs a RGBA image instead of RGB.',
                 default=False)
    Block.config('tight', 'Uses "tight" option for creating png (Matplotlib>=1.1).',
                 default=False)
    
    Block.input('tick')
    Block.output('rgb')
    
    
    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.height,
                                        transparent=self.config.transparent,
                                        tight=self.config.tight)

    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)
        
        
    def plot(self, pylab):
        t = self.get_input_timestamp(0)
        t0 = t
        t1 = t + 2
        x = np.linspace(t0, t1, 1000)
        y = np.cos(x)
        pylab.plot(x, y)
        pylab.axis((t0, t1, -1.2, +1.2))
示例#7
0
class AERTrackPlotter(Block):
    Block.alias('aer_track_plotter')
    Block.config('width', 'Image dimension', default=128)
    Block.input('tracks')
    Block.output('rgb')

    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.width,
                                        transparent=False,
                                        tight=False)

    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)

    def plot(self, pylab):
        tracks = self.input.tracks

        plot_tracks(pylab, tracks, base_markersize=10, alpha=0.5)

        T = self.get_input_timestamp(0)
        pylab.title('Raw detections')
        time = 'T = %.1f ms' % (T * 1000)
        pylab.text(3, 3, time)
        set_viewport_style(pylab)
示例#8
0
 def init(self):
     self.plot_generic = PlotGeneric(width=self.config.width,
                                     height=self.config.height,
                                     transparent=False,
                                     tight=False,
                                     keep=True)
     self.plot_anim = PlotAnim()
示例#9
0
class CBCDisplayDist(Block):
    Block.alias('cbc_display_dist')

    Block.config('width', 'Image dimension', default=320)
    Block.config('height', 'Image dimension', default=320)
    
    Block.input('res', 'Results dictionary')
    
    Block.output('rgb')
    
    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.height,
                                        transparent=False,
                                        tight=False,
                                        keep=True)
        self.plot_anim = PlotAnim()
        
    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)
        
    def plot(self, pylab):
        res = self.input.res
        S = res['S']
        self.info(S.shape)
        
        Sx = S[0, :]
        Sy = S[1, :]
#         Sz = S[2, :]
        self.plot_anim.set_pylab(pylab)
        
        self.plot_anim.plot('Sxy', Sx, Sy, 'ko')
        pylab.axis((-1, +1, -1, +1))
        turn_off_all_axes(pylab)
示例#10
0
class AERTrackPlotter(Block):
    Block.alias('aer_track_plotter')
    Block.config('width', 'Image dimension', default=128)
    Block.input('tracks')
    Block.output('rgb')
    
    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.width,
                                        transparent=False,
                                        tight=False)
        
    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)
        
    def plot(self, pylab):
        tracks = self.input.tracks
        
        plot_tracks(pylab, tracks, base_markersize=10, alpha=0.5)

        T = self.get_input_timestamp(0)
        pylab.title('Raw detections')
        time = 'T = %.1f ms' % (T * 1000)
        pylab.text(3, 3, time)
        set_viewport_style(pylab)
示例#11
0
文件: aer_pf.py 项目: AndreaCensi/rcl
 def init(self):
     self.plot_generic = PlotGeneric(width=self.config.width,
                                     height=self.config.width,
                                     transparent=False,
                                     tight=False)
     
     self.min_score = None  
     self.max_score = None
示例#12
0
文件: aer_pf.py 项目: AndreaCensi/rcl
class AERPFQualityPlotter(Block):
    Block.alias('aer_pf_quality_plot')
    Block.config('width', 'Image dimension', default=384)
    Block.input('tracks')
    Block.output('rgb')
    
    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.width,
                                        transparent=False,
                                        tight=False)
        
        self.min_score = None  
        self.max_score = None
        
    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)
        
    def plot(self, pylab):
        tracks = self.input.tracks
        track2color = get_track_colors(tracks)  
        for id_track, particles in enumerate_id_track(self.input.tracks):
            color = track2color[id_track]
            bound = particles['bound']
            score = particles['score']
            pylab.scatter(bound, np.log(score), marker='s', color=color)
        
        min_score = np.min(particles['score'])
        max_score = np.max(particles['score'])
        
        if self.min_score is None:
            self.min_score = min_score
            self.max_score = max_score
            
        self.min_score = min(self.min_score, min_score)
        self.max_score = min(self.max_score, max_score)
             
#        a = pylab.axis()
#        pylab.axis((-1, 30, a[2], a[3]))
        M = 0.1
        y0 = np.log(self.min_score)
        y1 = np.log(self.max_score)
        delta = y1 - y0
        y0 -= M * delta
        y1 += M * delta
        
        pylab.axis((-1, 30, y0, y1))
        pylab.xlabel('spatial uncertainty (pixels)')
        pylab.ylabel('score')
        pylab.title('Particles statistics')
示例#13
0
class AERPFQualityPlotter(Block):
    Block.alias('aer_pf_quality_plot')
    Block.config('width', 'Image dimension', default=384)
    Block.input('tracks')
    Block.output('rgb')

    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.width,
                                        transparent=False,
                                        tight=False)

        self.min_score = None
        self.max_score = None

    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)

    def plot(self, pylab):
        tracks = self.input.tracks
        track2color = get_track_colors(tracks)
        for id_track, particles in enumerate_id_track(self.input.tracks):
            color = track2color[id_track]
            bound = particles['bound']
            score = particles['score']
            pylab.scatter(bound, np.log(score), marker='s', color=color)

        min_score = np.min(particles['score'])
        max_score = np.max(particles['score'])

        if self.min_score is None:
            self.min_score = min_score
            self.max_score = max_score

        self.min_score = min(self.min_score, min_score)
        self.max_score = min(self.max_score, max_score)

        #        a = pylab.axis()
        #        pylab.axis((-1, 30, a[2], a[3]))
        M = 0.1
        y0 = np.log(self.min_score)
        y1 = np.log(self.max_score)
        delta = y1 - y0
        y0 -= M * delta
        y1 += M * delta

        pylab.axis((-1, 30, y0, y1))
        pylab.xlabel('spatial uncertainty (pixels)')
        pylab.ylabel('score')
        pylab.title('Particles statistics')
示例#14
0
文件: aer_pf.py 项目: AndreaCensi/rcl
class AERPFHPPlotter(Block):
    Block.alias('aer_pf_hp_plotter')
    Block.config('width', 'Image dimension', default=128)
    Block.config('title', default=None)
    Block.input('alts')
    Block.output('rgb')
    
    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.width,
                                        transparent=False,
                                        tight=False)
        self.max_q = 0
        
    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)
        
    def plot(self, pylab):
        alts = self.input.alts
        
        markers = ['s', 'o', 'x']
        for i, alt in enumerate(alts):    
            marker = markers[i % len(markers)]
            self.plot_hp(pylab, alt, marker)
        
        # only draw if small...
        if len(alts) <= 2:
            scores = ",".join(['%g' % x.score for x  in alts])
            pylab.text(3, 3, 'score: %s' % scores)
        set_viewport_style(pylab)
        title = self.config.title
        if title is not None:
            pylab.title(title) 

    def plot_hp(self, pylab, alt, marker):
        particles = alt.subset
        track2color = get_track_colors(particles)  
        for id_track, particles in enumerate_id_track(particles):
            color = track2color[id_track]
            plot_particles(pylab, particles, color)        
示例#15
0
class AERPFHPPlotter(Block):
    Block.alias('aer_pf_hp_plotter')
    Block.config('width', 'Image dimension', default=128)
    Block.config('title', default=None)
    Block.input('alts')
    Block.output('rgb')

    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.width,
                                        transparent=False,
                                        tight=False)
        self.max_q = 0

    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)

    def plot(self, pylab):
        alts = self.input.alts

        markers = ['s', 'o', 'x']
        for i, alt in enumerate(alts):
            marker = markers[i % len(markers)]
            self.plot_hp(pylab, alt, marker)

        # only draw if small...
        if len(alts) <= 2:
            scores = ",".join(['%g' % x.score for x in alts])
            pylab.text(3, 3, 'score: %s' % scores)
        set_viewport_style(pylab)
        title = self.config.title
        if title is not None:
            pylab.title(title)

    def plot_hp(self, pylab, alt, marker):
        particles = alt.subset
        track2color = get_track_colors(particles)
        for id_track, particles in enumerate_id_track(particles):
            color = track2color[id_track]
            plot_particles(pylab, particles, color)
示例#16
0
class CBCDisplayRes(Block):
    Block.alias('cbc_display_f')

    Block.config('width', 'Image dimension', default=320)
    Block.config('height', 'Image dimension', default=320)
    
    Block.input('res', 'Results dictionary')
    
    Block.output('rgb')
    
    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.height,
                                        transparent=False,
                                        tight=False,
                                        keep=False)
#         self.plot_anim = PlotAnim()
        
    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)
        
    def plot(self, pylab):
        
        
        res = self.input.res
        
        R = res['R']
        S = res['S']
        D = distances_from_directions(S)
        
        Rf = np.array(R.flat)
        Df = np.rad2deg(np.array(D.flat))
        
#         self.plot_anim.set_pylab(pylab)
#         self.plot_anim.plot('rel', Df, Rf, 'b.')
        pylab.plot(Df, Rf, 'b.')
        D1 = np.max(Df)
        pylab.axis((0, D1, -1, +1))
        pylab.xlabel('distance (deg)')
        pylab.ylabel('similarity')
示例#17
0
class AERqualityPlotter(Block):
    Block.alias('aer_quality_plotter')
    Block.config('width', 'Image dimension', default=128)
    Block.input('tracks')
    Block.output('rgb')
    
    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.width,
                                        transparent=False,
                                        tight=False)
        self.max_q = 0
        
    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)
        
    def plot(self, pylab):
        tracks = self.input.tracks
        assert isinstance(tracks, np.ndarray)
        
        t2c = get_track_colors(tracks)
        x_ticks = []
        x_label = []
        for i, xx in enumerate(enumerate_id_track(tracks)):
            id_track, its_data = xx
            x_ticks.append(i)
            x_label.append(id_track)
            quality = its_data['quality']
            for j, qq in enumerate(quality):
                xj = i + 0.16 * (j + 1 - len(quality) / 2.0)
                pylab.plot([xj, xj], [0, qq], '%s-' % t2c[id_track], linewidth=2)
                
        self.max_q = max(self.max_q, np.max(tracks['quality']))
    
        M = 0.1
        pylab.axis((-1, len(x_ticks), -M * self.max_q, self.max_q * (1 + M)))
        pylab.xticks(x_ticks, x_label)
        pylab.title('Detection quality') 
示例#18
0
class AERPFPlotter(Block):
    Block.alias('aer_pf_plot')
    Block.config('width', 'Image dimension', default=384)
    Block.input('tracks')
    Block.output('rgb')

    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.width,
                                        transparent=False,
                                        tight=False)

    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)

    def plot(self, pylab):
        tracks = self.input.tracks
        track2color = get_track_colors(tracks)
        for id_track, particles in enumerate_id_track(self.input.tracks):
            color = track2color[id_track]
            plot_particles(pylab, particles, color)

        set_viewport_style(pylab)
        pylab.title('Particles')
示例#19
0
class CBCDisplayDistLub(Block):
    Block.alias('cbc_display_dist_lum')

    Block.config('width', 'Image dimension', default=320)
    Block.config('height', 'Image dimension', default=320)
    
    Block.input('y0', 'image')
    Block.input('res', 'Results dictionary')
    
    Block.output('rgb')
    
    def init(self):
        self.plot_generic = PlotGeneric(width=self.config.width,
                                        height=self.config.height,
                                        transparent=False,
                                        tight=False,
                                        keep=True)
        self.plot_anim = PlotAnim()
        self.s = None
        
    def update(self):
        self.output.rgb = self.plot_generic.get_rgb(self.plot)
        
    def plot(self, pylab):
        res = self.input.res
        y0 = self.input.y0
        self.info(y0.shape)
        
        y0 = y0 / 255.0
        R = y0[..., 0].flatten()
        G = y0[..., 1].flatten()
        B = y0[..., 2].flatten()
        

        rgbs = zip(R, G, B)
#         rgbs = np.vstack((R, G, B)).T
#         print rgbs.shape
        
         
        
        if res is None or y0 is None: 
            return
        S = res['S']

        Sx = S[0, :]
        Sy = S[1, :]

#         _, N = S.shape 
#         assert rgbs.shape == (N, 3)

        fig = pylab.gcf()
        fig.patch.set_facecolor('black')

        if self.s is None:
            self.info('scatter')
            verts = [
                (-1., -1.),  # left, bottom
                (-1., 1.),  # left, top
                (1., 1.),  # right, top
                (1., -1.),  # right, bottom
                (-1., -1.),  # ignored
                ]

            codes = [Path.MOVETO,
                     Path.LINETO,
                     Path.LINETO,
                     Path.LINETO,
                     Path.CLOSEPOLY,
                     ]
            
            path = Path(verts, codes)            
            patch = patches.PathPatch(path, facecolor='black', lw=0)
            pylab.gca().add_patch(patch)

            self.s = pylab.scatter(x=Sx, y=Sy, c=rgbs, zorder=1000)


        else:
            offs = np.array((Sx, Sy)).T
            self.s.set_offsets(offs)
            self.s.set_color(rgbs)
            
            
        pylab.axis((-1, +1, -1, +1))
        turn_off_all_axes(pylab)
示例#20
0
 def init(self):
     self.plot_generic = PlotGeneric(width=self.config.width,
                                     height=self.config.width,
                                     transparent=False,
                                     tight=False)
示例#21
0
 def init(self):
     self.plot_generic = PlotGeneric(width=self.config.width,
                                     height=self.config.width,
                                     transparent=False,
                                     tight=False)