我已经尝试了很多方法,但我无法成功。我还没有发现任何源代码示例为Android(约rekognition)如何使用Android Studio在亚马逊重新识别AWS中识别出自动识别区域?
有一个在JAVA源代码的开发者指南中,但我不能执行,即使我试过TT
我试图通过发送到人脸从外部存储器中(模拟器) 图像文件,我不知道我做错了什么(我不是在编码好) 这里是我的代码
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);
// Initialize the Amazon Cognito credentials provider
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getApplicationContext(),
"us-east-2:.......", // Identity Pool ID
Regions.US_EAST_2 // Region
);
//I want "ALL" attributes
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());
}
,这里是我的错误
02-04 09:30:07.268 29405-29405/? E/InputStream:: [email protected]
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
什么是空对象引用? 我试图改变文件路径,但他说没有这样的文件...当我改变到这个路径,上面有错误。 顺便说一句,我已经问过用户的权限来访问Android中的模拟器的文件夹
请帮我 PS。对不起我的英文不好
谢谢你提前。
这将是有益的如果你可以发布你的解决方案,我是在相同的情况下。 –
我编辑了我的帖子以获取更多信息,我希望这些可以帮助您。 –