Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have made a ply file with the help of
this wrapper
.
How I made the ply file is shown below:
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");
Now I want to display it using the code:
private void Create3DViewPort()
var hVp3D = new HelixViewport3D();
var lights = new DefaultLights();
HViewPort.Children.Add(lights);
HViewPort.Children.Add(cloudPoints);
this.AddChild(HViewPort);
But I get the error at the line HViewPort.Children.Add(cloudPoints);
. It is saying that:
It cannot convert Systems.Windows.Media.Media3D.Model3D to Systems.Windows.Media.Media3D.Visual3D.
Can someone help me how I can display the point cloud using the helix toolkit?
I think it's not possible at the moment to show some ply files in the helix toolkit
(see Helix Wiki).
You can display a ply file with the code below, but you will not see the item you expect
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);
I don't know if this is the way but I can show the point cloud in the ply file.
The code:
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>
The previous advice really helped. However, it is necessary to create an instance of the importer class and in the XAML file the compiler asks you to place the model declaration before the camera is declared.
cpp file:
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>
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.