Exemplo n.º 1
0
 def startVideo(self):
     self.win2img = vtk.vtkWindowToImageFilter()
     self.win2img.SetInput(self.win)
     self.videoWriter = vtk.vtkFFMPEGWriter()
     self.videoWriter.SetFileName('/home/zxie/Desktop/blockworld.avi')
     self.videoWriter.SetInputConnection(self.win2img.GetOutputPort())
     self.videoWriter.SetRate(10)  # 10 fps
     self.videoWriter.SetQuality(2)  # Highest
     self.videoWriter.SetBitRate(1000)  # kilobits/s
     self.videoWriter.SetBitRateTolerance(1000)
     self.videoWriter.Start()
Exemplo n.º 2
0
 def startVideo(self):
     self.win2img = vtk.vtkWindowToImageFilter()
     self.win2img.SetInput(self.win)
     self.videoWriter = vtk.vtkFFMPEGWriter()
     self.videoWriter.SetFileName('/home/zxie/Desktop/blockworld.avi')
     self.videoWriter.SetInputConnection(self.win2img.GetOutputPort())
     self.videoWriter.SetRate(10)  # 10 fps
     self.videoWriter.SetQuality(2)  # Highest
     self.videoWriter.SetBitRate(1000)  # kilobits/s
     self.videoWriter.SetBitRateTolerance(1000)
     self.videoWriter.Start()
Exemplo n.º 3
0
    def display(self, animate=True, movie=False, filename=None):
        print 'TraubDataVis.display::Start: animate: %d, movie: %d, filename: %s' % (animate, movie, filename)
        self.camera = vtk.vtkCamera() #self.renderer.GetActiveCamera()
        self.camera.SetPosition(0.0, 500.0, -1200.0)
        self.camera.SetFocalPoint(0, 0, -1200)
        self.camera.ComputeViewPlaneNormal()
        self.renderer.SetActiveCamera(self.camera)
        self.renderer.ResetCamera()
        if not animate:
            self.interactor = vtk.vtkRenderWindowInteractor()
            self.interactor.SetRenderWindow(self.renwin)
            self.interactor.Initialize()
            self.interactor.Start()
        else:
            # self.renwin.SetOffScreenRendering(True)
            # self.win2image = vtk.vtkWindowToImageFilter()
            # self.win2image.SetInput(self.renwin)
	    if movie:
                self.moviewriter = vtk.vtkFFMPEGWriter()
                self.moviewriter.SetQuality(2)
                self.moviewriter.SetRate(10)
                self.moviewriter.SetInputConnection(self.win2image.GetOutputPort())
                self.moviewriter.SetFileName(filename)
                self.moviewriter.Start()
            else:
                pass
                # self.imwriter = vtk.vtkPNGWriter()
                # self.imwriter.SetInputConnection(self.win2image.GetOutputPort())
            time = 0.0
            for ii in range(self.datahandler.num_time):
                time += self.datahandler.plotdt
                print 'Time:', time
                for cellclass in self.datahandler.cellclass:
                    vm = self.datahandler.get_vm(cellclass, ii)
                    if (vm is None) or len(vm) == 0:
                        # print 'Error:', cellclass, vm
                        continue
                    self.positionSource[cellclass].GetPointData().SetScalars(vtknp.numpy_to_vtk(vm))
                self.renwin.Render()
                # self.win2image.Modified()
                if movie:
                    self.moviewriter.Write()
                else:
                    pass
                    # self.imwriter.SetFileName('frame_%05d.png' % (ii))
                    # self.imwriter.Write()
            if movie:
                self.moviewriter.End()
        print 'TraubDataVis.display::End'