Ejemplo n.º 1
0
        private List <SpeciesInfo> GetListOfCandidateIdentities(Bitmap image)
        {
            var tagsResult = _clarifaiClient.GetTagsInfo(image);


            if (tagsResult != null)
            {
                //If not an animal species/genus/order/etc, tag result will be NULL
                var candidateBag = new ConcurrentBag <SpeciesInfo>();
                var tagsFilters  = _tagsFilterFactory.GetOrderedFilters();
                var filteredTags = tagsFilters.Aggregate(tagsResult.ImageTags, (current, filter) => filter.Filter(current));

                Parallel.ForEach(filteredTags, tag =>
                {
                    var taxonomy = _wolframClient.GetTaxonomyData(tag.Name);
                    if (!String.IsNullOrEmpty(taxonomy.GetKingdom()))
                    {
                        var speciesName = _wolframClient.GetCommonNameFromScientific(taxonomy);
                        var finalName   = String.IsNullOrEmpty(speciesName) ? tag.Name : speciesName;
                        candidateBag.Add(SpeciesInfo.GetInstance(taxonomy, finalName, tag.Name, tag.Probability));
                    }
                });

                return(candidateBag.ToList());
            }

            const string message = "Failed to identify image- Did not get result back for image tagging.";

            throw new NoClientResponseError(message);
        }
 private SpeciesIdentityResult(Image sourceImage, Rectangle cropArea, SpeciesInfo likelySpeciesInfo)
 {
     _sourceImage       = sourceImage;
     _cropArea          = cropArea;
     _likelySpeciesInfo = likelySpeciesInfo;
 }
Ejemplo n.º 3
0
 public Boolean IsGeneralizationOfThis(SpeciesInfo candidate)
 {
     return(_taxonomy.IsGeneralizationOfThis(candidate._taxonomy));
 }
 public static SpeciesIdentityResult GetInstance(Image sourceImage, Rectangle cropArea, SpeciesInfo likelySpeciesInfo)
 {
     return(likelySpeciesInfo == SpeciesInfo.NULL ? NULL : new SpeciesIdentityResult(sourceImage, cropArea, likelySpeciesInfo));
 }