c#中的Helix Toolkit显示层点云



我在这个包装器的帮助下制作了一个ply文件。

我是如何制作ply文件的,如下所示:

using (var frames = pipeline.WaitForFrames())
{
var colorFrame = frames.ColorFrame.DisposeWith(frames);
var depthFrame = frames.DepthFrame.DisposeWith(frames);
var points = pc.Process(depthFrame).As<Points>();
// We colorize the depth frame for visualization purposes
var colorizedDepth = colorizer.Process<VideoFrame>(depthFrame).DisposeWith(frames);
// CopyVertices is extensible, any of these will do:
var vertices = new float[points.Count * 3];
// var vertices = new Intel.RealSense.Math.Vertex[points.Count];
// var vertices = new UnityEngine.Vector3[points.Count];
// var vertices = new System.Numerics.Vector3[points.Count]; // SIMD
// var vertices = new GlmSharp.vec3[points.Count];
//  var vertices = new byte[points.Count * 3 * sizeof(float)];
points.CopyVertices(vertices);
points.ExportToPLY("pointcloud.ply", colorFrame);
// Render the frames.
cloudPoints = importer.Load(@"pointcloud.ply");
}

现在我想使用代码显示它:

private void Create3DViewPort()
{
var hVp3D = new HelixViewport3D();
var lights = new DefaultLights();
HViewPort.Children.Add(lights);
HViewPort.Children.Add(cloudPoints);
this.AddChild(HViewPort);
}

但我在HViewPort.Children.Add(cloudPoints);行得到错误。据说:

它无法转换系统。Windows。媒体Media3D。Model3D到系统。Windows。媒体Media3D。Visual3D。

有人能帮我如何使用螺旋工具包显示点云吗?

我认为目前不可能在helix工具包中显示一些ply文件(参见Helix Wiki(。

你可以用下面的代码显示一个ply文件,但你不会看到你期望的项目

Model3DGroup group = new Model3DGroup();
var hpVp3D = new HelixViewport3D();
ModelVisual3D visual3D = new ModelVisual3D();
var lights = new DefaultLights();
ModelImporter importer = new ModelImporter();
Model3D element;
element = importer.Load(@"pointcloud.ply")
group.Children.Add(element);
visual3D.Content = group;
hVp3D.Children.Add(visual3D);
hVp3D.Children.Add(lights);
this.AddChild(hVp3D);

我不知道是否是这样,但我可以在ply文件中显示点云。代码:

Model3DGroup model1 = import.Load("pointcloud.ply");
model.Content = model1;

XAML:

<HelixToolkit:HelixViewport3D Grid.ColumnSpan="1" Grid.Column="1" Margin="2.4,1,0,-0.4" >
<HelixToolkit:HelixViewport3D.Camera>
<PerspectiveCamera />
</HelixToolkit:HelixViewport3D.Camera>
<HelixToolkit:DefaultLights></HelixToolkit:DefaultLights>
<ModelVisual3D x:Name="model"></ModelVisual3D>
</HelixToolkit:HelixViewport3D>

前面的建议真的很有帮助。但是,有必要创建importer类的实例,并且在XAML文件中,编译器要求您在声明相机之前放置模型声明。

cpp文件:

ModelImporter importer = new ModelImporter();
Model3DGroup model=importer.Load("model_file.ply");
MyModel.Content = model;

XAML:

<helix:HelixViewport3D x:Name="viewPort3d">
<ModelVisual3D x:Name="MyModel"/>
<helix:HelixViewport3D.Camera>
<PerspectiveCamera UpDirection="-0.00794080933244957, 0.909926622339627, 0.414693242656239"
LookDirection="49.636719684, -2387.8047, -29918.6652549283"
Position="-48.6367196, 5688.80470553634, 29917.665254"/>
</helix:HelixViewport3D.Camera>
</helix:HelixViewport3D>

相关内容

  • 没有找到相关文章

最新更新