首页 > 解决方案 > 如何计算 3d 扫描的腹部周长?

问题描述

我使用 kinect v2 扫描一个人并将他/她的身体保存为 .ply、.obj、.stl 格式。我想从这个 3d 扫描身体计算腹部、二头肌等的周长。

我对所有想法持开放态度。

这是我在保存 .obj 文件时使用的代码。

public static void SaveAsciiObjMesh(Mesh mesh, TextWriter writer, bool flipAxes)
    {
        if (null == mesh || null == writer)
        {
            return;
        }

        var vertices = mesh.GetVertices();
        var normals = mesh.GetNormals();
        var indices = mesh.GetTriangleIndexes();

        // Check mesh arguments
        if (0 == vertices.Count || 0 != vertices.Count % 3 || vertices.Count != indices.Count)
        {
            throw new ArgumentException(Properties.Resources.InvalidMeshArgument);
        }

        // Write the header lines
        writer.WriteLine("#");
        writer.WriteLine("# OBJ file created by Microsoft Kinect Fusion");
        writer.WriteLine("#");

        // Sequentially write the 3 vertices of the triangle, for each triangle
        for (int i = 0; i < vertices.Count; i++)
        {
            var vertex = vertices[i];

            string vertexString = "v " + vertex.X.ToString(CultureInfo.InvariantCulture) + " ";

            if (flipAxes)
            {
                vertexString += (-vertex.Y).ToString(CultureInfo.InvariantCulture) + " " + (-vertex.Z).ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                vertexString += vertex.Y.ToString(CultureInfo.InvariantCulture) + " " + vertex.Z.ToString(CultureInfo.InvariantCulture);
            }

            writer.WriteLine(vertexString);
        }

        // Sequentially write the 3 normals of the triangle, for each triangle
        for (int i = 0; i < normals.Count; i++)
        {
            var normal = normals[i];

            string normalString = "vn " + normal.X.ToString(CultureInfo.InvariantCulture) + " ";

            if (flipAxes)
            {
                normalString += (-normal.Y).ToString(CultureInfo.InvariantCulture) + " " + (-normal.Z).ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                normalString += normal.Y.ToString(CultureInfo.InvariantCulture) + " " + normal.Z.ToString(CultureInfo.InvariantCulture);
            }

            writer.WriteLine(normalString);
        }

        // Sequentially write the 3 vertex indices of the triangle face, for each triangle
        // Note this is typically 1-indexed in an OBJ file when using absolute referencing!
        for (int i = 0; i < vertices.Count / 3; i++)
        {
            string baseIndex0 = ((i * 3) + 1).ToString(CultureInfo.InvariantCulture);
            string baseIndex1 = ((i * 3) + 2).ToString(CultureInfo.InvariantCulture);
            string baseIndex2 = ((i * 3) + 3).ToString(CultureInfo.InvariantCulture);

            string faceString = "f " + baseIndex0 + "//" + baseIndex0 + " " + baseIndex1 + "//" + baseIndex1 + " " + baseIndex2 + "//" + baseIndex2;
            writer.WriteLine(faceString);
        }
    }

我对图像处理真的没有经验,这是我学期作业的一部分。我病了,那天不能去上学,他们给我留下了最难的作业。至少对我来说最难。所以我需要一些关于它的想法。任何信息都会很棒。

标签: c#image-processing3dkinect

解决方案


只需将其导入 Autodesk 3D Max,它就具有内置体积、表面积、尺寸测量功能。或者,如果您想编写自己的程序,您可以使用获取表面三角测量的坐标。从未使用过 kinect,因此无法告诉您更多信息,除非您可以告诉我们您可以从模型中获得什么样的数据。


推荐阅读