def testDepthImageToPointcloud(self): ds = self.depthScanners['foreground'] camera = ds.view.camera() depth_img = ds.getDepthImage() depth_img_raw, _, _ = ds.getDepthImageAndPointCloud() depth_img_numpy = ds.getDepthImageAsNumpyArray() print "depth min %.3f, depth max = %.3f" %(np.min(depth_img_numpy), np.max(depth_img_numpy)) # self.changeDetectionImageVisualizer.setImage(depth_img) f = vtk.vtkDepthImageToPointCloud() f.SetCamera(camera) f.SetInputData(depth_img) f.Update() polyData = f.GetOutput() print "polyData.GetNumberOfPoints() = ", polyData.GetNumberOfPoints() view = self.changeDetectionPointCloudView vis.updatePolyData(polyData, 'depth_im_to_pointcloud')
def testDepthImageToPointcloud(self): ds = self.depthScanners['foreground'] camera = ds.view.camera() depth_img = ds.getDepthImage() depth_img_raw, _, _ = ds.getDepthImageAndPointCloud() depth_img_numpy = ds.getDepthImageAsNumpyArray() print "depth min %.3f, depth max = %.3f" % (np.min(depth_img_numpy), np.max(depth_img_numpy)) # self.changeDetectionImageVisualizer.setImage(depth_img) f = vtk.vtkDepthImageToPointCloud() f.SetCamera(camera) f.SetInputData(depth_img) f.Update() polyData = f.GetOutput() print "polyData.GetNumberOfPoints() = ", polyData.GetNumberOfPoints() view = self.changeDetectionPointCloudView vis.updatePolyData(polyData, 'depth_im_to_pointcloud')
kuni_depth_vtk = vnp.numpyToImageData(np.reshape( source_kuni, (480, 640, 1)), vtktype=vtk.VTK_FLOAT) #real simulation source_sim = vnp.numpyToImageData(np.reshape(source, (480, 640, 1)), vtktype=vtk.VTK_FLOAT) iterate = zip( [im_depth_sim_vtk, real_depth_vtk, kuni_depth_vtk, source_sim], ["depthsim", "realdepth", "kunidepth", "sim"]) for img, simtype in iterate: objects.loadObjectMeshes("/registration_result.yaml", renderer1, keyword=None) pc = vtk.vtkDepthImageToPointCloud() pc.SetInputData(img) pc.SetCamera(renderer.GetActiveCamera()) pc.ProduceColorScalarsOn() pc.ProduceVertexCellArrayOn() pc.CullFarPointsOn() pc.CullNearPointsOff() pc.Update() pcMapper = vtk.vtkPolyDataMapper() pcMapper.SetInputData(pc.GetOutput()) pcMapper.Update() pcActor = vtk.vtkActor() pcActor.SetMapper(pcMapper) renderer1.AddActor(pcActor) renWin.Render()