mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 18:36:32 +00:00
fix id problems with day/winter switch
This commit is contained in:
@@ -154,8 +154,25 @@ public class CanvasEditor : Canvas
|
||||
private void CanvasMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (SelectionState == SelectionState.NewAnnCreating)
|
||||
CreateDetectionControl(e.GetPosition(this));
|
||||
|
||||
{
|
||||
var endPos = e.GetPosition(this);
|
||||
_newAnnotationRect.Width = 0;
|
||||
_newAnnotationRect.Height = 0;
|
||||
var width = Math.Abs(endPos.X - _newAnnotationStartPos.X);
|
||||
var height = Math.Abs(endPos.Y - _newAnnotationStartPos.Y);
|
||||
if (width < MIN_SIZE || height < MIN_SIZE)
|
||||
return;
|
||||
|
||||
var time = GetTimeFunc();
|
||||
CreateDetectionControl(CurrentAnnClass, time, new CanvasLabel
|
||||
{
|
||||
Width = width,
|
||||
Height = height,
|
||||
X = Math.Min(endPos.X, _newAnnotationStartPos.X),
|
||||
Y = Math.Min(endPos.Y, _newAnnotationStartPos.Y)
|
||||
});
|
||||
}
|
||||
|
||||
SelectionState = SelectionState.None;
|
||||
e.Handled = true;
|
||||
}
|
||||
@@ -290,27 +307,18 @@ public class CanvasEditor : Canvas
|
||||
if (diff.Y < 0)
|
||||
SetTop(_newAnnotationRect, currentPos.Y);
|
||||
}
|
||||
|
||||
private void CreateDetectionControl(Point endPos)
|
||||
{
|
||||
_newAnnotationRect.Width = 0;
|
||||
_newAnnotationRect.Height = 0;
|
||||
var width = Math.Abs(endPos.X - _newAnnotationStartPos.X);
|
||||
var height = Math.Abs(endPos.Y - _newAnnotationStartPos.Y);
|
||||
if (width < MIN_SIZE || height < MIN_SIZE)
|
||||
return;
|
||||
|
||||
var time = GetTimeFunc();
|
||||
CreateDetectionControl(CurrentAnnClass, time, new CanvasLabel
|
||||
public void CreateDetections(TimeSpan time, IEnumerable<Detection> detections, List<DetectionClass> detectionClasses, Size videoSize)
|
||||
{
|
||||
foreach (var detection in detections)
|
||||
{
|
||||
Width = width,
|
||||
Height = height,
|
||||
X = Math.Min(endPos.X, _newAnnotationStartPos.X),
|
||||
Y = Math.Min(endPos.Y, _newAnnotationStartPos.Y)
|
||||
});
|
||||
var annClass = DetectionClass.FromYoloId(detection.ClassNumber, detectionClasses);
|
||||
var canvasLabel = new CanvasLabel(detection, RenderSize, videoSize, detection.Probability);
|
||||
CreateDetectionControl(annClass, time, canvasLabel);
|
||||
}
|
||||
}
|
||||
|
||||
public DetectionControl CreateDetectionControl(DetectionClass annClass, TimeSpan time, CanvasLabel canvasLabel)
|
||||
private void CreateDetectionControl(DetectionClass annClass, TimeSpan time, CanvasLabel canvasLabel)
|
||||
{
|
||||
var detectionControl = new DetectionControl(annClass, time, AnnotationResizeStart, canvasLabel.Probability)
|
||||
{
|
||||
@@ -323,7 +331,6 @@ public class CanvasEditor : Canvas
|
||||
Children.Add(detectionControl);
|
||||
CurrentDetections.Add(detectionControl);
|
||||
_newAnnotationRect.Fill = new SolidColorBrush(annClass.Color);
|
||||
return detectionControl;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -41,6 +41,15 @@ public class DetectionClass
|
||||
|
||||
[JsonIgnore]
|
||||
public SolidColorBrush ColorBrush => new(Color);
|
||||
|
||||
public static DetectionClass FromYoloId(int yoloId, List<DetectionClass> detectionClasses)
|
||||
{
|
||||
var cls = yoloId % 20;
|
||||
var photoMode = (PhotoMode)(yoloId - cls);
|
||||
var detClass = detectionClasses[cls];
|
||||
detClass.PhotoMode = photoMode;
|
||||
return detClass;
|
||||
}
|
||||
}
|
||||
|
||||
public enum PhotoMode
|
||||
|
||||
@@ -41,7 +41,7 @@ public static class ThrottleExt
|
||||
await Task.Delay(throttleTime ?? TimeSpan.FromMilliseconds(500), cancellationToken);
|
||||
await func();
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
_taskStates[actionId] = false;
|
||||
}
|
||||
|
||||
@@ -120,6 +120,8 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
||||
await SaveAnnotationInner(DateTime.UtcNow, annotation.OriginalMediaName, annotation.Time, annotation.ImageExtension, annotation.Detections.ToList(), SourceEnum.Manual, null,
|
||||
_authProvider.CurrentUser.Role, _authProvider.CurrentUser.Email, generateThumbnail: false, token);
|
||||
|
||||
// Manual save from Validators -> Validated -> stream: azaion-annotations-confirm
|
||||
// AI, Manual save from Operators -> Created -> stream: azaion-annotations
|
||||
private async Task<Annotation> SaveAnnotationInner(DateTime createdDate, string originalMediaName, TimeSpan time, string imageExtension, List<Detection> detections, SourceEnum source, Stream? stream,
|
||||
RoleEnum userRole,
|
||||
string createdEmail,
|
||||
@@ -132,8 +134,6 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
||||
var annotation = await _dbFactory.Run(async db =>
|
||||
{
|
||||
var ann = await db.Annotations.FirstOrDefaultAsync(x => x.Name == fName, token: token);
|
||||
// Manual Save from Validators -> Validated
|
||||
// otherwise Created
|
||||
status = userRole.IsValidator() && source == SourceEnum.Manual
|
||||
? AnnotationStatus.Validated
|
||||
: AnnotationStatus.Created;
|
||||
|
||||
Reference in New Issue
Block a user