public GPSDataStreamWnd(GPSDataStream dataStream, ILogger logger) { InitializeComponent(); this.dataStream = dataStream; this.MainForm = (MainForm)this.MdiParent; this.logger = logger; if ((dataStream.Positions == null) || dataStream.Positions.Count() == 0) { dataStream.LoadPositionFile(logger); } InitMap(); // seek to first GPS fix int i = 0; foreach (GPSPositionDataLine dataLine in dataStream.Positions) { if (dataLine.Quality == 1) { SetFrame(i); break; } i++; } }
public static void Create(Project project, ILogger logger, CancellationToken cancelletionToken = default(CancellationToken)) { logger.WriteLineInfo("----------------------------------"); logger.WriteLineInfo(" CAR METADATA file v0.1"); logger.WriteLineInfo(" The Ohio State University, 2017"); logger.WriteLineInfo("----------------------------------"); logger.WriteLineInfo(" "); logger.WriteLineInfo(" "); int pi = 0; foreach (DataStream dataStream in project.DataStreams) { pi++; cancelletionToken.ThrowIfCancellationRequested(); logger.WriteProgress((double)pi / (double)project.DataStreams.Count() * 100.0); dataStream.WriteMetadata(logger); } PrintSummary(project, logger); logger.WriteLineInfo(" "); logger.WriteLineInfo("Checking: "); // Checking Nikon's Novatel MARKTIMEA ImageDataStream nikonDataStream = (ImageDataStream)project.GetDataStreamByShortName("NIKON"); NovatelDataStream novatelDataStream = (NovatelDataStream)project.GetDataStreamByShortName("NOVATEL"); CheckEvents(nikonDataStream, novatelDataStream, EvenMarkerDataLine.MarkerEventPort.Unknown, logger); /*if ((nikonDataStream != null) && (novatelDataStream != null)) * { * if (nikonDataStream.NumOfFiles != novatelDataStream.MarkerEvents.Count()) * { * logger.WriteLineInfo("WRONG -- Number of #MARKTIME events from the Novatel ASC and the number of Nikon images are different!"); * logger.WriteLineWarning("Number of #MARKTIME events from the Novatel ASC and the number of Nikon images are different!"); * } * else * { * logger.WriteLineInfo("OK -- Number of #MARKTIME events from the Novatel ASC and the number of Nikon images !"); * } * }*/ // Checking Sony's Septentrio MARKTIME ImageDataStream son1DataStream = (ImageDataStream)project.GetDataStreamByShortName("SON1"); ImageDataStream son2DataStream = (ImageDataStream)project.GetDataStreamByShortName("SON2"); GPSDataStream septDataStream = (GPSDataStream)project.GetDataStreamByShortName("SEPT"); CheckEvents(son1DataStream, septDataStream, EvenMarkerDataLine.MarkerEventPort.EventA, logger); CheckEvents(son2DataStream, septDataStream, EvenMarkerDataLine.MarkerEventPort.EventB, logger); logger.Flush(); }
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(); } }
public static void CheckEvents(ImageDataStream imgDataStream, GPSDataStream gpsDataStream, EvenMarkerDataLine.MarkerEventPort port, ILogger logger) { if ((imgDataStream != null) && (gpsDataStream != null)) { if (imgDataStream.DataLines.Count() == 0) { return; } DateTime startTime = imgDataStream.StartTime - TimeSpan.FromMinutes(5); DateTime endTime = imgDataStream.EndTime + TimeSpan.FromMinutes(5); int numMarkers = 0; // check events and image numbers foreach (EvenMarkerDataLine evnt in gpsDataStream.MarkerEvents) { if ((startTime <= evnt.TimeStamp) && (evnt.TimeStamp <= endTime) && (evnt.Port == port)) { numMarkers++; } } if (imgDataStream.NumOfData != numMarkers) { logger.WriteLineWarning("Number of events from the " + gpsDataStream.ShortName + " and the number of " + imgDataStream.ShortName + " images are different!"); logger.WriteLineWarning("Number of images: " + imgDataStream.NumOfData); logger.WriteLineWarning("Number of markers: " + numMarkers); } else { logger.WriteLineInfo("OK -- Number of events from the " + gpsDataStream.ShortName + " and the number of " + imgDataStream.ShortName + " images are same"); logger.WriteLineInfo("Number of images: " + imgDataStream.NumOfData); logger.WriteLineInfo("Number of markers: " + numMarkers); } } }
private void syncToNOVATELToolStripMenuItem_Click(object sender, EventArgs e) { logger.WriteLineInfo(" "); logger.WriteLineInfo("Matching NIKON images to NOVATEL EVNT timestamps"); GPSDataStream novatel = project.DataStreams.Find(x => x.ShortName == "NOVATEL") as GPSDataStream; if (dataStream == null) { logger.WriteLineError("Cannot find NIKON datastream in the project!"); return; } DateTime startTime = dataStream.StartTime - TimeSpan.FromMinutes(2); DateTime endTime = dataStream.EndTime + TimeSpan.FromMinutes(2); int numMarkers = 0; // check events and image numbers foreach (EvenMarkerDataLine evnt in novatel.MarkerEvents) { if ((startTime <= evnt.TimeStamp) && (evnt.TimeStamp <= endTime)) { numMarkers++; } } if (dataStream.ShortName != "NIKON") { logger.WriteLineWarning("This is not NIKON stream! This method is developed for NIKON!"); } if (numMarkers != novatel.MarkerEvents.Count) { logger.WriteLineError("No of marker events does not match with NIKON images!"); logger.WriteLineError("# of NIKON images: " + dataStream.DataLines.Count); logger.WriteLineError("# of NOVATEL EVNT: " + novatel.MarkerEvents.Count); return; } logger.WriteLineInfo("# of NIKON images: " + dataStream.DataLines.Count); logger.WriteLineInfo("# of NOVATEL EVNT: " + novatel.MarkerEvents.Count); logger.WriteLineInfo("Start dT [s]=" + (new TimeSpan(dataStream.DataLines[0].TimeStamp.Ticks - novatel.MarkerEvents[0].TimeStamp.Ticks)).TotalSeconds); //logger.WriteLineInfo("End dT [s]=" + (new TimeSpan(dataStream.DataLines[dataStream.DataLines.Count-1].TimeStamp.Ticks - novatel.MarkerEvents[dataStream.DataLines.Count-1].TimeStamp.Ticks)).TotalSeconds); double[] dts = new double[novatel.MarkerEvents.Count]; for (int i = 0; i < novatel.MarkerEvents.Count; i++) { if ((startTime <= novatel.MarkerEvents[i].TimeStamp) && (novatel.MarkerEvents[i].TimeStamp <= endTime)) { try { dts[i] = Math.Abs((new TimeSpan(dataStream.DataLines[0].TimeStamp.Ticks - novatel.MarkerEvents[0].TimeStamp.Ticks)).TotalSeconds); dataStream.DataLines[i].TimeStamp = novatel.MarkerEvents[i].TimeStamp; dataStream.DataLines[i].TimeType = TimeType.GPS; } catch (Exception ex) { throw ex; } } } this.dataStream.OrderDataLines(); logger.WriteLineInfo("Average dT [s]= " + dts.Average()); logger.WriteLineInfo("Maximum dT [s]= " + dts.Max()); logger.WriteLineInfo("Minimum dT [s]= " + dts.Min()); logger.WriteLineInfo("Done"); }
public async static Task Export(String filename, Project project, ILogger logger = null, CancellationToken cancelletionToken = default(CancellationToken)) { logger?.WriteLineInfo(""); logger?.WriteLineInfo("Saving project into MAT file!"); logger?.WriteLineInfo("MAT file location: " + filename); List <MLArray> mlList = new List <MLArray>(); int pi = 0; foreach (DataStream dataStream in project.DataStreams) { pi++; cancelletionToken.ThrowIfCancellationRequested(); logger?.WriteLineInfo("Exporting " + dataStream.ShortName + " datastream..."); logger?.WriteProgress((double)pi / (double)project.DataStreams.Count() * 100.0); MLStructure structDataStream = new MLStructure(dataStream.ShortName, new int[] { 1, 1 }); structDataStream["Name", 0] = new MLChar(null, dataStream.Name); structDataStream["ShortName", 0] = new MLChar(null, dataStream.ShortName); if (dataStream.DataLines.Count > 0) { // DataLines MLCell arrayDataLines = new MLCell("DataLines", new int[] { dataStream.DataLines.Count, 1 }); int k = 0; foreach (DataLine dataLine in dataStream.DataLines) { MLStructure structDataLine = new MLStructure(dataStream.ShortName, new int[] { 1, 1 }); structDataLine["Timestamp", 0] = new MLDouble("", new double[] { Utils.ConvertToUnixTimestamp(dataLine.TimeStamp) }, 1); structDataLine["TimestampC", 0] = ConvertDateTimeToMLDouble(dataLine.TimeStamp); if (dataLine is ImageDataLine) { structDataLine["ImageFileName", 0] = new MLChar(null, (dataLine as ImageDataLine).ImageFileName); } if (dataLine is VideoDataLine) { structDataLine["VideoFileName", 0] = new MLChar(null, (dataLine as VideoDataLine).VideoFileName); } arrayDataLines[k] = structDataLine; k++; } structDataStream["DataLines", 0] = arrayDataLines; } if (dataStream is GPSDataStream) { GPSDataStream gpsDataStream = dataStream as GPSDataStream; // Event Marker if (gpsDataStream.MarkerEvents.Count > 0) { MLCell arrayMarkerEvents = new MLCell("MarkerEvents", new int[] { gpsDataStream.MarkerEvents.Count, 1 }); int k = 0; foreach (EvenMarkerDataLine evnt in gpsDataStream.MarkerEvents) { MLStructure structEventMarkers = new MLStructure(dataStream.ShortName, new int[] { 1, 1 }); structEventMarkers["Timestamp", 0] = new MLDouble("", new double[] { (double)evnt.TimeStamp.Ticks }, 1); structEventMarkers["TimestampC", 0] = ConvertDateTimeToMLDouble(evnt.TimeStamp); structEventMarkers["Port", 0] = new MLChar(null, evnt.Port.ToString()); arrayMarkerEvents[k] = structEventMarkers; k++; } structDataStream["MarkerEvents", 0] = arrayMarkerEvents; } // Positions if (gpsDataStream.Positions.Count > 0) { double[][] points = new double[gpsDataStream.Positions.Count][]; int k = 0; foreach (GPSPositionDataLine pt in gpsDataStream.Positions) { points[k] = new double[5]; points[k][0] = Utils.ConvertToUnixTimestamp(pt.TimeStamp); points[k][1] = pt.Lat; points[k][2] = pt.Lon; points[k][3] = pt.Height; points[k][4] = pt.Quality; k++; } MLDouble arrayPoints = new MLDouble("Points", points); structDataStream["Points", 0] = arrayPoints; } } mlList.Add(structDataStream); } try { MatFileWriter mfw = new MatFileWriter(filename, mlList, false); } catch (Exception ex) { logger?.WriteLineError("Error occured: " + ex.ToString()); return; } logger?.WriteLineInfo("MAT file location: " + filename); logger?.WriteLineInfo("Done."); }
public void UpdateGraph() { GraphPane myPane = timeLineGraph.GraphPane; int dataStreamCount = 1; foreach (DataStream dataStream in project.DataStreams) { Color clr = Color.Black; if (dataStream is GPSDataStream) { clr = Color.Green; } if (dataStream is MicroStrainDataStream) { clr = Color.GreenYellow; } if (dataStream is ImageDataStream) { clr = Color.Blue; } if (dataStream is PointGreyDataStream) { clr = Color.DarkBlue; } if (dataStream is VideoDataStream) { clr = Color.Red; } if (dataStream is VelodyneDataStream) { clr = Color.DarkGray; } if (dataStream is GPSDataStream) { PointPairList ptList = new PointPairList(); GPSDataStream gpsDataStream = (GPSDataStream)dataStream; foreach (EvenMarkerDataLine evnt in gpsDataStream.MarkerEvents) { //if (evnt.Port == EvenMarkerDataLine.MarkerEventPort.EventB) //{ //ptList.Add(new PointPair((new TimeSpan(evnt.TimeStamp.Ticks)).TotalSeconds, dataStreamCount)); ptList.Add(new XDate(evnt.TimeStamp.ToOADate()), dataStreamCount); //} } if (ptList.Count() > 0) { TextObj text = new TextObj(dataStream.ShortName + " EVNT", ptList[0].X, ptList[0].Y, CoordType.AxisXYScale, AlignH.Right, AlignV.Center); text.FontSpec.Size = 8f; text.ZOrder = ZOrder.A_InFront; text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill.IsVisible = false; text.FontSpec.FontColor = clr; myPane.GraphObjList.Add(text); LineItem myCurve = myPane.AddCurve(dataStream.ShortName + " (" + dataStreamCount + ")", ptList, clr, SymbolType.Circle); myCurve.Line.IsVisible = false; myCurve.Symbol.Fill = new Fill(clr); myCurve.Symbol.Size = 2; dataStreamCount++; } } if (dataStream.DataLines.Count() == 0) { continue; } if (dataStream.DataLines[0] is LongFileDataLine) { bool isFirst = true; foreach (LongFileDataLine evnt in dataStream.DataLines) { PointPairList ptList = new PointPairList(); //ptList.Add(new PointPair((new TimeSpan(evnt.TimeStamp.Ticks)).TotalSeconds, dataStreamCount)); //ptList.Add(new PointPair((new TimeSpan(evnt.TimeStamp.Ticks)).TotalSeconds + evnt.Length.TotalSeconds, dataStreamCount)); ptList.Add(new XDate(evnt.TimeStamp.ToOADate()), dataStreamCount); ptList.Add(new XDate(evnt.TimeStamp.AddSeconds(evnt.Length.TotalSeconds).ToOADate()), dataStreamCount); LineItem lineItem; if (isFirst) { lineItem = myPane.AddCurve(dataStream.ShortName + " (" + dataStreamCount + ")", ptList, clr, SymbolType.Circle); isFirst = false; TextObj text = new TextObj(dataStream.ShortName, ptList[0].X, ptList[0].Y, CoordType.AxisXYScale, AlignH.Right, AlignV.Center); text.FontSpec.Size = 8f; text.ZOrder = ZOrder.A_InFront; text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill.IsVisible = false; text.FontSpec.FontColor = clr; myPane.GraphObjList.Add(text); } else { lineItem = myPane.AddCurve(null, ptList, clr, SymbolType.Circle); } lineItem.Line.Style = DashStyle.Solid; lineItem.Line.Width = 2; lineItem.Color = clr; lineItem.Symbol.Fill = new Fill(clr); lineItem.Symbol.Size = 3; } dataStreamCount++; } else { PointPairList ptList = new PointPairList(); foreach (DataLine evnt in dataStream.DataLines) { //ptList.Add(new PointPair((new TimeSpan(evnt.TimeStamp.Ticks)).TotalSeconds, dataStreamCount)); ptList.Add(new XDate(evnt.TimeStamp.ToOADate()), dataStreamCount); } LineItem myCurve = myPane.AddCurve(dataStream.ShortName + " (" + dataStreamCount + ")", ptList, clr, SymbolType.Circle); myCurve.Line.IsVisible = false; myCurve.Symbol.Fill = new Fill(clr); myCurve.Symbol.Size = 2; if (ptList.Count() > 0) { TextObj text = new TextObj(dataStream.ShortName, ptList[0].X, ptList[0].Y, CoordType.AxisXYScale, AlignH.Right, AlignV.Center); text.FontSpec.Size = 8f; text.ZOrder = ZOrder.A_InFront; text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill.IsVisible = false; text.FontSpec.FontColor = clr; myPane.GraphObjList.Add(text); dataStreamCount++; } } } // Set the XAxis to date type myPane.XAxis.Type = AxisType.Date; /*myPane.XAxis.Scale.MajorStep = 10; * myPane.XAxis.Scale.MajorUnit = DateUnit.Minute; * // tilt the x axis labels to an angle of 65 degrees * myPane.XAxis.Scale.FontSpec.Angle = 65; * myPane.XAxis.Scale.FontSpec.IsBold = false; * //myPane.XAxis.Scale.FontSpec.Size = 12; * myPane.XAxis.Scale.Format = "hh:mm:ss";*/ myPane.XAxis.Title.Text = "Time [UTC]"; myPane.YAxis.Title.Text = "Streams"; myPane.Legend.IsVisible = false; timeLineGraph.AxisChange(); timeLineGraph.Invalidate(); }