コード例 #1
0
    public static void Example()
    {
        AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient();

        Console.WriteLine("Listing collections");
        int limit = 10;

        ListCollectionsResponse listCollectionsResponse = null;
        String paginationToken = null;

        do
        {
            if (listCollectionsResponse != null)
            {
                paginationToken = listCollectionsResponse.NextToken;
            }

            ListCollectionsRequest listCollectionsRequest = new ListCollectionsRequest()
            {
                MaxResults = limit,
                NextToken  = paginationToken
            };

            listCollectionsResponse = rekognitionClient.ListCollections(listCollectionsRequest);

            foreach (String resultId in listCollectionsResponse.CollectionIds)
            {
                Console.WriteLine(resultId);
            }
        } while (listCollectionsResponse != null && listCollectionsResponse.NextToken != null);
    }
コード例 #2
0
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonRekognitionConfig config = new AmazonRekognitionConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonRekognitionClient client = new AmazonRekognitionClient(creds, config);

            ListCollectionsResponse resp = new ListCollectionsResponse();

            do
            {
                ListCollectionsRequest req = new ListCollectionsRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.ListCollections(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.CollectionIds)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
コード例 #3
0
        public static List <String> GetFaceCollectionList()
        {
            List <String> _faceCollectionList = new List <string>();

            _faceCollectionList.Clear();

            using (rekognitionClient = new AmazonRekognitionClient(collectionRegion))
            {
                ListingCollections();
            }

            void ListingCollections()
            {
                try
                {
                    int limit = 10;

                    ListCollectionsResponse listCollectionsResponse = null;
                    String paginationToken = null;
                    do
                    {
                        if (listCollectionsResponse != null)
                        {
                            paginationToken = listCollectionsResponse.NextToken;
                        }

                        ListCollectionsRequest listCollectionsRequest = new ListCollectionsRequest()
                        {
                            MaxResults = limit,
                            NextToken  = paginationToken
                        };

                        listCollectionsResponse = rekognitionClient.ListCollections(listCollectionsRequest);

                        foreach (String resultId in listCollectionsResponse.CollectionIds)
                        {
                            _faceCollectionList.Add(resultId);
                        }
                    } while (listCollectionsResponse != null && listCollectionsResponse.NextToken != null);
                }
                catch (AmazonRekognitionException e)
                {
                    Console.WriteLine("AmazonRekognitionException: " + e);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e);
                }
            }

            return(_faceCollectionList);
        }
コード例 #4
0
        public ActionResult Index(ImageTrainModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            try
            {
                using (Stream inputStream = model.File.InputStream)
                {
                    MemoryStream memoryStream = inputStream as MemoryStream;
                    if (memoryStream == null)
                    {
                        memoryStream = new MemoryStream();
                        inputStream.CopyTo(memoryStream);
                    }

                    var collectionsList = client.ListCollections(new ListCollectionsRequest {
                        MaxResults = 10
                    });
                    //client.CreateCollection(new CreateCollectionRequest
                    //{
                    //    CollectionId = "TrainedImages"
                    //});

                    IndexFacesRequest indexFacesRequest = new IndexFacesRequest()
                    {
                        Image = new Image
                        {
                            Bytes = memoryStream
                        },
                        CollectionId        = "TrainedImages",
                        ExternalImageId     = model.Name,
                        DetectionAttributes = new List <String>()
                        {
                            "ALL"
                        }
                    };

                    IndexFacesResponse indexFacesResponse = client.IndexFaces(indexFacesRequest);
                    if (indexFacesResponse.HttpStatusCode == System.Net.HttpStatusCode.OK)
                    {
                        ViewBag.Message = "Image trained successfully";
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message.ToString();
            }
            return(View());
        }
コード例 #5
0
        public void RekognitionListCollections()
        {
            #region to-list-the-collections-1482179199088

            var client   = new AmazonRekognitionClient();
            var response = client.ListCollections(new ListCollectionsRequest
            {
            });

            List <string> collectionIds = response.CollectionIds;

            #endregion
        }
コード例 #6
0
        public ActionResult ListarCollections()
        {
            var rekognitionClient = new AmazonRekognitionClient("AKIAIBLZ7KFAN6XG3NNA", "2nukFOTDN0zv/y2tzeCiLrAHM5TwbFgvEqqZA9zn", RegionEndpoint.USWest2);

            var response = rekognitionClient.ListCollections(new ListCollectionsRequest
            {
            });

            List <string> collectionIds = response.CollectionIds;

            ViewBag.colecao = collectionIds.ToList();

            return(View());
        }