Пример #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 WhenCaptionsAreComplexThenDescriptionDoesntChange(Caption caption, Description.Arguments arguments, string expectedDescription)
        {
            string actualDescription = Description.Get(caption, arguments);

            Assert.Equal(expectedDescription, actualDescription);
        }
Пример #3
0
        public static void DescriptionsAreGenderNeutral(Caption caption, Description.Arguments arguments, string expectedDescription)
        {
            string actualDescription = Description.Get(caption, arguments);

            Assert.Equal(expectedDescription, actualDescription);
        }
Пример #4
0
        public static void WhenCaptionIncludesPeopleThenDescriptionAddsArtQualifier(Caption caption, Description.Arguments arguments, string expectedDescription)
        {
            string actualDescription = Description.Get(caption, arguments);

            Assert.Equal(expectedDescription, actualDescription);
        }
Пример #5
0
        public static void WhenCaptionsAreSimpleAndItemIsOldAndBlackAndWhiteThenDescriptionHasOld(Caption caption, Description.Arguments arguments, string expectedDescription)
        {
            string actualDescription = Description.Get(caption, arguments);

            Assert.Equal(expectedDescription, actualDescription);
        }
Пример #6
0
        public static void WhenCaptionsAreSimpleThenDescriptionHasColor(Caption caption, Description.Arguments arguments, string expectedDescription)
        {
            string actualDescription = Description.Get(caption, arguments);

            Assert.Equal(expectedDescription, actualDescription);
        }