class CCIPCAProcessor(dataprocessor.DataProcessor): def __init__(self, shape, plot=False, **kwargs): self.plot = plot self.ccipca = CCIPCA(np.zeros(shape, np.complex128), **kwargs) self.output_ccipca = self.ccipca def process_sequence(self, frames): for frame in frames: mags = self.ccipca.learn_vector(frame) mags *= np.abs(mags) rec = self.output_ccipca.reconstruct(mags) rec[0] = 0 rec /= (np.linalg.norm(rec) / np.linalg.norm(frame)) if self.plot: #pylab.plot(ticks, np.log(np.abs(rec)), ticks, np.log(np.abs(frame))) pylab.bar(xrange(10), np.abs(mags[:10])) pylab.ylim(0, 1000) pylab.show() yield rec
def __init__(self, shape, plot=False, **kwargs): self.plot = plot self.ccipca = CCIPCA(np.zeros(shape, np.complex128), **kwargs) self.output_ccipca = self.ccipca