问题描述
我想在将图像添加到ARCore数据库之前计算图像质量得分。我读过arcoreimg google documentation以计算质量得分,但他们正在Windows / Mac OS命令行上计算得分。我想以编程方式在我的项目中计算图像质量得分。我该怎么做。请帮忙。 我还检查了this stackoverflow链接,但没有得到解决方案。 谢谢:)
private void registeredImage() {
File file = new File(getExternalFilesDir(null) + "/db.imgdb");
//OutputStream outputStream = getResources().openRawResource(R.raw.imagedb);
Frame CurrFrame = frame;
Image currentimage;
int idx = -1;
byte[] data = null;
try {
currentimage = CurrFrame.acquireCameraimage();
data = NV21toJPEG(YUV_420_888toNV21(currentimage),currentimage.getWidth(),currentimage.getHeight());
} catch (NotYetAvailableException | IOException | ImageInsufficientQualityException e) {
e.printstacktrace();
}
try {
FileOutputStream outputStream = new FileOutputStream(file);
Bitmap bitmap = BitmapFactory.decodeByteArray(data,data.length);
-------------------------------------------------------------
***// Here i want to calculate the quality score of image that i'm going to add in database***.
--------------------------------------------------------------
idx = aid.addImage(name,bitmap);
aid.serialize(outputStream);
outputStream.close();
Toast.makeText(this,"image Registered",Toast.LENGTH_SHORT).show();
} catch (IOException | ImageInsufficientQualityException e) {
Toast.makeText(this,"Image doesnot have enough featues..Please try again",Toast.LENGTH_LONG).show();
e.printstacktrace();
}
}
解决方法
第一步:从官网下载arcoreimg工具
https://github.com/google-ar/arcore-android-sdk/blob/master/tools/arcoreimg/linux/arcoreimg
第 2 步:试试这个命令
./arcoreimg eval-img --input_image_path=yourImagePath
示例命令
./arcoreimg eval-img --input_image_path=/Users/ranjithkumar/Downloads/sceneform-android-sdk-1.15.0/samples/augmentedimage/app/src/main/assets/default.jpg
第 3 步:如果您遇到任何错误,请授予 arcoreimg 工具的读写权限。
(如果第 2 步有效,请忽略此项)
sudo chmod +x arcoreimg
它返回 0 到 100 的分数。高分不会滞后。