mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:46:30 +00:00
fix bugs
This commit is contained in:
@@ -69,8 +69,10 @@ public class DatasetExplorerEventHandler(DatasetExplorer datasetExplorer, IGalle
|
||||
}
|
||||
}
|
||||
|
||||
public Task Handle(ImageCreatedEvent notification, CancellationToken cancellationToken)
|
||||
public async Task Handle(ImageCreatedEvent imageCreatedEvent, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var (thumbnailDto, detections) = await galleryManager.CreateThumbnail(imageCreatedEvent.ImagePath, cancellationToken);
|
||||
if (thumbnailDto != null && detections != null)
|
||||
datasetExplorer.AddThumbnail(thumbnailDto, detections);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class GalleryManager(
|
||||
private readonly AnnotationConfig _annotationConfig = annotationConfig.Value;
|
||||
|
||||
private readonly string _thumbnailsCacheFile = Path.Combine(directoriesConfig.Value.ThumbnailsDirectory, Constants.THUMBNAILS_CACHE_FILE);
|
||||
public event ThumbnailsUpdatedEventHandler ThumbnailsUpdate;
|
||||
public event ThumbnailsUpdatedEventHandler? ThumbnailsUpdate;
|
||||
|
||||
|
||||
private readonly SemaphoreSlim _updateLock = new(1);
|
||||
@@ -125,7 +125,7 @@ public class GalleryManager(
|
||||
await File.WriteAllTextAsync(_thumbnailsCacheFile, labelsCacheStr);
|
||||
}
|
||||
|
||||
public async Task<ThumbnailDto?> CreateThumbnail(string imgPath, CancellationToken cancellationToken = default)
|
||||
public async Task<(ThumbnailDto? thumbnailDto, List<int>? classes)> CreateThumbnail(string imgPath, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -149,7 +149,7 @@ public class GalleryManager(
|
||||
{
|
||||
File.Delete(imgPath);
|
||||
logger.LogInformation($"No labels found for image {imgName}! Image deleted!");
|
||||
return null;
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
var labels = (await YoloLabel.ReadFromFile(labelName, cancellationToken))
|
||||
@@ -209,18 +209,19 @@ public class GalleryManager(
|
||||
var thumbnailName = Path.Combine(ThumbnailsDirectory.FullName, $"{Path.GetFileNameWithoutExtension(imgPath)}{Constants.THUMBNAIL_PREFIX}.jpg");
|
||||
bitmap.Save(thumbnailName, ImageFormat.Jpeg);
|
||||
|
||||
return new ThumbnailDto
|
||||
var thumbnailDto = new ThumbnailDto
|
||||
{
|
||||
ThumbnailPath = thumbnailName,
|
||||
ImagePath = imgPath,
|
||||
LabelPath = labelName,
|
||||
ImageDate = File.GetCreationTimeUtc(imgPath)
|
||||
};
|
||||
return (thumbnailDto, classes);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, e.Message);
|
||||
return null;
|
||||
return (null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,12 +242,12 @@ public class GalleryManager(
|
||||
|
||||
public interface IGalleryManager
|
||||
{
|
||||
event ThumbnailsUpdatedEventHandler ThumbnailsUpdate;
|
||||
event ThumbnailsUpdatedEventHandler? ThumbnailsUpdate;
|
||||
double ThumbnailsPercentage { get; set; }
|
||||
Task SaveLabelsCache();
|
||||
LabelInfo AddToCache(string imgPath, List<int> classes);
|
||||
ConcurrentDictionary<string, LabelInfo> LabelsCache { get; set; }
|
||||
Task<ThumbnailDto?> CreateThumbnail(string imgPath, CancellationToken cancellationToken = default);
|
||||
Task<(ThumbnailDto? thumbnailDto, List<int>? classes)> CreateThumbnail(string imgPath, CancellationToken cancellationToken = default);
|
||||
Task RefreshThumbnails();
|
||||
void ClearThumbnails();
|
||||
}
|
||||
Reference in New Issue
Block a user