def play(self): """Play the internal list of events and save a video.""" from vedo import Video self.events = sorted(self.events, key=lambda x: x[0]) self.bookingMode = False for a in self.actors: a.alpha(0) #if self.showProgressBar: # pb = ProgressBar(0, len(self.events), c='g') if self.totalDuration is None: self.totalDuration = self.events[-1][0] - self.events[0][0] vd = Video(self.videoFileName, fps=self.videoFPS, duration=self.totalDuration) ttlast = 0 for e in self.events: tt, action, self._performers, self._inputvalues = e action(0, 0) dt = tt - ttlast if dt > self.eps: self.show(interactive=False, resetcam=self.resetcam) vd.addFrame() if dt > self.timeResolution + self.eps: vd.pause(dt) ttlast = tt #if self.showProgressBar: # pb.print('t='+str(int(tt*100)/100)+'s, '+action.__name__) self.show(interactive=False, resetcam=self.resetcam) vd.addFrame() vd.close() self.show(interactive=True, resetcam=self.resetcam) self.bookingMode = True
infoFile = os.path.join(outSubDir, 'p{}_info.txt'.format(patient)) meanFile = os.path.join(outSubDir, 'p{}_dE.txt'.format(patient)) with open(infoFile, 'w') as fid: fid.write('{:<30}{}\n'.format('file', nm)) fid.write('{:<30}{:g}\n'.format('n', n)) fid.write('{:<30}{:g}\n'.format('M', M)) fid.write('{:<30}{:g}\n'.format('ignored', np.sum(anomalous))) fid.write('{:<30}{:g}\n'.format('EDGE_THRESHOLD', EDGE_THRESHOLD)) with open(meanFile, 'w') as fid: fid.write('{:<20}{:<20}'.format('m', 'dE')) videoFile0 = os.path.join(outSubDir, 'p{}_front.mp4'.format(patient)) video0 = Video(videoFile0, fps=4, backend='opencv') videoFile1 = os.path.join(outSubDir, 'p{}_back.mp4'.format(patient)) video1 = Video(videoFile1, fps=4, backend='opencv') videoFile2 = os.path.join(outSubDir, 'p{}_dE.mp4'.format(patient)) video2 = Video(videoFile2, fps=4, backend='opencv') # patient 033 # cam0 = {'pos': (-157, 128, 123), # 'focalPoint': (14.1, 75.8, 115), # 'viewup': (0.0728, 0.0926, 0.993), # 'distance': 179, # 'clippingRange': (110, 267)} # cam1 = {'pos': (181, 13.0, 130), # 'focalPoint': (14.1, 75.8, 115),
mapLAT[latIdx[i]] = latVals[i] infoFile = os.path.join(outSubDir, 'p{}_info.txt'.format(patient)) with open(infoFile, 'w') as fid: fid.write('{:<30}{}\n'.format('file', nm)) fid.write('{:<30}{:g}\n'.format('n', n)) fid.write('{:<30}{:g}\n'.format('M', M)) fid.write('{:<30}{:g}\n'.format('ignored', np.sum(anomalous))) fid.write('{:<30}{:g}\n'.format('EDGE_THRESHOLD', EDGE_THRESHOLD)) videoFile0 = os.path.join(outSubDir, 'p{}.mp4'.format(patient)) video0 = Video(videoFile0, duration=12, backend='opencv') # patient 033 # cam0 = {'pos': (-157, 128, 123), # 'focalPoint': (14.1, 75.8, 115), # 'viewup': (0.0728, 0.0926, 0.993), # 'distance': 179, # 'clippingRange': (110, 267)} # cam1 = {'pos': (181, 13.0, 130), # 'focalPoint': (14.1, 75.8, 115), # 'viewup': (-0.0213, 0.172, 0.985), # 'distance': 179, # 'clippingRange': (106, 273)} # patient 037