I have tried so much, but I cannot succeed. I didn’t find any source code examples for Android (about the reenactment)
there is source code in JAVA in the Developer's Guide, but I can not implement this, although I tried TT
I'm trying to detect faces by sending an image file from external storage (from the emulator) I don’t know what I did wrong (I can’t encode) Here is my code
AmazonRekognitionClient amazonRekognitionClient;
Image getAmazonRekognitionImage;
DetectFacesRequest detectFaceRequest;
DetectFacesResult detectFaceResult;
File file = new File(Environment.getExternalStorageDirectory(),"sungyeol.jpg.jpg");
public void test_00(View view) {
ByteBuffer imageBytes;
try{
InputStream inputStream = new FileInputStream(file.getAbsolutePath().toString());
imageBytes = ByteBuffer.wrap(IOUtils.toByteArray(inputStream));
Log.e("InputStream: ",""+inputStream);
Log.e("imageBytes: ","");
getAmazonRekognitionImage.withBytes(imageBytes);
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getApplicationContext(),
"us-east-2:.......",
Regions.US_EAST_2
);
amazonRekognitionClient = new AmazonRekognitionClient(credentialsProvider);
detectFaceRequest = new DetectFacesRequest()
.withAttributes(Attribute.ALL.toString())
.withImage(getAmazonRekognitionImage);
detectFaceResult = amazonRekognitionClient.detectFaces(detectFaceRequest);
detectFaceResult.getFaceDetails();
}
catch(Exception ex){
Log.e("Error on something:","Message:"+ex.getMessage());
}
and here are my mistakes
02-04 09:30:07.268 29405-29405/? E/InputStream:: java.io.FileInputStream@a9b23e7
02-04 09:30:07.271 29405-29405/? E/Error on something:: Message:Attempt to invoke virtual method 'com.amazonaws.services.rekognition.model.Image com.amazonaws.services.rekognition.model.Image.withBytes(java.nio.ByteBuffer)' on a null object reference
What is a reference to a null object? I'm trying to change the path to a file, but he didn’t say such a file ... and when I go to this path, there are errors above. By the way, I already asked the user for permission to access the folder from Emulator in Android
please help me PS. sorry for my bad english
Thanks in advance.