mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 22:36:31 +00:00
51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
namespace Azaion.Common.DTO;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
|
|
public class GpsMatchResult
|
|
{
|
|
public int Index { get; set; }
|
|
public string Image { get; set; } = null!;
|
|
public double Latitude { get; set; }
|
|
public double Longitude { get; set; }
|
|
public int KeyPoints { get; set; }
|
|
public int Rotation { get; set; }
|
|
public string MatchType { get; set; } = null!;
|
|
|
|
public static List<GpsMatchResult> ReadFromCsv(string csvFilePath)
|
|
{
|
|
var imageDatas = new List<GpsMatchResult>();
|
|
|
|
using var reader = new StreamReader(csvFilePath);
|
|
//read header
|
|
reader.ReadLine();
|
|
if (reader.EndOfStream)
|
|
return new List<GpsMatchResult>();
|
|
|
|
while (!reader.EndOfStream)
|
|
{
|
|
var line = reader.ReadLine();
|
|
if (string.IsNullOrWhiteSpace(line))
|
|
continue;
|
|
var values = line.Split(',');
|
|
if (values.Length == 6)
|
|
{
|
|
imageDatas.Add(new GpsMatchResult
|
|
{
|
|
Image = GetFilename(values[0]),
|
|
Latitude = double.Parse(values[1]),
|
|
Longitude = double.Parse(values[2]),
|
|
KeyPoints = int.Parse(values[3]),
|
|
Rotation = int.Parse(values[4]),
|
|
MatchType = values[5]
|
|
});
|
|
}
|
|
}
|
|
|
|
return imageDatas;
|
|
}
|
|
|
|
private static string GetFilename(string imagePath) =>
|
|
Path.GetFileNameWithoutExtension(imagePath)
|
|
.Replace("-small", "");
|
|
} |