コード例 #1
0
        public ICognitiveImageAnalysis SaveKeysAndAnalyze(string faceApi, string faceApiEndpoint, string computerVisionApi, string computerVisionApiEndpoint)
        {
            //save items to fields
            if (MSCSApiKeys.Face != faceApi)
            {
                MSCSApiKeys.Face = faceApi;
            }
            if (MSCSApiKeys.FaceEndpoint != faceApiEndpoint)
            {
                MSCSApiKeys.FaceEndpoint = faceApiEndpoint;
            }
            if (MSCSApiKeys.ComputerVision != computerVisionApi)
            {
                MSCSApiKeys.ComputerVision = computerVisionApi;
            }
            if (MSCSApiKeys.ComputerVisionEndpoint != computerVisionApiEndpoint)
            {
                MSCSApiKeys.ComputerVisionEndpoint = computerVisionApiEndpoint;
            }

            //get the sample image and analyze it to test responses
            Item sampleImage = DataWrapper.GetDatabase(SearchSettings.MasterDatabase).GetItem(SearchSettings.SampleImageId);

            return(AnalysisService.AnalyzeImage(sampleImage));
        }
        public IImageAnalysis SaveKeysAndAnalyze(string faceApi, string faceApiEndpoint, string computerVisionApi, string computerVisionApiEndpoint)
        {
            //save items to fields
            if (MSCSApiKeys.Face != faceApi)
            {
                UpdateKey(SCSDKSettings.MSSDK_FaceFieldId, faceApi);
            }
            if (MSCSApiKeys.FaceEndpoint != faceApiEndpoint)
            {
                UpdateKey(SCSDKSettings.MSSDK_FaceEndpointFieldId, faceApiEndpoint);
            }
            if (MSCSApiKeys.ComputerVision != computerVisionApi)
            {
                UpdateKey(SCSDKSettings.MSSDK_ComputerVisionFieldId, computerVisionApi);
            }
            if (MSCSApiKeys.ComputerVisionEndpoint != computerVisionApiEndpoint)
            {
                UpdateKey(SCSDKSettings.MSSDK_ComputerVisionEndpointFieldId, computerVisionApiEndpoint);
            }

            //get the sample image and analyze it to test responses
            try
            {
                var sampleItem = DataWrapper.GetItemById(SearchSettings.SampleImageId, SearchSettings.MasterDatabase);
                return(AnalysisService.AnalyzeImage(sampleItem, null, null, null, false));
            }
            catch (Exception ex)
            {
                Logger.Error("There was an error setting up the Intelligent Media modules", this, ex);
                return(null);
            }
        }
        public ActionResult Analyze(string id, string language, string db)
        {
            if (!IsSitecoreUser())
            {
                return(LoginPage());
            }

            Item item = DataWrapper.GetItemByIdValue(id, db);

            var analysis = AnalysisService.AnalyzeImage(item);

            return(View("ImageAnalysis", analysis));
        }
コード例 #4
0
        public ActionResult Analyze(string id, string language, string db, bool overwrite = false)
        {
            if (!IsSitecoreUser())
            {
                return(LoginPage());
            }

            var result = SearchService.GetSearchResult(id, language, db);
            var item   = DataWrapper.GetItemByIdValue(id, db);

            var analysis = AnalysisService.AnalyzeImage(item, result.FacialAnalysis, result.TextAnalysis, result.VisionAnalysis, true, overwrite);

            return(View("ImageAnalysis", analysis));
        }
コード例 #5
0
        public bool RecordNewIncident(CreateIncidentInput incidentRequest)
        {
            var incident = _objectMapper.Map <Incident>(incidentRequest);

            incident.PositivitySentimentScore = _languageAnalysys.GetSentimentScore(incident.Description);

            var phrases      = _languageAnalysys.GetKeyPrases(incident.Description);
            var incidentTags = (from phrase in phrases
                                let databasePhrase = _tagRepository.GetAll().FirstOrDefault(tag => tag.Name == phrase)
                                                     select databasePhrase == null
                    ? _tagRepository.InsertAndGetId(new Tag {
                Name = phrase
            })
                    : databasePhrase.Id).ToList();

            var imageTags = _imageAnalysisService.AnalyzeImage(incidentRequest.ImageBytes).Result.Description.Tags;

            incidentTags.AddRange((from imageTag in imageTags
                                   let databasePhrase = _tagRepository.GetAll().FirstOrDefault(tag => tag.Name == imageTag)
                                                        select databasePhrase == null
                    ? _tagRepository.InsertAndGetId(new Tag {
                Name = imageTag
            })
                    : databasePhrase.Id).ToList());

            incident.ImageId = _imageRepository.InsertAndGetId(new Image {
                ImagePath = incidentRequest.ImageName
            });
            var incidentId = _incidentRepository.InsertAndGetId(incident);

            foreach (var incidentTag in incidentTags)
            {
                _incidentTagRepository.Insert(new IncidentTag {
                    IncidentId = incidentId, TagId = incidentTag
                });
            }
            return(true);
        }
コード例 #6
0
        public void Process(UploadArgs args)
        {
            var Database = args.UploadedItems.Any()
                ? args.UploadedItems.First().Database
                : null;

            if (Database == null)
            {
                return;
            }

            foreach (Item mediaItem in args.UploadedItems)
            {
                var           searchRoot = Database.GetItem(Settings.ImageSearchFolderId);
                CheckboxField f          = searchRoot.Fields[Settings.AnalyzeNewImageField];
                if (f == null || !f.Checked)
                {
                    return;
                }

                AnalysisService.AnalyzeImage(mediaItem);
            }
        }
 public void AnalyzeUploadedImages(Item image)
 {
     AnalysisService.AnalyzeImage(image, null, null, null);
 }