示例#1
0
        public async Task Rekognize()
        {
            var newRegion = RegionEndpoint.GetBySystemName("us-east-1");

            using (var rekClient = new AmazonRekognitionClient(newRegion))
            {
                //Amazon.Rekognition.Model.DetectFacesRequest
                string collection_id = "test";

                CreateCollectionRequest request = new CreateCollectionRequest()
                {
                    CollectionId = collection_id
                };

                CreateCollectionResponse response = await rekClient.CreateCollectionAsync(request);

                KinesisVideoStream VidStream = new KinesisVideoStream()
                {
                    Arn = "arn:aws:kinesisvideo:us-east-1:229551089657:stream/myVideoStream/1525622803413"
                };

                StreamProcessorInput SPInput = new StreamProcessorInput()
                {
                    KinesisVideoStream = VidStream
                };
                KinesisDataStream DataStream = new KinesisDataStream()
                {
                    Arn = "arn:aws:kinesis:us-east-1:229551089657:stream/myDataStream"
                };
                StreamProcessorOutput output = new StreamProcessorOutput()
                {
                    KinesisDataStream = DataStream
                };
                FaceSearchSettings faceSearchSettings = new FaceSearchSettings()
                {
                    CollectionId       = collection_id,
                    FaceMatchThreshold = 10
                };
                StreamProcessorSettings spSettings = new StreamProcessorSettings()
                {
                    FaceSearch = faceSearchSettings
                };

                CreateStreamProcessorResponse final_resp = await rekClient.CreateStreamProcessorAsync(new CreateStreamProcessorRequest()
                {
                    Input    = SPInput,
                    RoleArn  = "arn:aws:iam::229551089657:role/RekRole2",
                    Output   = output,
                    Settings = spSettings,
                    Name     = "CrazyDemo1"
                });



                string why = final_resp.StreamProcessorArn;
            }
        }
示例#2
0
        public string CreateStreamProcessor()
        {
            //Setup input parameters
            KinesisVideoStream kinesisVideoStream = new KinesisVideoStream()
            {
                Arn = kinesisVideoStreamArn,
            };

            StreamProcessorInput streamProcessorInput = new StreamProcessorInput()
            {
                KinesisVideoStream = kinesisVideoStream,
            };

            KinesisDataStream kinesisDataStream = new KinesisDataStream()
            {
                Arn = kinesisDataStreamArn,
            };

            StreamProcessorOutput streamProcessorOutput = new StreamProcessorOutput()
            {
                KinesisDataStream = kinesisDataStream,
            };

            FaceSearchSettings faceSearchSettings = new FaceSearchSettings()
            {
                CollectionId       = collectionId,
                FaceMatchThreshold = matchThreshold,
            };

            StreamProcessorSettings streamProcessorSettings = new StreamProcessorSettings()
            {
                FaceSearch = faceSearchSettings,
            };

            //Create the stream processor
            CreateStreamProcessorResponse createStreamProcessorResponse = rekognitionClient.CreateStreamProcessor(
                new CreateStreamProcessorRequest()
            {
                Input    = streamProcessorInput,
                Output   = streamProcessorOutput,
                Settings = streamProcessorSettings,
                RoleArn  = roleArn,
                Name     = streamProcessorName,
            });

            //Display result
            Console.WriteLine("Stream Processor " + streamProcessorName + " created.");
            Console.WriteLine("StreamProcessorArn - " + createStreamProcessorResponse.StreamProcessorArn);

            return(createStreamProcessorResponse.StreamProcessorArn);
        }
示例#3
0
        public static bool CreateStreamProcessor(String streamProcessorName, String VideoStreamArn, String DataStreamArn)
        {
            bool isSuccess = false;

            // Setup input parameters
            KinesisVideoStream kinesisVideoStream = new KinesisVideoStream()
            {
                Arn = VideoStreamArn,
            };

            StreamProcessorInput streamProcessorInput = new StreamProcessorInput()
            {
                KinesisVideoStream = kinesisVideoStream,
            };

            KinesisDataStream kinesisDataStream = new KinesisDataStream()
            {
                Arn = DataStreamArn,
            };

            StreamProcessorOutput streamProcessorOutput = new StreamProcessorOutput()
            {
                KinesisDataStream = kinesisDataStream,
            };

            FaceSearchSettings faceSearchSettings = new FaceSearchSettings()
            {
                CollectionId       = collectionId,
                FaceMatchThreshold = matchThreshold,
            };

            StreamProcessorSettings streamProcessorSettings = new StreamProcessorSettings()
            {
                FaceSearch = faceSearchSettings,
            };

            try
            {
                AmazonRekognitionClient rekognitionClient;
                using (rekognitionClient = new AmazonRekognitionClient(MyAWSConfigs.KinesisRegion))
                {
                    // Create the stream processor
                    CreateStreamProcessorResponse createStreamProcessorResponse = rekognitionClient.CreateStreamProcessor(
                        new CreateStreamProcessorRequest()
                    {
                        Input    = streamProcessorInput,
                        Output   = streamProcessorOutput,
                        Settings = streamProcessorSettings,
                        RoleArn  = roleArn,
                        Name     = streamProcessorName,
                    });

                    // Display result
                    Console.WriteLine("Stream Processor " + streamProcessorName + " created.");
                    Console.WriteLine("StreamProcessorArn - " + createStreamProcessorResponse.StreamProcessorArn);

                    isSuccess = createStreamProcessorResponse.HttpStatusCode == System.Net.HttpStatusCode.OK ? true : false;
                }
            }
            catch (AmazonRekognitionException e)
            {
                Console.WriteLine("AmazonRekognitionException: " + e);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e);
            }

            return(isSuccess);
        }