Пример #1
0
 public static void WriteTriangleList(float[] vertexes, float[] normals, float[] colors, string path)
 {
     int vertexCount = vertexes.Length / 4;
     MeshReaderWriter writer = new MeshReaderWriter(vertexCount, vertexCount / 3, path);
     for (int i = 0; i < vertexes.Length; i += 4)
     {
         int v = i / 4;
         writer.AddPoint(new float4(vertexes[i], vertexes[i + 1], vertexes[i + 2], 1), new float4(normals[3 * v], normals[3 * v + 1], normals[3 * v + 2], 1), new float4(colors[i], colors[i + 1], colors[i + 2], 1));
     }
     for (int i = 0; i < vertexCount; i += 3)
     {
         writer.AddFace(i, i + 1, i + 2);
     }
     writer.Close();
 }
Пример #2
0
        public void Process(BaseCameraApplication app)
        {
            CameraDataFilter filter = app.GetImageFilter();
            kernelCopyImage.Execute(new CLCalc.Program.MemoryObject[] {
                app.GetPrimaryDevice().GetDepthImage().GetMemoryObject(),
                filter.GetTextureImage(),
                filter.GetColorImage(),
                pointBuffer,
                colorBuffer}, new int[] { filter.GetDepthImage().Width, filter.GetDepthImage().Height });
            pointBuffer.ReadFromDeviceTo(points);
            int vertexCount = points.Length / 4;
            /*
            for (int i = 0; i < points.Length; i += 4)
            {

                float4 pt = new float4(points[i], points[i + 1], points[i + 2], points[i + 3]);
                if (pt.z>200.0&&pt.z < 2000.0f&&pt.w>100.0f)
                {
                    vertexCount++;
                }
            }
             * */
            colorBuffer.ReadFromDeviceTo(colors);
            string path = outputDir + "pointcloud" + counter.ToString("0000") + ".xyz";
            MeshReaderWriter writer = new MeshReaderWriter(vertexCount, 0, path);
            float minDepth = app.GetPrimaryDevice().GetMinDepth();
            float maxDepth = app.GetPrimaryDevice().GetMaxDepth();
            for (int i = 0; i < points.Length; i += 4)
            {
                float4 pt = new float4(points[i], points[i + 1], points[i + 2], points[i + 3]);
                float4 rgb = new float4(colors[i], colors[i + 1], colors[i + 2], colors[i + 3]);
                if (pt.z > minDepth && pt.z < maxDepth && pt.w > 100.0f)
                {
                    writer.AddPoint(pt, rgb);
                }
                else
                {
                    writer.AddPoint(new float4(), new float4());
                }
            }
            writer.Close();
            counter++;
        }