I have an image for which I need to do Handwriting Recognition on Android Client using TFLite.
To test this, I cut some portions of the image and passed them to the model but was getting very poor accuracy despite the model being 90% accurate.
For further debugging, I was checking if my cutting part was correct. The following code is the one which I use to crop my image.
Bitmap test = Bitmap.createBitmap(src, 494,213,30, 33);
When I do this,
new Thread() {
@Override
public void run() {
try (FileOutputStream out = new FileOutputStream(path+"/test.jpg")) {
(test).compress(Bitmap.CompressFormat.JPEG, 100, out); // bmp is your Bitmap instance
// PNG is a lossless format, the compression factor (100) is ignored
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
The image gets properly saved to my storage.
But, I tried something like this.
for(int i =0;i<30;i++){
for(int j=0;j<33;j++){
System.out.print(Color.red(test.getPixel(i,j))+" ");
}
System.out.println();
}
I used the matrix and formed the following image.
As you can see, my original bitmap of 1 part is rotated.
Can someone please explain why this is happening ?? And some alternative approach to this will help as well
Thanks in Advance.
Update: I tried the following
ExifInterface ei= null;
try {
ei = new ExifInterface(root+"/test.jpg");
} catch (IOException e) {
e.printStackTrace();
}
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_UNDEFINED);
System.out.println("Orientation is "+orientation);
My Output is:
Orientation is 0