有人成功完成了FaceSearch吗?
我在2018年8月13日美国东部时间上午8点左右使用.Net API提交了人脸搜索,但尚未通知我的队列作业已完成。来自StartFaceSearch的响应的HttpStatusCode为:确定
我有一个队列订阅了我希望在其上收到通知的主题。我向主题发布了一条测试消息,队列确实将其提取。
这是代码...(已删除标识符)
// upload the video to Amazon
IAmazonS3 client = new AmazonS3Client();
// 1. Put object-specify only key name for the new object.
var putRequest1 = new PutObjectRequest
{
BucketName = "mybucket.com",
Key = dr["video_id"].ToString(),
FilePath = Path.Combine(videoPath, dr["video_path"].ToString()),
ContentType = "video/mp4"
};
PutObjectResponse response1 = await client.PutObjectAsync(putRequest1);
// upload the image to Amazon
byte[] image = (byte[])(dr["photobinary"]);
MemoryStream stream = new MemoryStream(image);
using (Amazon.S3.Transfer.TransferUtility tranUtility =
new Amazon.S3.Transfer.TransferUtility(client))
{
tranUtility.Upload(stream, "bucket.com", dr["SSN"].ToString());
}
stream.Close();
// create a Rekognition Collection
IAmazonRekognition rekClient = new AmazonRekognitionClient();
try
{
// try to delete in case it already exists
rekClient.DeleteCollection(new DeleteCollectionRequest
{
CollectionId = dr["ssn"].ToString()
});
}
catch { }
var response = rekClient.CreateCollection(new CreateCollectionRequest
{
CollectionId = dr["ssn"].ToString()
});
string collectionArn = response.CollectionArn;
int statusCode = response.StatusCode;
var facesResponse = rekClient.IndexFaces(new IndexFacesRequest
{
CollectionId = dr["ssn"].ToString(),
DetectionAttributes = new List<string>
{
},
ExternalImageId = dr["ssn"].ToString(),
Image = new Image
{
S3Object = new Amazon.Rekognition.Model.S3Object
{
Bucket = "bucket.com",
Name = dr["ssn"].ToString()
}
}
});
List<FaceRecord> faceRecords = facesResponse.FaceRecords;
string orientationCorrection = facesResponse.OrientationCorrection;
var faceSearchResponse = rekClient.StartFaceSearch(new StartFaceSearchRequest
{
CollectionId = dr["ssn"].ToString(),
Video = new Video
{
S3Object = new Amazon.Rekognition.Model.S3Object
{
Bucket = "videobucket.com",
Name = dr["video_id"].ToString()
}
},
NotificationChannel = new NotificationChannel
{
SNSTopicArn = "arn:xxx",
RoleArn = "arn:xxx"
}
});
答案 0 :(得分:0)
问题是我指定的角色没有适当的权限来写入主题。我授予了角色管理员访问权限,然后它开始工作。