/// <summary> /// Create view of image navigation result. /// </summary> /// <param name="imageNavigationResult">Navigation result to create view from</param> /// <returns>View of image navigation result</returns> public static ImageNavigationResultView CreateView(ImageNavigationResult imageNavigationResult) { #region valdiation if (imageNavigationResult == null) { throw new ArgumentNullException(nameof(imageNavigationResult)); } #endregion return(new ImageNavigationResultView { ImageLabel = ImageLabelFactory.CreateView(imageNavigationResult.ImageLabel), ImageCount = imageNavigationResult.ImageCount, HasNextBlank = imageNavigationResult.HasNextBlank, HasNext = imageNavigationResult.HasNext, HasPrevious = imageNavigationResult.HasPrevious, HasPreviousBlank = imageNavigationResult.HasPreviousBlank }); }
private ImageNavigationResultView GetImageLabelNavigationResult(Topic topic, NavigationParameter navigationParameter, ENavigationDirection navigationDirection) { System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); // fill imagelabel-structure of image label ImageNavigationResult image = NavigationService.Navigate(topic, navigationParameter.Index, navigationParameter.LabelMode, navigationDirection); // default navigation if not label was found on navigation to blank if (image == null && (navigationDirection == ENavigationDirection.Blank || navigationDirection == ENavigationDirection.LastBlank)) { image = NavigationService.Navigate(topic, navigationParameter.Index, navigationParameter.LabelMode, ENavigationDirection.Direct); } if (image == null) { // return http-404 if no label found return(null); } // create naviation result ImageNavigationResultView navigationResult = ImageNavigationResultFactory.CreateView(image); switch (navigationParameter.LabelMode) { case ELabelMode.ObjectDetection: if (image.ImageLabel.HasLabels) { IEnumerable <Label> labels = LabelService.GetLabels(topic, image.ImageLabel); navigationResult.ImageLabel.Labels = labels.Select(LabelFactory.CreateView); } break; } sw.Stop(); Log.Information($"Navigation takes {sw.ElapsedMilliseconds} ms"); return(navigationResult); }