/// <summary> /// write ply file from depth data and colorInfoPixels (color info) /// </summary> /// <param name="colorInfoPixels"></param> /// <param name="depthData"></param> /// <param name="path"></param> /// <param name="fileName"></param> /// <returns></returns> public static bool Write_OBJ_Test(PointCloud pc, PointCloud pcTest, string path, string fileName) { StringBuilder sb = new StringBuilder(); List <string> lines = new List <string>(); lines.Add("####"); lines.Add("#"); lines.Add("# OBJ File Generated by OpenTKLib"); lines.Add("#"); lines.Add("####"); lines.Add("#"); lines.Add("# Vertices: " + pc.Vectors.GetLength(0).ToString()); lines.Add("#"); lines.Add("####"); if (pc.Colors != null && pc.Colors.GetLength(0) == pc.Vectors.GetLength(0)) { for (int i = 0; i < pc.Vectors.GetLength(0); ++i) { Vector3 v = pc.Vectors[i]; Vector3 vTest = pcTest.Vectors[i]; Vector3 colorVal = pc.Colors[i]; string coordinate = v.X.ToString(CultureInfo) + " " + v.Y.ToString(CultureInfo) + " " + v.Z.ToString(CultureInfo); string color = string.Empty; if (colorVal != null) { // 255F color = colorVal[0].ToString(CultureInfo) + " " + colorVal[1].ToString(CultureInfo) + " " + colorVal[2].ToString(CultureInfo) + " "; } //string color = pixels[displayIndex].ToString() + " " + pixels[displayIndex + 1].ToString() + " " + pixels[displayIndex + 2].ToString() + " " + pixels[displayIndex + 3].ToString(); lines.Add("v " + coordinate + " " + color); string coordinate1 = vTest.X.ToString(CultureInfo) + " " + vTest.Y.ToString(CultureInfo) + " " + vTest.Z.ToString(CultureInfo); lines.Add("- " + coordinate1); } } else { for (int i = 0; i < pc.Vectors.GetLength(0); ++i) { Vector3 v = pc.Vectors[i]; Vector3 vTest = pcTest.Vectors[i]; string coordinate = v.X.ToString(CultureInfo) + " " + v.Y.ToString(CultureInfo) + " " + v.Z.ToString(CultureInfo); string coordinate1 = vTest.X.ToString(CultureInfo) + " " + vTest.Y.ToString(CultureInfo) + " " + vTest.Z.ToString(CultureInfo); //string color = pixels[displayIndex].ToString() + " " + pixels[displayIndex + 1].ToString() + " " + pixels[displayIndex + 2].ToString() + " " + pixels[displayIndex + 3].ToString(); lines.Add("v " + coordinate); lines.Add("-" + coordinate1); } } System.IO.File.WriteAllLines(path + "\\" + fileName, lines); return(true); }
/// <summary> /// at least source points should be non zero /// </summary> /// <param name="myPCLTarget"></param> /// <param name="myPCLSource"></param> /// <param name="myPCLResult"></param> /// <param name="changeColor"></param> public void Show3PointCloudOpenGL(PointCloud myPCLSource, PointCloud myPCLTarget, PointCloud myPCLResult, bool changeColor) { this.OpenGLControl.RemoveAllModels(); //target in green if (myPCLTarget != null) { if (changeColor) { myPCLTarget.Colors = ColorExtensions.ToVector3Array(myPCLTarget.Vectors.GetLength(0), 0, 255, 0); } ShowPointCloudOpenGL(myPCLTarget, false); } if (myPCLSource != null) { //source in white if (changeColor) { myPCLSource.Colors = ColorExtensions.ToVector3Array(myPCLSource.Vectors.GetLength(0), 255, 255, 255); } ShowPointCloudOpenGL(myPCLSource, false); } if (myPCLResult != null) { //transformed in red if (changeColor) { myPCLResult.Colors = ColorExtensions.ToVector3Array(myPCLResult.Vectors.GetLength(0), 255, 0, 0); } ShowPointCloudOpenGL(myPCLResult, false); } }
/// <summary> /// write ply file from depth data and colorInfoPixels (color info) /// </summary> /// <param name="colorInfoPixels"></param> /// <param name="depthData"></param> /// <param name="path"></param> /// <param name="fileName"></param> /// <returns></returns> public static bool ToObjFile(PointCloud pc, string path, string fileName) { ToObjFile(pc, path + "\\" + fileName); return(true); }
public void CalculateCentroidBoundingBox() { this.CalculateCentroid(); PointCloud.BoundingBox(this, ref boundingBoxMax, ref boundingBoxMin); centroidAndBoundingBoxCalculated = true; }