vendredi 23 mars 2018

Amazon aws-cpp-sdk Index Faces giving segfault

I'm having a problem with Index_Faces using Amazon aws-cpp-sdk. I'm getting segmentation fault in following program.

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;
}

So, how to provide image file from my local system to amazon aws-cpp-sdk?

Aucun commentaire:

Enregistrer un commentaire