how to calculate the image quality score in arcore in android?

Viewed 525

I want to calculate the image quality score before adding the image in ARCore database. I read arcoreimg google documentation to calculate the quality score but they are calculating score on windows/Mac OS command line. I want to calculate the image quality score programmatically in my project. How can i do it. Please help. I also check this stackoverflow link, but not getting the solution. Thanks :)

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,0,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();
}

}
1 Answers

Step 1: Download arcoreimg tool from official site

https://github.com/google-ar/arcore-android-sdk/blob/master/tools/arcoreimg/linux/arcoreimg

Step 2: Try this command

./arcoreimg eval-img --input_image_path=yourImagePath

Sample command

./arcoreimg eval-img --input_image_path=/Users/ranjithkumar/Downloads/sceneform-android-sdk-1.15.0/samples/augmentedimage/app/src/main/assets/default.jpg

Step 3: If you face any error, Give read+write permission to arcoreimg tool.

(Ignore this if Step 2 working)

sudo chmod +x arcoreimg

It return score 0 to 100. High scores will work without lagging.

Related