Beispiel #1
0
        public string Header(PointCloudTemp temp, PointCloudRecorderOptions options)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("# .PCD v.7 - Point Cloud Data file format");
            sb.AppendLine("VERSION .7");
            if (!options.RecordRGB)
            {
                sb.AppendLine("FIELDS x y z");
                sb.AppendLine("SIZE 4 4 4");
                sb.AppendLine("TYPE F F F");
                sb.AppendLine("COUNT 1 1 1");
            }
            else
            {
                sb.AppendLine("FIELDS x y z rgb");
                sb.AppendLine("SIZE 4 4 4 4");
                sb.AppendLine("TYPE F F F F");
                sb.AppendLine("COUNT 1 1 1 1");
            }

            sb.AppendLine("WIDTH 1");
            sb.AppendLine("HEIGHT " + temp.PointCount);
            sb.AppendLine("VIEWPOINT 0 0 0 1 0 0 0");
            sb.AppendLine("POINTS " + temp.PointCount);
            sb.Append("DATA ascii");
            return sb.ToString();
        }
Beispiel #2
0
        public string Header(PointCloudTemp temp, PointCloudRecorderOptions options)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("ply");
            sb.AppendLine("format ascii 1.0");
            sb.AppendLine(String.Concat("element vertex ", temp.PointCount));
            sb.AppendLine("property float x");
            sb.AppendLine("property float y");
            sb.AppendLine("property float z");
            sb.AppendLine("property uchar red");
            sb.AppendLine("property uchar green");
            sb.AppendLine("property uchar blue");
            sb.AppendLine("end_header");

            return sb.ToString();
        }
 string FileType.Header(PointCloudTemp temp, PointCloudRecorderOptions options)
 {
     return "";
 }
        /// <summary>
        /// Background thread method, process the temporary point cloud stack
        /// </summary>
        protected void ProcessStack(object sender, DoWorkEventArgs e)
        {
            while (this.RecorderState == PointCloudRecorderState.Recording || this.RecorderState == PointCloudRecorderState.Stopping)
            {
                if (this.TempClouds.Count > 0 && this.TempClouds.Peek() != null)
                {
                    PointCloudTemp tempCloud = this.TempClouds.Pop();
                    PointCloudRecorderOptions options = new PointCloudRecorderOptions()
                    {
                        RecordRGB = this.RecordRGB
                    };

                    string tempfile = Path.GetTempFileName();
                    using (var writer = new StreamWriter(tempfile))
                    {
                        foreach (PointCloudTemp temp in tempCloud.ProcessCloud())
                            writer.Write(this.ZipWriter.FileType.FormatLine(temp.Id, temp.XYZ, this.RecordRGB ? temp.RGB : null));
                    }

                    ZipArchiveEntry entry = this.ZipWriter.Archive.CreateEntry("frame-" + tempCloud.Id + "." + this.ZipWriter.FileType.Extension());
                    using (StreamWriter entryWriter = new StreamWriter(entry.Open()))
                    {
                        string fileHeader = this.ZipWriter.FileType.Header(tempCloud, options);
                        entryWriter.Write(fileHeader);

                        using (var reader = new StreamReader(tempfile))
                        {
                            while (!reader.EndOfStream)
                                entryWriter.WriteLine(reader.ReadLine());
                        }
                    }

                    this.FrameIds[tempCloud.Id] = tempCloud.PointCount;
                    this.CloudProcessingThread.ReportProgress(0, new Tuple<int, int>(this.TempClouds.Count, this.FrameIds.Count));
                }
                else if (this.RecorderState == PointCloudRecorderState.Stopping)
                {
                    ChangeState(PointCloudRecorderState.ProcessingClouds);
                    //this.PostProcessingThread = new Thread(new ThreadStart(PostProcess));
                    //this.PostProcessingThread.Start();

                    this.PostProcessingThread = new BackgroundWorker();
                    this.PostProcessingThread.WorkerReportsProgress = true;
                    this.PostProcessingThread.DoWork += PostProcessingThread_DoWork;
                    this.PostProcessingThread.ProgressChanged += PostProcessingThread_ProgressChanged;

                    this.PostProcessingThread.RunWorkerAsync();
                }
            }
        }