示例#1
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            if (lstFrames.SelectedItems.Count > 0)
            {
                List <ILogger> loggers = new List <ILogger>();
                loggers.Add(mainForm.ConsoleLogger);

                ProgressBarWnd wnd = new ProgressBarWnd();
                wnd.Text             = "Exporting frame...";
                wnd.ProgressBarStyle = ProgressBarStyle.Blocks;
                loggers.Add(wnd);

                MultipleLogger logger = new MultipleLogger(loggers);

                HotFrame hotFrame   = lstFrames.SelectedItems[0].Tag as HotFrame;
                var      rootFolder = project.Folder + "\\" + Project.MetadataFolder;
                var      annot      = hotFrame.Timestamp.ToString("HH_mm_ss");

                wnd.Worker.DoWork += delegate(object senderWorker, DoWorkEventArgs eWorker)
                {
                    MatlabExporter.ExportHotFrame(rootFolder, annot, hotFrame, MatlabExporterOptions.Overwrite, logger, wnd.CancelTokenSource.Token);
                };

                wnd.ShowDialog();
            }
        }
示例#2
0
        private void sampleLiDARToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (TimeLineWnd == null)
            {
                MessageBox.Show("Frame is not selected! Open the TimeLine window and select a frame.", "Frame is not selected", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            List <ILogger> loggers = new List <ILogger>();

            loggers.Add(ConsoleLogger);

            MainForm       form = (MainForm)this.MdiParent;
            ProgressBarWnd wnd  = new ProgressBarWnd();

            wnd.Text = "Export LiDAR frames...";
            loggers.Add(wnd);

            MultipleLogger logger = new MultipleLogger(loggers);

            wnd.WriteLine("Export LiDAR frames..");
            toolStripProgressBar.Visible = true;

            DateTime startTime = TimeLineWnd.CurrentTime;

            startTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute, startTime.Second);

            wnd.Worker.DoWork += delegate(object senderWorker, DoWorkEventArgs eWorker)
            {
                try
                {
                    for (int k = 0; k < 100; k++)
                    {
                        wnd.CancelTokenSource.Token.ThrowIfCancellationRequested();
                        DateTime currentTime = startTime.AddSeconds(k);
                        wnd.WriteLine("Time: " + currentTime.ToString("yyyy-MM-hh HH:mm:ss.fff"));
                        this.SampleLiDAR(currentTime, LiDARTransformType.None);
                    }
                }
                catch (OperationCanceledException)
                {
                    logger.WriteLineWarning("User cancelled!");
                    return;
                }
                catch (Exception ex)
                {
                    logger.WriteLineError("Error occured: " + ex.Message);
                }

                logger.WriteLineInfo("done.");
            };

            wnd.Worker.RunWorkerCompleted += delegate(object senderWorker, RunWorkerCompletedEventArgs eWorker)
            {
                toolStripProgressBar.Visible = false;
            };

            wnd.ShowDialog();
        }
        /// <summary>
        /// Convert Velodyne data stream into internal format
        /// </summary>
        /// <param name="velodyneDataStream"></param>
        private void ConvertVelodyneDataStream(VelodyneDataStream velodyneDataStream)
        {
            MainForm       form = (MainForm)this.MdiParent;
            ProgressBarWnd wnd  = new ProgressBarWnd();

            wnd.Text = "Conversion: " + velodyneDataStream.ShortName;

            // create multiple logger
            List <ILogger> loggers = new List <ILogger>();

            loggers.Add(Logger);
            loggers.Add(wnd);
            MultipleLogger logger = new MultipleLogger(loggers);


            wnd.Worker.DoWork += delegate(object senderWorker, DoWorkEventArgs eWorker)
            {
                foreach (VelodyneDataLine dataLine in velodyneDataStream.DataLines)
                {
                    VelodyneConverter converter = VelodyneConverter.Create(form.Project.Folder + "\\" + velodyneDataStream.SubFolder + "\\" + dataLine.PcapLocation);

                    converter.ProgressReport += delegate(object senderReport, ProgressReportEventArgs argsReport)
                    {
                        logger.WriteLineInfo(argsReport.CurrentDataTime.ToString("yyy-MM-dd hh:mm:ss") + " " + argsReport.ReadBytes / 1000000 + " MB " + argsReport.Precentage.ToString("0.00") + "%" + Environment.NewLine);
                        logger.WriteProgress(argsReport.Precentage);
                    };

                    try
                    {
                        converter.Convert(wnd.CancelTokenSource.Token);
                    }
                    catch (OperationCanceledException)
                    {
                        // TODO: clean up files!
                    }
                    catch (Exception ex)
                    {
                        logger.WriteLineInfo("Error occured: " + ex.Message);
                    }
                }
            };

            wnd.Worker.RunWorkerCompleted += delegate(object senderWorker, RunWorkerCompletedEventArgs eWorker)
            {
                logger.WriteLineInfo("Conversion done.");
                logger.WriteProgress(100);
            };

            wnd.ShowDialog();
        }
        private void VelodyneStreamWnd_Load(object sender, EventArgs e)
        {
            MainForm         form      = (MainForm)this.MdiParent;
            VelodyneDataLine dataLine  = ((VelodyneDataLine)DataStream.DataLines[0]);
            String           pcapFile  = form.Project.Folder + "\\" + DataStream.SubFolder + "\\" + dataLine.PcapLocation;
            String           indexFile = VelodyneConverter.GetDefaultIndexFile(pcapFile);
            String           pointFile = VelodyneConverter.GetDefaultPointFile(pcapFile);

            ProgressBarWnd wnd = new ProgressBarWnd();

            wnd.Text           = "Load data stream: " + ((VelodyneDataStream)DataStream).ShortName;
            wnd.Worker.DoWork += delegate(object senderWorker, DoWorkEventArgs eWorker)
            {
                VelodyneReader.ClearProgressReport();
                VelodyneReader.ProgressReport += delegate(object senderReader, ProgressReportEventArgs argsReport)
                {
                    form.ReportProgress(argsReport.Precentage);
                    logger.WriteInfo(argsReport.CurrentDataTime.ToString("yyy-MM-dd hh:mm:ss") + " " + argsReport.ReadBytes / 1000000 + " MB " + argsReport.Precentage.ToString("0.00") + "%" + Environment.NewLine);
                    wnd.WriteLine(argsReport.CurrentDataTime.ToString("yyy-MM-dd hh:mm:ss") + " " + argsReport.ReadBytes / 1000000 + " MB " + argsReport.Precentage.ToString("0.00") + "%" + Environment.NewLine);

                    ((BackgroundWorker)senderWorker).ReportProgress(Convert.ToInt32(argsReport.Precentage));
                };

                veloReader = VelodyneReader.Open(((VelodyneDataStream)DataStream).SensorType, ReturnMode.StrongestReturnOnly, indexFile, pointFile);
            };

            wnd.Worker.RunWorkerCompleted += delegate(object senderWorker, RunWorkerCompletedEventArgs eWorker)
            {
                wnd.Close();
                form.ReportProgress(100);

                // set scroll bar
                idxStart = veloReader.Indeces.First();
                IndexData idxLast = veloReader.Indeces.Last();
                trackBar.Minimum = 0;
                trackBar.Maximum = Convert.ToInt32((idxLast.InternalTimeStamp.Ticks - idxStart.InternalTimeStamp.Ticks) / TimeSpan.TicksPerSecond);

                this.Text = "Streams: ";
                foreach (VelodyneDataStream ds in this.VeodyneDataStreams)
                {
                    this.Text += ds.ShortName + " ";
                }

                // set reader to the first index
                veloReader.Seek(idxStart);
                viewer.Render();
            };

            wnd.ShowDialog();
        }
示例#5
0
        private void extractFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <ILogger> loggers = new List <ILogger>();

            loggers.Add(ConsoleLogger);

            if (!Directory.Exists(Project.Folder + "\\" + Project.MetadataFolder))
            {
                Directory.CreateDirectory(Project.Folder + "\\" + Project.MetadataFolder);
            }
            var fileLogger = FileLogger.Create(Project.Folder + "\\" + Project.MetadataFolder + "\\metadata.txt", Project.Folder + "\\" + Project.MetadataFolder + "\\warnings.txt");

            loggers.Add(fileLogger);

            MainForm       form = (MainForm)this.MdiParent;
            ProgressBarWnd wnd  = new ProgressBarWnd();

            wnd.Text             = "Loading project...";
            wnd.ProgressBarStyle = ProgressBarStyle.Blocks;
            loggers.Add(wnd);

            MultipleLogger logger = new MultipleLogger(loggers);

            wnd.WriteLine("Start loading project: " + projectFolder);
            toolStripProgressBar.Visible = true;

            wnd.Worker.DoWork += delegate(object senderWorker, DoWorkEventArgs eWorker)
            {
                try
                {
                    MetadataBuilder.Create(Project, new MultipleLogger(loggers), wnd.CancelTokenSource.Token);
                }
                catch (OperationCanceledException)
                {
                }
                catch (Exception ex)
                {
                    logger.WriteLineError("Error occured: " + ex.Message);
                }
            };

            wnd.Worker.RunWorkerCompleted += delegate(object senderWorker, RunWorkerCompletedEventArgs eWorker)
            {
                toolStripProgressBar.Visible = false;
                fileLogger.Flush();
                fileLogger.Dispose();
            };

            wnd.ShowDialog();
        }
示例#6
0
        private void updateFileTimesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <ILogger> loggers = new List <ILogger>();

            loggers.Add(ConsoleLogger);

            MainForm       form = (MainForm)this.MdiParent;
            ProgressBarWnd wnd  = new ProgressBarWnd();

            wnd.Text = "Updating file times...";
            loggers.Add(wnd);

            MultipleLogger logger = new MultipleLogger(loggers);

            wnd.WriteLine("Start updating file times: " + projectFolder);
            toolStripProgressBar.Visible = true;

            wnd.Worker.DoWork += delegate(object senderWorker, DoWorkEventArgs eWorker)
            {
                try
                {
                    int k = 0;
                    foreach (DataStream stream in Project.DataStreams)
                    {
                        wnd.CancelTokenSource.Token.ThrowIfCancellationRequested();

                        logger.WriteProgress((++k / (double)Project.DataStreams.Count()) * 100.0);
                        if (stream is ImageDataStream)
                        {
                            logger.WriteLineInfo("Image data stream: " + stream.ShortName);
                            ImageDataStream imageDataStream = stream as ImageDataStream;
                            imageDataStream.UpdateFileTimes();
                        }

                        if (stream is VideoDataStream)
                        {
                            logger.WriteLineInfo("Image data stream: " + stream.ShortName);
                            VideoDataStream videoDataStream = stream as VideoDataStream;
                            videoDataStream.UpdateFileTimes();
                        }
                    }
                }
                catch (OperationCanceledException)
                {
                    logger.WriteLineWarning("User cancelled!");
                    return;
                }
                catch (Exception ex)
                {
                    logger.WriteLineError("Error occured: " + ex.Message);
                }

                logger.WriteLineInfo("done.");
            };

            wnd.Worker.RunWorkerCompleted += delegate(object senderWorker, RunWorkerCompletedEventArgs eWorker)
            {
                toolStripProgressBar.Visible = false;
            };

            wnd.ShowDialog();
        }
示例#7
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fdb    = new FolderBrowserDialog();
            DialogResult        result = fdb.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            projectFolder = fdb.SelectedPath;

            MainForm       form = (MainForm)this.MdiParent;
            ProgressBarWnd wnd  = new ProgressBarWnd();

            wnd.Text             = "Loading project...";
            wnd.ProgressBarStyle = ProgressBarStyle.Marquee;

            // create multiple logger
            List <ILogger> loggers = new List <ILogger>();

            loggers.Add(ConsoleLogger);
            loggers.Add(wnd);
            MultipleLogger logger = new MultipleLogger(loggers);

            logger.WriteLineInfo("Start loading project: " + projectFolder);

            wnd.Worker.DoWork += delegate(object senderWorker, DoWorkEventArgs eWorker)
            {
                try
                {
                    Project = Project.Load(projectFolder, logger);
                }
                catch (OperationCanceledException)
                {
                    logger.WriteLineInfo("Cancelled!");
                    eWorker.Cancel = true;
                }
                catch (Exception ex)
                {
                    logger.WriteLineInfo("Error occured: " + ex.Message);
                    eWorker.Cancel = true;
                }
            };

            wnd.Worker.RunWorkerCompleted += delegate(object senderWorker, RunWorkerCompletedEventArgs eWorker)
            {
                if (!eWorker.Cancelled)
                {
                    logger.WriteLineInfo("Project has been loaded!");
                    logger.WriteLineInfo("Project folder: " + this.Project.Folder);
                    logger.WriteLineInfo("No. of data streams: " + this.Project.DataStreams.Count());
                    MetadataBuilder.PrintSummary(this.Project, ConsoleLogger);
                    if (DataStreamWnd != null)
                    {
                        DataStreamWnd.UpdateUI();
                    }
                    form?.ReportProgress(100);
                    wnd.WriteProgress(100);
                    wnd.Close();
                }
            };

            wnd.ShowDialog();
        }