Browse Source

只要是视频分配,状态都会变为待确认
开发端增加标注帧模式显示,支持最高帧调整间隔。

felix 8 months ago
parent
commit
a42c791bc0

+ 2 - 1
aipdev/PendingAllocationImageBrowser.xaml.cs

@@ -145,7 +145,7 @@ namespace aipdev
                     {
                         Dispatcher.Invoke(() =>
                         {
-                            MessageBox.Show(Application.Current.MainWindow, $"当前组没有待确认分配的数据,即将关闭当前页面。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+                            MessageBox.Show(Application.Current.MainWindow, $"当前组没有待确认分配的数据,即将关闭当前页面。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                             ClearImages();
                             this.Hide();
                         });
@@ -194,6 +194,7 @@ namespace aipdev
             {
                 conculsions += $"固定间隔:{assignedLabelCaseFile.VideoItem.IntervalFrame}\r\n";
                 conculsions += $"相似度阈值:{assignedLabelCaseFile.VideoItem.SimilarityThreshold}\r\n";
+                conculsions += $"首张视频标注帧模式:{EnumHelper.GetEnumDescription(assignedLabelCaseFile.VideoItem.FrameMode)}\r\n";
                 conculsions += $"首张视频总帧数:{developConfirmGroupInfo.FirstAssignedLabelCaseFileFrameCount}\r\n";
                 conculsions += $"首张视频关键帧数量:{assignedLabelCaseFile.KeyFrameIndexList.Count()}";
             }

+ 21 - 5
aipdev/PendingAllocationImageViewer.xaml

@@ -541,19 +541,35 @@
                             <RowDefinition Height="Auto" />
                             <RowDefinition Height="Auto" />
                             <RowDefinition Height="Auto" />
+                            <RowDefinition Height="Auto" />
                         </Grid.RowDefinitions>
-
                         <TextBox
                             Grid.Row="0"
                             Grid.Column="0"
                             Margin="5"
                             HorizontalAlignment="Left"
                             Style="{StaticResource ReadOnlyTextBoxStyle}"
+                            Text="标注帧模式:"
+                            TextWrapping="Wrap" />
+                        <TextBox
+                            x:Name="FrameModeTextBox"
+                            Grid.Row="0"
+                            Grid.Column="1"
+                            Margin="5"
+                            HorizontalAlignment="Left"
+                            Style="{StaticResource ReadOnlyTextBoxStyle}"
+                            TextWrapping="Wrap" />
+                        <TextBox
+                            Grid.Row="1"
+                            Grid.Column="0"
+                            Margin="5"
+                            HorizontalAlignment="Left"
+                            Style="{StaticResource ReadOnlyTextBoxStyle}"
                             Text="固定间隔:"
                             TextWrapping="Wrap" />
                         <TextBox
                             x:Name="InvervalFrameTextBox"
-                            Grid.Row="0"
+                            Grid.Row="1"
                             Grid.Column="1"
                             Width="100"
                             Height="25"
@@ -564,7 +580,7 @@
                             FontSize="12"
                             TextWrapping="Wrap" />
                         <TextBox
-                            Grid.Row="1"
+                            Grid.Row="2"
                             Grid.Column="0"
                             Margin="5"
                             HorizontalAlignment="Left"
@@ -573,7 +589,7 @@
                             TextWrapping="Wrap" />
                         <TextBox
                             x:Name="SimilarityThresholdTextBox"
-                            Grid.Row="1"
+                            Grid.Row="2"
                             Grid.Column="1"
                             Width="100"
                             Height="25"
@@ -584,7 +600,7 @@
                             FontSize="12"
                             TextWrapping="Wrap" />
                         <Button
-                            Grid.Row="2"
+                            Grid.Row="3"
                             Grid.Column="0"
                             Margin="5"
                             HorizontalAlignment="Left"

+ 18 - 9
aipdev/PendingAllocationImageViewer.xaml.cs

@@ -94,7 +94,7 @@ namespace aipdev
                 var previewFileModels = await DeveloperManager.Shared.GetVideoPreviewFilesByGroupIdAsync(_currAssignedLabelCaseGroupId);
                 if (previewFileModels.Count == 0)
                 {
-                    MessageBox.Show(this, $"当前组没有待确认分配的数据,即将关闭当前页面。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+                    MessageBox.Show(this, $"当前组没有待确认分配的数据,即将关闭当前页面。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                     Close();
                     return;
                 }
@@ -149,7 +149,6 @@ namespace aipdev
                     return;
                 }
                 selectedPreFile.IsSelected = true;
-                selectedPreFile.IsMultiSelected = true;
                 _currentPreviewFileViewModel = selectedPreFile;
                 _currArchivedVideoData = selectedPreFile.VideoData;
                 _currArchivedImage = await DeveloperManager.Shared.GetArchivedImageAsync(selectedPreFile.ArchivedImageId);
@@ -162,14 +161,13 @@ namespace aipdev
                 KeyFrameCountTextBox.Text = _currentPreviewFileViewModel.KeyFrameIndexList.Count.ToString();
                 InvervalFrameTextBox.Text = _currentPreviewFileViewModel.VideoItem.IntervalFrame.ToString();
                 SimilarityThresholdTextBox.Text = _currentPreviewFileViewModel.VideoItem.SimilarityThreshold.ToString();
+                FrameModeTextBox.Text = EnumHelper.GetEnumDescription(_currentPreviewFileViewModel.VideoItem.FrameMode);
                 if (_currArchivedVideoData == null)
                 {
                     MessageBox.Show(this, $"加载原始视频失败", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                     return;
                 }
                 InitializePlayer();
-
-                var labeledFrameCount = 0;
                 for (int i = 0; i < _totalFrameCount; i++)
                 {
                     var isAdd = false;
@@ -577,15 +575,26 @@ namespace aipdev
             var selectedImages = _previewFileViewModels.Where(i => i.IsMultiSelected).ToList();
             if (selectedImages.Count == 0)
             {
-                MessageBox.Show(Application.Current.MainWindow, $"请先选择要确认修改的视频列表", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
-                return;
+                var selectedImage = _previewFileViewModels.FirstOrDefault(i => i.IsSelected);
+                if (selectedImage == null)
+                {
+                    MessageBox.Show(Application.Current.MainWindow, $"请先选择要确认修改的视频列表", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+                    return;
+                }
+                else
+                {
+                    selectedImages.Add(selectedImage);
+                }
             }
             double similarityThreshold = 0;
             int frameInterval = 1;
-            if (!double.TryParse(SimilarityThresholdTextBox.Text, out similarityThreshold))
+            if (selectedImages.Any(x => x.VideoItem.FrameMode == FrameMode.EqualInterval))
             {
-                MessageBox.Show(Application.Current.MainWindow, $"请输入正确的相似度阈值,范围为0~1,最多2位小数", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
-                return;
+                if (!double.TryParse(SimilarityThresholdTextBox.Text, out similarityThreshold))
+                {
+                    MessageBox.Show(Application.Current.MainWindow, $"请输入正确的相似度阈值,范围为0~1,最多2位小数", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+                    return;
+                }
             }
             similarityThreshold = ((int)(similarityThreshold * 100)) / 100d;
             if (similarityThreshold < 0 || similarityThreshold > 1)

+ 1 - 1
aipdev/PendingAllocationManagement.xaml.cs

@@ -165,7 +165,7 @@ namespace aipdev
                     var groupQty = item.GroupItem.Quantity;
                     if (item.Level == CategoryLevel.SameBatchLabelCase)
                     {
-                        desc += $" - 文件:组:{groupQty.Total},文件:{quantity.Total}";
+                        desc += $" - 病例组:{groupQty.Total},文件:{quantity.Total}";
                     }
                     var caseExtend = new ImageFolderExtend
                     {

+ 13 - 14
aipsvr/Services/AdminService.cs

@@ -4797,7 +4797,7 @@ namespace aipsvr.Services
                                     };
                                     modalItems.Add(modalItem);
                                 }
-                                if (ultrasoundFile.IsVideo && videoItem.FrameMode == FrameMode.EqualInterval)
+                                if (ultrasoundFile.IsVideo)
                                 {
                                     if (!developConfirmStatusInGroupDict.ContainsKey(group.Id))
                                     {
@@ -5040,7 +5040,6 @@ namespace aipsvr.Services
                                             }
                                             break;
                                     }
-                                    requiredFrame += keyFrameIndexList.Count;
                                 }
                                 else
                                 {
@@ -5094,32 +5093,32 @@ namespace aipsvr.Services
                             var progress = (int)((double)assignIndex / assignTotal * 100);
                             OperationManager.SetProgress(operationId, progress);
                         }
-                        switch (imageCategory.DevelopConfirmInfo.Status)
+                        switch (imageBatch.DevelopConfirmInfo.Status)
                         {
                             case DevelopConfirmStatus.None:
                             case DevelopConfirmStatus.HasConfirmed:
                                 if (totalDevelopConfirmInfo.Status == DevelopConfirmStatus.WaitForConfirm)
                                 {
-                                    imageCategory.DevelopConfirmInfo.Status = DevelopConfirmStatus.WaitForConfirm;
-                                    imageCategory.DevelopConfirmInfo.Developer = new EntityBase();
-                                    imageCategory.DevelopConfirmInfo.ConfirmTime = DateTime.MinValue.ToUniversalTime();
+                                    imageBatch.DevelopConfirmInfo.Status = DevelopConfirmStatus.WaitForConfirm;
+                                    imageBatch.DevelopConfirmInfo.Developer = new EntityBase();
+                                    imageBatch.DevelopConfirmInfo.ConfirmTime = DateTime.MinValue.ToUniversalTime();
                                 }
                                 break;
                         }
-                        await imageCategoryDataManager.UpdateImageCategoryAsync(imageCategory);
-                        switch (imageBatch.DevelopConfirmInfo.Status)
+                        await imageCategoryDataManager.UpdateImageCategoryAsync(imageBatch);
+                        switch (imageCategory.DevelopConfirmInfo.Status)
                         {
                             case DevelopConfirmStatus.None:
                             case DevelopConfirmStatus.HasConfirmed:
                                 if (totalDevelopConfirmInfo.Status == DevelopConfirmStatus.WaitForConfirm)
                                 {
-                                    imageBatch.DevelopConfirmInfo.Status = DevelopConfirmStatus.WaitForConfirm;
-                                    imageBatch.DevelopConfirmInfo.Developer = new EntityBase();
-                                    imageBatch.DevelopConfirmInfo.ConfirmTime = DateTime.MinValue.ToUniversalTime();
+                                    imageCategory.DevelopConfirmInfo.Status = DevelopConfirmStatus.WaitForConfirm;
+                                    imageCategory.DevelopConfirmInfo.Developer = new EntityBase();
+                                    imageCategory.DevelopConfirmInfo.ConfirmTime = DateTime.MinValue.ToUniversalTime();
                                 }
                                 break;
                         }
-                        await imageCategoryDataManager.UpdateImageCategoryAsync(imageBatch);
+                        await imageCategoryDataManager.UpdateImageCategoryAsync(imageCategory);
 
                         #endregion Add eachCount
 
@@ -5366,7 +5365,7 @@ namespace aipsvr.Services
                                 GoldStandardAssignedCount = actualAddedGoldStandardCount,
                                 SelfCheckAssignedCount = actualAddedSelfCheckCount,
                             };
-                            if (!developConfirmStatusInGroupDict.ContainsValue(DevelopConfirmStatus.WaitForConfirm))
+                            if (totalDevelopConfirmInfo.Status!=DevelopConfirmStatus.WaitForConfirm)
                             {
                                 labelerGroup.LabelCaseQuantityItem.Remaining += requiredFrameTotal;
                                 labelerGroup.LabelCaseQuantityItem.Required += requiredFrameTotal;
@@ -5378,7 +5377,7 @@ namespace aipsvr.Services
                             labelerGroup.LabelCaseQuantityItem.Total += assignFrameTotal;
                             labelerGroup.GoldStandardAssignedCount += actualAddedGoldStandardCount;
                             labelerGroup.SelfCheckAssignedCount += actualAddedSelfCheckCount;
-                            if (!developConfirmStatusInGroupDict.ContainsValue(DevelopConfirmStatus.WaitForConfirm))
+                            if (totalDevelopConfirmInfo.Status != DevelopConfirmStatus.WaitForConfirm)
                             {
                                 labelerGroup.LabelCaseQuantityItem.Remaining += requiredFrameTotal;
                                 labelerGroup.LabelCaseQuantityItem.Required += requiredFrameTotal;

+ 181 - 111
aipsvr/Services/DeveloperService.cs

@@ -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;