Exemple #1
0
 def run(self):
     with RunManager(self.name, self.run_acquirer, self.setup, self.q_sig,
                     self.q_comm) as rm:
         print(rm)
Exemple #2
0
 def run(self):
     ''' Run continuously, waiting for input
     '''
     with RunManager(self.name, self.getInput, self.setup, self.q_sig,
                     self.q_comm) as rm:
         logger.info(rm)
Exemple #3
0
    def run(self):
        '''Run the processor continually on input frames
        '''
        self.fitframe_time = []
        self.putAnalysis_time = []
        self.procFrame_time = []  #aka t_motion
        self.detect_time = []
        self.shape_time = []
        self.flag = False
        self.total_times = []
        self.timestamp = []
        self.counter = 0

        with RunManager(self.name, self.runProcess, self.setup, self.q_sig,
                        self.q_comm) as rm:
            logger.info(rm)

        print('Processor broke, avg time per frame: ',
              np.mean(self.total_times, axis=0))
        print('Processor got through ', self.frame_number, ' frames')
        np.savetxt('output/timing/process_frame_time.txt',
                   np.array(self.total_times))
        np.savetxt('output/timing/process_timestamp.txt',
                   np.array(self.timestamp))

        self.shape_time = np.array(self.onAc.t_shapes)
        self.detect_time = np.array(self.onAc.t_detect)

        np.savetxt('output/timing/fitframe_time.txt',
                   np.array(self.fitframe_time))
        np.savetxt('output/timing/shape_time.txt', self.shape_time)
        np.savetxt('output/timing/detect_time.txt', self.detect_time)

        np.savetxt('output/timing/putAnalysis_time.txt',
                   np.array(self.putAnalysis_time))
        np.savetxt('output/timing/procFrame_time.txt',
                   np.array(self.procFrame_time))

        before = self.params['init_batch']
        nb = self.onAc.params.get('init', 'nb')
        np.savetxt(
            'output/raw_C.txt',
            np.array(
                self.onAc.estimates.C_on[nb:self.onAc.M,
                                         before:self.frame_number + before]))

        print('Number of times coords updated ', self.counter)

        # with open('output/S.pk', 'wb') as f:
        #     init = self.params['init_batch']
        #     S = np.stack([osi.s[init:] for osi in self.onAc.estimates.OASISinstances])
        #     print('--------Final S shape: ', S.shape)
        #     pickle.dump(S, f)
        with open('output/A.pk', 'wb') as f:
            nb = self.onAc.params.get('init', 'nb')
            A = self.onAc.estimates.Ab[:, nb:]
            print(type(A))
            pickle.dump(A, f)

        if self.onAc.estimates.OASISinstances is not None:
            try:
                init = self.params['init_batch']
                S = np.stack([
                    osi.s[init:] for osi in self.onAc.estimates.OASISinstances
                ])
                np.savetxt('output/end_spikes.txt', S)
            except Exception as e:
                logger.error('Exception {}: {} during frame number {}'.format(
                    type(e).__name__, e, self.frame_number))
                print(traceback.format_exc())
        else:
            print('No OASIS')
        self.coords1 = [o['CoM'] for o in self.coords]
        print(self.coords1[0])
        print('type ', type(self.coords1[0]))
        np.savetxt('output/contours.txt', np.array(self.coords1))