public AzureCvModels.RecognitionResult GetRecognitionResult(Domain.ImageFile imageFile, AzureCvModels.TextRecognitionMode textRecognitionMode)
        {
            ImageFile dbImageFile = _computerVisionContext.ImageFile.SingleOrDefault(x => x.HashString == imageFile.HashString);

            if (dbImageFile != null)
            {
                RecognitionResult dbRecognitionResult             = GetRecognitionResult(dbImageFile, textRecognitionMode);
                AzureCvModels.RecognitionResult recognitionResult = null;
                if (dbRecognitionResult != null)
                {
                    recognitionResult = Mapper.Map <AzureCvModels.RecognitionResult>(dbRecognitionResult);
                }
                return(recognitionResult);
            }

            return(null);
        }
        public void AddRecognitionResult(Domain.ImageFile imageFile, AzureCvModels.RecognitionResult recognizeText, AzureCvModels.TextRecognitionMode textRecognitionMode)
        {
            RecognitionResult dbRecognizeText    = Mapper.Map <RecognitionResult>(recognizeText);
            RecognitionResult addedRecognizeText = _computerVisionContext.RecognitionResult.Add(dbRecognizeText).Entity;

            _computerVisionContext.SaveChanges();
            ImageFile dbImageFile = _computerVisionContext.ImageFile.SingleOrDefault(x => x.HashString == imageFile.HashString);

            if (dbImageFile != null && textRecognitionMode == AzureCvModels.TextRecognitionMode.Printed)
            {
                dbImageFile.PrintedRecognitionResultId = addedRecognizeText.Id;
            }
            else if (dbImageFile != null && textRecognitionMode == AzureCvModels.TextRecognitionMode.Handwritten)
            {
                dbImageFile.HandwrittenRecognitionResultId = addedRecognizeText.Id;
            }
            _computerVisionContext.SaveChanges();
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the TextOperationResult class.
 /// </summary>
 /// <param name="status">Status of the text operation. Possible values
 /// include: 'Not Started', 'Running', 'Failed', 'Succeeded'</param>
 public TextOperationResult(TextOperationStatusCodes status = default(TextOperationStatusCodes), RecognitionResult recognitionResult = default(RecognitionResult))
 {
     Status            = status;
     RecognitionResult = recognitionResult;
     CustomInit();
 }