|
@@ -8,7 +8,6 @@ using aipsvr.Services.DatabaseManagers;
|
|
|
using aipsvr.Utilities;
|
|
|
using Newtonsoft.Json;
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
-using NPOI.SS.Formula.Functions;
|
|
|
using SixLabors.ImageSharp;
|
|
|
using System;
|
|
|
using System.Collections.Concurrent;
|
|
@@ -6366,6 +6365,7 @@ namespace aipsvr.Services
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+
|
|
|
#region Develop Confirm
|
|
|
|
|
|
/// <summary>
|
|
@@ -6521,6 +6521,7 @@ namespace aipsvr.Services
|
|
|
var ultrasoundFileDataManager = databaseService.GetManager<IUltrasoundFileDataManager>();
|
|
|
var sameBatchLabelCaseDataManager = databaseService.GetManager<ISameBatchLabelCaseDataManager>();
|
|
|
var imageCategoryDataManager = databaseService.GetManager<IImageCategoryDataManager>();
|
|
|
+ var labelerGroupDataManager = databaseService.GetManager<ILabelerGroupDataManager>();
|
|
|
#region Update AssignedLabelCaseFile, AssignedLabelCaseGroup, AssignedLabelCase
|
|
|
foreach (var assignGroupId in assignedLabelGroupIds)
|
|
|
{
|
|
@@ -6604,6 +6605,28 @@ namespace aipsvr.Services
|
|
|
Name = session.Name,
|
|
|
};
|
|
|
await sameBatchLabelCaseDataManager.UpdateSameBatchLabelCaseAsync(sameBatchLabelCase);
|
|
|
+ #region Update Quantity
|
|
|
+ var requiredFrameTotal = 0;
|
|
|
+ foreach (var labelerInfo in sameBatchLabelCase.Labelers)
|
|
|
+ {
|
|
|
+ var assignLabelCaseFileList = await assignedLabelCaseDataManager.GetAssignedLabelCaseFilesByCaseIdAsync(labelerInfo.AssignedLabelCaseId);
|
|
|
+ foreach (var file in assignLabelCaseFileList)
|
|
|
+ {
|
|
|
+ if (file.IsVideo)
|
|
|
+ {
|
|
|
+ requiredFrameTotal += file.KeyFrameIndexList.Count;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ requiredFrameTotal++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var labelerGroup = await labelerGroupDataManager.GetLabelerGroupAsync(labelerInfo.Id, labelerInfo.InstitutionId, sameBatchLabelCase.ImageCategoryId);
|
|
|
+ labelerGroup.LabelCaseQuantityItem.Remaining += requiredFrameTotal;
|
|
|
+ labelerGroup.LabelCaseQuantityItem.Required += requiredFrameTotal;
|
|
|
+ await labelerGroupDataManager.UpdateLabelerGroupAsync(labelerGroup);
|
|
|
+ }
|
|
|
+ #endregion Update Quantity
|
|
|
var imageCase = await imageCategoryDataManager.GetImageCaseBySameBatchLabelCaseIdAsync(sameBatchLabelCase.Id);
|
|
|
if (imageCase.DevelopConfirmInfo.Status == DevelopConfirmStatus.WaitForConfirm)
|
|
|
{
|
|
@@ -6684,6 +6707,7 @@ namespace aipsvr.Services
|
|
|
var ultrasoundFileDataManager = databaseService.GetManager<IUltrasoundFileDataManager>();
|
|
|
var sameBatchLabelCaseDataManager = databaseService.GetManager<ISameBatchLabelCaseDataManager>();
|
|
|
var imageCategoryDataManager = databaseService.GetManager<IImageCategoryDataManager>();
|
|
|
+ var labelerGroupDataManager = databaseService.GetManager<ILabelerGroupDataManager>();
|
|
|
#region Update AssignedLabelCaseFile, AssignedLabelCaseGroup, AssignedLabelCase
|
|
|
List<long> confirmUltrasoundIdList = new List<long>();
|
|
|
foreach (var assignedLabelCaseFileId in assignedLabelCaseFileIdList)
|
|
@@ -6799,47 +6823,69 @@ namespace aipsvr.Services
|
|
|
Name = session.Name,
|
|
|
};
|
|
|
await sameBatchLabelCaseDataManager.UpdateSameBatchLabelCaseAsync(sameBatchLabelCase);
|
|
|
- var imageCase = await imageCategoryDataManager.GetImageCaseBySameBatchLabelCaseIdAsync(sameBatchLabelCase.Id);
|
|
|
- if (imageCase.DevelopConfirmInfo.Status == DevelopConfirmStatus.WaitForConfirm)
|
|
|
+ var requiredFrameTotal = 0;
|
|
|
+ #region Update Quantity
|
|
|
+ foreach (var labelerInfo in sameBatchLabelCase.Labelers)
|
|
|
{
|
|
|
- imageCase.DevelopConfirmInfo.Status = DevelopConfirmStatus.HasConfirmed;
|
|
|
- imageCase.DevelopConfirmInfo.ConfirmTime = DateTime.UtcNow;
|
|
|
- imageCase.DevelopConfirmInfo.Developer = new EntityBase
|
|
|
+ var assignLabelCaseFileList = await assignedLabelCaseDataManager.GetAssignedLabelCaseFilesByCaseIdAsync(labelerInfo.AssignedLabelCaseId);
|
|
|
+ foreach (var file in assignLabelCaseFileList)
|
|
|
+ {
|
|
|
+ if (file.IsVideo)
|
|
|
+ {
|
|
|
+ requiredFrameTotal += file.KeyFrameIndexList.Count;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ requiredFrameTotal++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var labelerGroup = await labelerGroupDataManager.GetLabelerGroupAsync(labelerInfo.Id, labelerInfo.InstitutionId, sameBatchLabelCase.ImageCategoryId);
|
|
|
+ labelerGroup.LabelCaseQuantityItem.Remaining += requiredFrameTotal;
|
|
|
+ labelerGroup.LabelCaseQuantityItem.Required += requiredFrameTotal;
|
|
|
+ await labelerGroupDataManager.UpdateLabelerGroupAsync(labelerGroup);
|
|
|
+ }
|
|
|
+ #endregion Update Quantity
|
|
|
+ }
|
|
|
+ var imageCase = await imageCategoryDataManager.GetImageCaseBySameBatchLabelCaseIdAsync(sameBatchLabelCase.Id);
|
|
|
+ if (imageCase.DevelopConfirmInfo.Status == DevelopConfirmStatus.WaitForConfirm)
|
|
|
+ {
|
|
|
+ imageCase.DevelopConfirmInfo.Status = DevelopConfirmStatus.HasConfirmed;
|
|
|
+ imageCase.DevelopConfirmInfo.ConfirmTime = DateTime.UtcNow;
|
|
|
+ imageCase.DevelopConfirmInfo.Developer = new EntityBase
|
|
|
+ {
|
|
|
+ Id = session.AccountId,
|
|
|
+ Name = session.Name,
|
|
|
+ };
|
|
|
+ await imageCategoryDataManager.UpdateImageCategoryAsync(imageCase);
|
|
|
+ }
|
|
|
+ var imageBatch = await imageCategoryDataManager.GetImageCategoryAsync(imageCase.Parent.Id);
|
|
|
+ if (imageBatch.DevelopConfirmInfo.Status == DevelopConfirmStatus.WaitForConfirm)
|
|
|
+ {
|
|
|
+ var imageCases = await imageCategoryDataManager.GetImageCategoriesByParentIdAsync(imageBatch.Id);
|
|
|
+ if (!imageCases.Any(x => x.DevelopConfirmInfo.Status == DevelopConfirmStatus.WaitForConfirm))
|
|
|
+ {
|
|
|
+ imageBatch.DevelopConfirmInfo.Status = DevelopConfirmStatus.HasConfirmed;
|
|
|
+ imageBatch.DevelopConfirmInfo.ConfirmTime = DateTime.UtcNow;
|
|
|
+ imageBatch.DevelopConfirmInfo.Developer = new EntityBase
|
|
|
{
|
|
|
Id = session.AccountId,
|
|
|
Name = session.Name,
|
|
|
};
|
|
|
- await imageCategoryDataManager.UpdateImageCategoryAsync(imageCase);
|
|
|
- }
|
|
|
- var imageBatch = await imageCategoryDataManager.GetImageCategoryAsync(imageCase.Parent.Id);
|
|
|
- if (imageBatch.DevelopConfirmInfo.Status == DevelopConfirmStatus.WaitForConfirm)
|
|
|
- {
|
|
|
- var imageCases = await imageCategoryDataManager.GetImageCategoriesByParentIdAsync(imageBatch.Id);
|
|
|
- if (!imageCases.Any(x => x.DevelopConfirmInfo.Status == DevelopConfirmStatus.WaitForConfirm))
|
|
|
+ await imageCategoryDataManager.UpdateImageCategoryAsync(imageBatch);
|
|
|
+ var imageCategory = await imageCategoryDataManager.GetImageCategoryAsync(imageBatch.Parent.Id);
|
|
|
+ if (imageCategory.DevelopConfirmInfo.Status == DevelopConfirmStatus.WaitForConfirm)
|
|
|
{
|
|
|
- imageBatch.DevelopConfirmInfo.Status = DevelopConfirmStatus.HasConfirmed;
|
|
|
- imageBatch.DevelopConfirmInfo.ConfirmTime = DateTime.UtcNow;
|
|
|
- imageBatch.DevelopConfirmInfo.Developer = new EntityBase
|
|
|
- {
|
|
|
- Id = session.AccountId,
|
|
|
- Name = session.Name,
|
|
|
- };
|
|
|
- await imageCategoryDataManager.UpdateImageCategoryAsync(imageBatch);
|
|
|
- var imageCategory = await imageCategoryDataManager.GetImageCategoryAsync(imageBatch.Parent.Id);
|
|
|
- if (imageCategory.DevelopConfirmInfo.Status == DevelopConfirmStatus.WaitForConfirm)
|
|
|
+ var imageBatches = await imageCategoryDataManager.GetImageCategoriesByParentIdAsync(imageCategory.Id);
|
|
|
+ if (!imageBatches.Any(x => x.DevelopConfirmInfo.Status == DevelopConfirmStatus.WaitForConfirm))
|
|
|
{
|
|
|
- var imageBatches = await imageCategoryDataManager.GetImageCategoriesByParentIdAsync(imageCategory.Id);
|
|
|
- if (!imageBatches.Any(x => x.DevelopConfirmInfo.Status == DevelopConfirmStatus.WaitForConfirm))
|
|
|
+ imageCategory.DevelopConfirmInfo.Status = DevelopConfirmStatus.HasConfirmed;
|
|
|
+ imageCategory.DevelopConfirmInfo.ConfirmTime = DateTime.UtcNow;
|
|
|
+ imageCategory.DevelopConfirmInfo.Developer = new EntityBase
|
|
|
{
|
|
|
- imageCategory.DevelopConfirmInfo.Status = DevelopConfirmStatus.HasConfirmed;
|
|
|
- imageCategory.DevelopConfirmInfo.ConfirmTime = DateTime.UtcNow;
|
|
|
- imageCategory.DevelopConfirmInfo.Developer = new EntityBase
|
|
|
- {
|
|
|
- Id = session.AccountId,
|
|
|
- Name = session.Name,
|
|
|
- };
|
|
|
- await imageCategoryDataManager.UpdateImageCategoryAsync(imageCategory);
|
|
|
- }
|
|
|
+ Id = session.AccountId,
|
|
|
+ Name = session.Name,
|
|
|
+ };
|
|
|
+ await imageCategoryDataManager.UpdateImageCategoryAsync(imageCategory);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -6893,6 +6939,7 @@ namespace aipsvr.Services
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
bool result = false;
|
|
|
int frameCount = 0;
|
|
|
List<int> keyFrameIndexList = new List<int>();
|
|
@@ -6906,47 +6953,59 @@ namespace aipsvr.Services
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- var archivedImage = await archivedImageDataManager.GetArchivedImageAsync(ultrasoundFile.ArchivedImageId);
|
|
|
- var videoPath = Path.Combine(CommonConfigManager.VideoTranscodingFolder, ultrasoundFile.ArchivedImageId.ToString(), archivedImage.OriginalName);
|
|
|
- try
|
|
|
- {
|
|
|
- result = opencvSimUtils.VideoFrameSimilarity(videoPath, 1, (float)similarityThreshold, intervalFrame, out frameCount, out keyFrameIndexListFromAI);
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
+ switch (assignedLabelCaseFile.VideoItem.FrameMode)
|
|
|
{
|
|
|
- Logger.WriteLineError($"VideoFrameSimilarity Exception:{ex}");
|
|
|
- }
|
|
|
- if (result)
|
|
|
- {
|
|
|
- if (frameCount != ultrasoundFile.FrameCount)
|
|
|
- {
|
|
|
- string msg = $"AssignLabelCaseAsync FrameCount is Different:FrameCount is {ultrasoundFile.FrameCount},FrameCount read by opencvSimUtils is {frameCount}";
|
|
|
- Logger.WriteLineError(msg);
|
|
|
- }
|
|
|
- if (keyFrameIndexListFromAI != null)
|
|
|
- {
|
|
|
- foreach (var keyFrame in keyFrameIndexListFromAI)
|
|
|
+ case FrameMode.EqualInterval:
|
|
|
+ var archivedImage = await archivedImageDataManager.GetArchivedImageAsync(ultrasoundFile.ArchivedImageId);
|
|
|
+ var videoPath = Path.Combine(CommonConfigManager.VideoTranscodingFolder, ultrasoundFile.ArchivedImageId.ToString(), archivedImage.OriginalName);
|
|
|
+ try
|
|
|
{
|
|
|
- keyFrameIndexList.Add(keyFrame - 1);//AI给出的结果是从索引1开始
|
|
|
+ result = opencvSimUtils.VideoFrameSimilarity(videoPath, 1, (float)similarityThreshold, intervalFrame, out frameCount, out keyFrameIndexListFromAI);
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- string msg = $"AssignLabelCaseAsync KeyFrameList From AI is Null";
|
|
|
- Logger.WriteLineError(msg);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- string msg = $"AssignLabelCaseAsync Error:VideoFrameSimilarity Error result is failed";
|
|
|
- Logger.WriteLineError(msg);
|
|
|
- }
|
|
|
- if (keyFrameIndexList.Count == 0)
|
|
|
- {
|
|
|
- for (int j = 0; j < ultrasoundFile.FrameCount; j += intervalFrame)
|
|
|
- {
|
|
|
- keyFrameIndexList.Add(j);
|
|
|
- }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Logger.WriteLineError($"VideoFrameSimilarity Exception:{ex}");
|
|
|
+ }
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ if (frameCount != ultrasoundFile.FrameCount)
|
|
|
+ {
|
|
|
+ string msg = $"AssignLabelCaseAsync FrameCount is Different:FrameCount is {ultrasoundFile.FrameCount},FrameCount read by opencvSimUtils is {frameCount}";
|
|
|
+ Logger.WriteLineError(msg);
|
|
|
+ }
|
|
|
+ if (keyFrameIndexListFromAI != null)
|
|
|
+ {
|
|
|
+ foreach (var keyFrame in keyFrameIndexListFromAI)
|
|
|
+ {
|
|
|
+ keyFrameIndexList.Add(keyFrame - 1);//AI给出的结果是从索引1开始
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string msg = $"AssignLabelCaseAsync KeyFrameList From AI is Null";
|
|
|
+ Logger.WriteLineError(msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string msg = $"AssignLabelCaseAsync Error:VideoFrameSimilarity Error result is failed";
|
|
|
+ Logger.WriteLineError(msg);
|
|
|
+ }
|
|
|
+ if (keyFrameIndexList.Count == 0)
|
|
|
+ {
|
|
|
+ for (int j = 0; j < ultrasoundFile.FrameCount; j += intervalFrame)
|
|
|
+ {
|
|
|
+ keyFrameIndexList.Add(j);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case FrameMode.MaxInterval:
|
|
|
+ for (int j = 0; j < ultrasoundFile.FrameCount; j += intervalFrame)
|
|
|
+ {
|
|
|
+ keyFrameIndexList.Add(j);
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
assignedLabelCaseFile.VideoItem.IntervalFrame = intervalFrame;
|
|
|
assignedLabelCaseFile.VideoItem.SimilarityThreshold = similarityThreshold;
|
|
@@ -6955,7 +7014,6 @@ namespace aipsvr.Services
|
|
|
videoItemDict.Add(ultrasoundFile.Id, assignedLabelCaseFile.VideoItem);
|
|
|
keyFrameDict.Add(ultrasoundFile.Id, assignedLabelCaseFile.KeyFrameIndexList);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -7010,47 +7068,59 @@ namespace aipsvr.Services
|
|
|
List<int> keyFrameIndexListFromAI = new List<int>();
|
|
|
|
|
|
var ultrasoundFile = await ultrasoundFileDataManager.GetUltrasoundFileAsync(assignedLabelCaseFile.UltrasoundFileId);
|
|
|
- var archivedImage = await archivedImageDataManager.GetArchivedImageAsync(ultrasoundFile.ArchivedImageId);
|
|
|
- var videoPath = Path.Combine(CommonConfigManager.VideoTranscodingFolder, ultrasoundFile.ArchivedImageId.ToString(), archivedImage.OriginalName);
|
|
|
- try
|
|
|
- {
|
|
|
- result = opencvSimUtils.VideoFrameSimilarity(videoPath, 1, (float)similarityThreshold, intervalFrame, out frameCount, out keyFrameIndexListFromAI);
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- Logger.WriteLineError($"VideoFrameSimilarity Exception:{ex}");
|
|
|
- }
|
|
|
- if (result)
|
|
|
+ switch (assignedLabelCaseFile.VideoItem.FrameMode)
|
|
|
{
|
|
|
- if (frameCount != ultrasoundFile.FrameCount)
|
|
|
- {
|
|
|
- string msg = $"AssignLabelCaseAsync FrameCount is Different:FrameCount is {ultrasoundFile.FrameCount},FrameCount read by opencvSimUtils is {frameCount}";
|
|
|
- Logger.WriteLineError(msg);
|
|
|
- }
|
|
|
- if (keyFrameIndexListFromAI != null)
|
|
|
- {
|
|
|
- foreach (var keyFrame in keyFrameIndexListFromAI)
|
|
|
+ case FrameMode.EqualInterval:
|
|
|
+ var archivedImage = await archivedImageDataManager.GetArchivedImageAsync(ultrasoundFile.ArchivedImageId);
|
|
|
+ var videoPath = Path.Combine(CommonConfigManager.VideoTranscodingFolder, ultrasoundFile.ArchivedImageId.ToString(), archivedImage.OriginalName);
|
|
|
+ try
|
|
|
{
|
|
|
- keyFrameIndexList.Add(keyFrame - 1);//AI给出的结果是从索引1开始
|
|
|
+ result = opencvSimUtils.VideoFrameSimilarity(videoPath, 1, (float)similarityThreshold, intervalFrame, out frameCount, out keyFrameIndexListFromAI);
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- string msg = $"AssignLabelCaseAsync KeyFrameList From AI is Null";
|
|
|
- Logger.WriteLineError(msg);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- string msg = $"AssignLabelCaseAsync Error:VideoFrameSimilarity Error result is failed";
|
|
|
- Logger.WriteLineError(msg);
|
|
|
- }
|
|
|
- if (keyFrameIndexList.Count == 0)
|
|
|
- {
|
|
|
- for (int j = 0; j < ultrasoundFile.FrameCount; j += intervalFrame)
|
|
|
- {
|
|
|
- keyFrameIndexList.Add(j);
|
|
|
- }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Logger.WriteLineError($"VideoFrameSimilarity Exception:{ex}");
|
|
|
+ }
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ if (frameCount != ultrasoundFile.FrameCount)
|
|
|
+ {
|
|
|
+ string msg = $"AssignLabelCaseAsync FrameCount is Different:FrameCount is {ultrasoundFile.FrameCount},FrameCount read by opencvSimUtils is {frameCount}";
|
|
|
+ Logger.WriteLineError(msg);
|
|
|
+ }
|
|
|
+ if (keyFrameIndexListFromAI != null)
|
|
|
+ {
|
|
|
+ foreach (var keyFrame in keyFrameIndexListFromAI)
|
|
|
+ {
|
|
|
+ keyFrameIndexList.Add(keyFrame - 1);//AI给出的结果是从索引1开始
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string msg = $"AssignLabelCaseAsync KeyFrameList From AI is Null";
|
|
|
+ Logger.WriteLineError(msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string msg = $"AssignLabelCaseAsync Error:VideoFrameSimilarity Error result is failed";
|
|
|
+ Logger.WriteLineError(msg);
|
|
|
+ }
|
|
|
+ if (keyFrameIndexList.Count == 0)
|
|
|
+ {
|
|
|
+ for (int j = 0; j < ultrasoundFile.FrameCount; j += intervalFrame)
|
|
|
+ {
|
|
|
+ keyFrameIndexList.Add(j);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case FrameMode.MaxInterval:
|
|
|
+ for (int j = 0; j < ultrasoundFile.FrameCount; j += intervalFrame)
|
|
|
+ {
|
|
|
+ keyFrameIndexList.Add(j);
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
assignedLabelCaseFile.VideoItem.IntervalFrame = intervalFrame;
|
|
|
assignedLabelCaseFile.VideoItem.SimilarityThreshold = similarityThreshold;
|