示例#1
0
        static Appraisal CreateAppraisal(Bitmap sourceImage, ComputerVisionService.AnalysisBlob analysisResult)
        {
            Caption caption = GetCaption(analysisResult.generalAnalysisResult);

            Console.WriteLine("Caption: " + caption.Text + " " + caption.Confidence);

            string foregroundColor     = GetForegroundColor(analysisResult.generalAnalysisResult);
            float  confidence          = (float)caption.Confidence;
            bool   isOld               = IsOld(analysisResult.generalAnalysisResult);
            float  expensiveMultiplier = GetPriceExpensiveMultiplier(analysisResult.generalAnalysisResult);

            Console.WriteLine("Is Old: " + isOld);
            bool isBlackAndWhite = IsBlackAndWhite(analysisResult.generalAnalysisResult);

            Console.WriteLine("Is Black and White: " + isBlackAndWhite);
            bool isPainting = PaintingDetection.IsPainting(analysisResult);

            Console.WriteLine("Is Painting: " + isPainting);
            bool isPhoto = !isPainting && IsPhoto(analysisResult.generalAnalysisResult);

            Console.WriteLine("Is Photo: " + isPhoto);
            bool isSign = SignDetection.IsSign(analysisResult);

            Console.WriteLine("Is Sign: " + isSign);
            int?extractedYear = YearExtractor.ExtractYear(analysisResult.ocrAnalysisResult);

            Description.Arguments descriptionArguments = new Description.Arguments
            {
                foregroundColor = foregroundColor,
                isOld           = isOld,
                isBlackAndWhite = isBlackAndWhite,
                isPainting      = isPainting,
                isPhoto         = isPhoto,
                isSign          = isSign,
            };

            string descriptionText = Description.Get(caption, descriptionArguments);

            Console.WriteLine("Final Description Text: " + descriptionText);
            Console.WriteLine("Extracted Year: " + extractedYear);
            string extractedLocale = LanguageCodeToLocation.LookUp(analysisResult.ocrAnalysisResult);

            Console.WriteLine("Extracted Locale: " + extractedLocale);

            Random random        = GetDeterministicRandom(sourceImage);
            Bitmap composedImage = ComposeImage(sourceImage, descriptionText, confidence, isOld, isBlackAndWhite && isPhoto, expensiveMultiplier, isPainting, isSign, extractedYear, extractedLocale, random);

            return(new Appraisal {
                image = composedImage, comment = descriptionText
            });
        }
示例#2
0
        public static void BestYearExtractedFromList(System.Collections.Generic.IEnumerable <string> words, int?expectedYear)
        {
            int?actualYear = YearExtractor.ExtractYear(words);

            Assert.Equal(expectedYear, actualYear);
        }
示例#3
0
 public static void TestPriority(int year, int expectedPriority)
 {
     Assert.Equal(YearExtractor.GetPriority(year), expectedPriority);
 }