我在使用 Amazon aws-cpp-sdk时遇到 Index_Faces问题。我在以下程序中遇到分段错误。
Image *fileData;
Image& imageToBytes(const char* str)
{
FILE *fp;
size_t length = 0;
fp= fopen(str, "rb");
if(fp == NULL)
{
exit(0);
}
fseek(fp, 0, SEEK_END);
length= ftell(fp);
rewind(fp);
fileData= (Image*)malloc((length+1)*sizeof(char));
fread(fileData, length, 1, fp);
return *fileData;
}
int main()
{
Aws::SDKOptions options;
Aws::InitAPI(options);
{
RekognitionClient *rekClient = new RekognitionClient();
CreateCollectionRequest *clRequest = new CreateCollectionRequest();
CreateCollectionRequest str = clRequest->WithCollectionId("collection7981");
CreateCollectionOutcome respose = rekClient->CreateCollection(str);
std::cout<<"Collection Successfully Created..."<<std::endl;
IndexFacesRequest iFaceRequest;
iFaceRequest.WithImage(imageToBytes("/home/msc/Profile_Pics/ms.JPG"));
}
Aws::ShutdownAPI(options);
return 0;
}
那么,如何从我的本地系统向亚马逊 aws-cpp-sdk 提供图像文件?