mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 13:26:30 +00:00
add gps matcher service
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
namespace Azaion.Common.DTO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
public class GpsMatchResult
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public string Image { get; set; }
|
||||
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; }
|
||||
|
||||
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", "");
|
||||
}
|
||||
Reference in New Issue
Block a user