Ejemplo n.º 1
0
        private void dataStreamList_DoubleClick(object sender, EventArgs e)
        {
            DataStream dataStream = (DataStream)dataStreamList.SelectedItem;

            if (dataStream.DataLines.Count == 0)
            {
                Logger.WriteLineWarning("No file for " + dataStream.ShortName);
                MessageBox.Show("No file for " + dataStream.ShortName, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (dataStreamList.SelectedItem is VideoDataStream)
            {
                VideoDataStream videoDataStream = dataStreamList.SelectedItem as VideoDataStream;
                VideoStreamWnd  wnd             = new VideoStreamWnd(videoDataStream, Logger);
                wnd.MdiParent = this.MdiParent;
                wnd.Show();
            }
            else if (dataStreamList.SelectedItem is ImageDataStream)
            {
                ImageDataStream imageDataStream = dataStreamList.SelectedItem as ImageDataStream;
                ImageStreamWnd  wnd             = new ImageStreamWnd(imageDataStream, Logger);
                wnd.MdiParent = this.MdiParent;
                wnd.Show();
            }
            else if (dataStreamList.SelectedItem is VelodyneDataStream)
            {
                VelodyneDataStream velodyneDataStream = dataStreamList.SelectedItem as VelodyneDataStream;
                if (velodyneDataStream.HasIndexedFiles() == false)
                {
                    DialogResult result = MessageBox.Show("No index file for " + dataStream.ShortName + "! Do you want to create index file?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (result == DialogResult.No)
                    {
                        return;
                    }
                    ConvertVelodyneDataStream(velodyneDataStream);
                }
                else
                {
                    VelodyneStreamWnd wnd = new VelodyneStreamWnd(velodyneDataStream, Logger);
                    wnd.MdiParent = this.MdiParent;
                    wnd.Show();
                }
            }
            else if (dataStreamList.SelectedItem is GPSDataStream)
            {
                GPSDataStream    gpsDataStream = dataStreamList.SelectedItem as GPSDataStream;
                GPSDataStreamWnd wnd           = new GPSDataStreamWnd(gpsDataStream, Logger);
                wnd.MdiParent = this.MdiParent;
                wnd.Show();
            }
        }
Ejemplo n.º 2
0
        public void SampleLiDAR(DateTime timeStamp, LiDARTransformType type = LiDARTransformType.None)
        {
            foreach (Form form in this.MdiChildren)
            {
                if ((!form.IsDisposed) && (form is VelodyneStreamWnd))
                {
                    VelodyneStreamWnd veloForm = form as VelodyneStreamWnd;
                    veloForm.SetFrameByTime(timeStamp);

                    List <VelodynePoint> pts = veloForm.GetPoints();
                    if (pts.Count() == 0)
                    {
                        continue;
                    }
                    double[,] ptsMat = Matrix.Create <double>(4, pts.Count(), 0);

                    for (int i = 0; i < pts.Count(); i++)
                    {
                        ptsMat[0, i] = pts[i].X;
                        ptsMat[1, i] = pts[i].Y;
                        ptsMat[2, i] = pts[i].Z;
                        ptsMat[3, i] = 1;
                    }

                    var veloStream = veloForm.DataStream as VelodyneDataStream;
                    if ((veloStream.Tp == null) && (type != LiDARTransformType.None))
                    {
                        this.ConsoleLogger.WriteLineWarning("Transfromation matrix for " + veloStream.ShortName + " is not avaialble!");
                        continue;
                    }

                    double[,] convPts = null;

                    if (type == LiDARTransformType.None)
                    {
                        convPts = ptsMat;
                    }
                    else if (type == LiDARTransformType.TransformToPlatform)
                    {
                        convPts = veloStream.Tp.Dot(ptsMat);
                    }
                    else if (type == LiDARTransformType.TransformToGlobal)
                    {
                        throw new NotImplementedException();
                    }

                    var hotFrameSubfix = timeStamp.ToString("HHmmss");
                    var saveTo         = this.Project.Folder + "\\" + Project.LiDARFrameFolder + "\\LiDAR_" + hotFrameSubfix + "_" + veloStream.ShortName + ".txt";

                    TextWriter tw = new StreamWriter(saveTo);
                    for (int i = 0; i < convPts.Columns(); i++)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            tw.Write(convPts[j, i] + " ");
                        }
                        tw.Write(pts[i].Intensity);
                        tw.WriteLine();
                    }
                    tw.Close();
                }
            }
        }