mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:46:30 +00:00
fix bug with annotation result gradient stops
add tensorrt engine
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
xmlns:controls1="clr-namespace:Azaion.Common.Controls;assembly=Azaion.Common"
|
||||
xmlns:controls2="clr-namespace:Azaion.Annotator.Controls;assembly=Azaion.Common"
|
||||
mc:Ignorable="d"
|
||||
xmlns:local="clr-namespace:Azaion.Annotator"
|
||||
Title="Azaion Annotator" Height="800" Width="1100"
|
||||
WindowState="Maximized"
|
||||
>
|
||||
@@ -49,6 +50,8 @@
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<local:GradientStyleSelector x:Key="GradientStyleSelector"/>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid Name="GlobalGrid"
|
||||
@@ -232,7 +235,6 @@
|
||||
Grid.Row="1"
|
||||
Grid.RowSpan="4"
|
||||
Background="Black"
|
||||
RowBackground="#252525"
|
||||
Foreground="White"
|
||||
RowHeaderWidth="0"
|
||||
Padding="2 0 0 0"
|
||||
@@ -241,7 +243,8 @@
|
||||
CellStyle="{DynamicResource DataGridCellStyle1}"
|
||||
IsReadOnly="True"
|
||||
CanUserResizeRows="False"
|
||||
CanUserResizeColumns="False">
|
||||
CanUserResizeColumns="False"
|
||||
RowStyleSelector="{StaticResource GradientStyleSelector}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Width="60"
|
||||
@@ -264,20 +267,6 @@
|
||||
<Setter Property="Background" Value="#252525"></Setter>
|
||||
</Style>
|
||||
</DataGridTextColumn.HeaderStyle>
|
||||
<DataGridTextColumn.CellStyle>
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<LinearGradientBrush StartPoint="0 0 " EndPoint="1 0">
|
||||
<GradientStop Offset="0.3" Color="{Binding Path=ClassColor0}" />
|
||||
<GradientStop Offset="0.5" Color="{Binding Path=ClassColor1}" />
|
||||
<GradientStop Offset="0.8" Color="{Binding Path=ClassColor2}" />
|
||||
<GradientStop Offset="0.99" Color="{Binding Path=ClassColor3}" />
|
||||
</LinearGradientBrush>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</DataGridTextColumn.CellStyle>
|
||||
</DataGridTextColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
@@ -328,7 +328,11 @@ public partial class Annotator
|
||||
|
||||
var existingResult = _formState.AnnotationResults.FirstOrDefault(x => x.Annotation.Time == time);
|
||||
if (existingResult != null)
|
||||
{
|
||||
_logger.LogInformation($"remove annotation {existingResult.TimeStr} {existingResult.ClassName}!");
|
||||
_formState.AnnotationResults.Remove(existingResult);
|
||||
}
|
||||
|
||||
|
||||
var dict = _formState.AnnotationResults
|
||||
.Select((x, i) => new { x.Annotation.Time, Index = i })
|
||||
@@ -339,7 +343,8 @@ public partial class Annotator
|
||||
.Select(x => x.Value + 1)
|
||||
.FirstOrDefault();
|
||||
|
||||
_formState.AnnotationResults.Insert(index, new AnnotationResult(_appConfig.AnnotationConfig.DetectionClassesDict, annotation));
|
||||
var annRes = new AnnotationResult(_appConfig.AnnotationConfig.DetectionClassesDict, annotation);
|
||||
_formState.AnnotationResults.Insert(index, annRes);
|
||||
}
|
||||
|
||||
private async Task ReloadFiles()
|
||||
@@ -565,6 +570,7 @@ public partial class Annotator
|
||||
await _mediator.Publish(new AnnotatorControlEvent(PlaybackControlEnum.Play), ct);
|
||||
}
|
||||
}
|
||||
|
||||
AddAnnotation(annotation);
|
||||
|
||||
if (FollowAI)
|
||||
@@ -574,7 +580,7 @@ public partial class Annotator
|
||||
$"{_appConfig.AnnotationConfig.DetectionClassesDict[det.ClassNumber].Name}: " +
|
||||
$"xy=({det.CenterX:F2},{det.CenterY:F2}), " +
|
||||
$"size=({det.Width:F2}, {det.Height:F2}), " +
|
||||
$"prob: {det.Probability*100:F0}%"));
|
||||
$"conf: {det.Confidence*100:F0}%"));
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
@@ -618,3 +624,42 @@ public partial class Annotator
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class GradientStyleSelector : StyleSelector
|
||||
{
|
||||
public override Style? SelectStyle(object item, DependencyObject container)
|
||||
{
|
||||
if (container is not DataGridRow row || row.DataContext is not AnnotationResult result)
|
||||
return null;
|
||||
|
||||
var style = new Style(typeof(DataGridRow));
|
||||
var brush = new LinearGradientBrush
|
||||
{
|
||||
StartPoint = new Point(0, 0),
|
||||
EndPoint = new Point(1, 0)
|
||||
};
|
||||
|
||||
var gradients = new List<GradientStop>();
|
||||
if (result.Colors.Count != 0)
|
||||
{
|
||||
var color = (Color)ColorConverter.ConvertFromString("#40DDDDDD");
|
||||
gradients = [new GradientStop(color, 0.99)];
|
||||
}
|
||||
else
|
||||
{
|
||||
var increment = 1.0 / result.Colors.Count;
|
||||
var currentStop = increment;
|
||||
foreach (var c in result.Colors)
|
||||
{
|
||||
var resultColor = c.Color.ToConfidenceColor(c.Confidence);
|
||||
brush.GradientStops.Add(new GradientStop(resultColor, currentStop));
|
||||
currentStop += increment;
|
||||
}
|
||||
}
|
||||
foreach (var gradientStop in gradients)
|
||||
brush.GradientStops.Add(gradientStop);
|
||||
|
||||
style.Setters.Add(new Setter(DataGridRow.BackgroundProperty, brush));
|
||||
return style;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,16 +38,19 @@ public partial class MapMatcher : UserControl
|
||||
SatelliteMap.Position = new PointLatLng(48.295985271707664, 37.14477539062501);
|
||||
SatelliteMap.MultiTouchEnabled = true;
|
||||
|
||||
GpsFiles.MouseDoubleClick += async (sender, args) =>
|
||||
GpsFiles.MouseDoubleClick += async (sender, args) => { await OpenGpsLocation(GpsFiles.SelectedIndex); };
|
||||
}
|
||||
|
||||
private async Task OpenGpsLocation(int gpsFilesIndex)
|
||||
{
|
||||
var media = GpsFiles.Items[gpsFilesIndex] as MediaFileInfo;
|
||||
var ann = _annotations.GetValueOrDefault(Path.GetFileNameWithoutExtension(media.Name));
|
||||
GpsImageEditor.Background = new ImageBrush
|
||||
{
|
||||
var media = (GpsFiles.SelectedItem as MediaFileInfo)!;
|
||||
var ann = _annotations.GetValueOrDefault(Path.GetFileNameWithoutExtension(media.Name));
|
||||
GpsImageEditor.Background = new ImageBrush
|
||||
{
|
||||
ImageSource = await Path.Combine(_currentDir, ann.Name).OpenImage()
|
||||
};
|
||||
SatelliteMap.Position = new PointLatLng(ann.Lat, ann.Lon);
|
||||
ImageSource = await Path.Combine(_currentDir, ann.Name).OpenImage()
|
||||
};
|
||||
if (ann.Lat != 0 && ann.Lon != 0)
|
||||
SatelliteMap.Position = new PointLatLng(ann.Lat, ann.Lon);
|
||||
}
|
||||
|
||||
private void GpsFilesContextOpening(object sender, ContextMenuEventArgs e)
|
||||
@@ -104,8 +107,11 @@ public partial class MapMatcher : UserControl
|
||||
_allMediaFiles = mediaFiles;
|
||||
GpsFiles.ItemsSource = new ObservableCollection<MediaFileInfo>(_allMediaFiles);
|
||||
var annotations = SetFromCsv(mediaFiles);
|
||||
Cursor = Cursors.Wait;
|
||||
await Task.Delay(TimeSpan.FromSeconds(10));
|
||||
SetMarkers(annotations);
|
||||
Cursor = Cursors.Arrow;
|
||||
await OpenGpsLocation(0);
|
||||
}
|
||||
|
||||
private Dictionary<string, Annotation> SetFromCsv(List<MediaFileInfo> mediaFiles)
|
||||
@@ -117,7 +123,9 @@ public partial class MapMatcher : UserControl
|
||||
}).ToDictionary(x => Path.GetFileNameWithoutExtension(x.OriginalMediaName));
|
||||
|
||||
var csvResults = GpsCsvResult.ReadFromCsv(Constants.CSV_PATH);
|
||||
var csvDict = csvResults.ToDictionary(x => x.Image);
|
||||
var csvDict = csvResults
|
||||
.Where(x => x.MatchType == "stitched")
|
||||
.ToDictionary(x => x.Image);
|
||||
foreach (var ann in _annotations)
|
||||
{
|
||||
var csvRes = csvDict.GetValueOrDefault(ann.Key);
|
||||
@@ -137,7 +145,7 @@ public partial class MapMatcher : UserControl
|
||||
|
||||
var firstAnnotation = annotations.FirstOrDefault();
|
||||
SatelliteMap.Position = new PointLatLng(firstAnnotation.Value.Lat, firstAnnotation.Value.Lon);
|
||||
foreach (var ann in annotations)
|
||||
foreach (var ann in annotations.Where(x => x.Value.Lat != 0 && x.Value.Lon != 0))
|
||||
{
|
||||
var marker = new GMapMarker(new PointLatLng(ann.Value.Lat, ann.Value.Lon));
|
||||
var circle = new CircleVisual(marker, System.Windows.Media.Brushes.Blue)
|
||||
@@ -147,6 +155,6 @@ public partial class MapMatcher : UserControl
|
||||
marker.Shape = circle;
|
||||
SatelliteMap.Markers.Add(marker);
|
||||
}
|
||||
|
||||
SatelliteMap.ZoomAndCenterMarkers(null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user