コード例 #1
0
        public SpeciesCandidatesResult Post(Double latitude, Double longitude, Boolean multisample, byte[] imageBytes)
        {
            if (imageBytes == null)
            {
                return(new SpeciesCandidatesResult(new List <SpeciesCandidate>(), FailureStatus, "Valid image must be supplied."));
            }

            try
            {
                var image                 = ImageConversion.ByteArrayToImage(imageBytes);
                var geographyPoint        = GeographyPoint.Create(latitude, longitude);
                var speciesIdentityResult = _speciesIdentifier.GetMostLikelyIdentity(image, geographyPoint, true, multisample);
                var speciesInfo           = speciesIdentityResult.LikelySpeciesInfo;

                var speciesCandidates = new List <SpeciesCandidate>
                {
                    new SpeciesCandidate(speciesInfo.GetName(),
                                         speciesInfo.Taxonomy.GetGenus() + " " + speciesInfo.Taxonomy.GetSpecies(),
                                         speciesInfo.GetProbability())
                };
                return(new SpeciesCandidatesResult(speciesCandidates, SuccessStatus, ""));
            }
            catch (Exception e)
            {
                var message = "Failure while processing request: " + e.Message;
                return(new SpeciesCandidatesResult(new List <SpeciesCandidate>(), FailureStatus, message));
            }
        }