-1

I have requirement like below in an android,

Read image from camera or gallery of android phone. Compare this image with an image stored in a database (any valid format). Show the percentage of match between the images.

Tell me possible ways to achieve it.

sschrass
  • 7,014
  • 6
  • 43
  • 62

1 Answers1

0

First You Have To Compare Image Height And Width .. if It is Same then You Have To compare Bytes Pixel.

Check Height And Width.

if (image1.getHeight() != image2.getHeight()){
 return false;
}
 if (image1.getWidth() != image2.getWidth()){
 return false;
}

Then Check Image Pixel

for (int i = 0; i < image1.getWidth(); i++)
    {
        for (int j = 0; j < image1.getHeight(); j++)
        {
            if (image1.getPixel(i,j) == image2.getPixel(i,j))
            {
               // Do whatever you want Correct Image.. // both image Are Same
            }
            else
            {
                // both image Are diffrent
            }
        }
    }

Full Code Look Like

if (image1.getHeight() != image2.getHeight()){
    isImageSame = false;
    return;
}
if (image1.getWidth() != image2.getWidth()){
    isImageSame = false;
    return;
}


if(isImageSame){

for (int i = 0; i < image1.getWidth(); i++)
    {
        for (int j = 0; j < image1.getHeight(); j++)
        {
            if (image1.getPixel(i,j) == image2.getPixel(i,j))
            {
               // Do whatever you want Correct Image.. // both image Are Same
            }
            else
            {
                // both image Are diffrent
            }
        }
    }
}

you Can Also Do it By OpenCV lib also find Good Example here https://github.com/opencv/opencv/tree/master/samples/android/face-detection

Learning Always
  • 1,563
  • 4
  • 29
  • 49
  • @SharanBallundagi Please Add All Description about your Image And Some Code In Your Question So People Will Able To give Suitable Answer of your Question. – Learning Always Nov 30 '17 at 08:13