图像尺寸太小,Android Face Face API Android

问题描述 投票:5回答:1

我正在尝试在Android上使用Azure Face API。我正在从设备相机捕获图像,然后将其转换为InputStream以发送到detect方法。我不断收到错误“ com.microsoft.projectoxford.face.rest.ClientException:图像大小太小”

我检查了文档,图像大小为1.4Mb,在1Kb-4Mb范围内。我不明白为什么它不起作用。

Bitmap bitmap = cameraKitImage.getBitmap();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, bos);
bitmapdata = bos.toByteArray();

new FaceTask().execute(new ByteArrayInputStream(bitmapdata));

Face[] faces = faceServiceClient.detect(inputStreams[0], true, false, null);
android azure microsoft-cognitive face-api
1个回答
0
投票

以某种方式将文件压缩超过1Kb,或者如果文件的实际大小已经很小。尝试将其保存在drawable或assets文件夹中的某个位置,然后在输入流中将其打开。

© www.soinside.com 2019 - 2024. All rights reserved.