android - 为什么 Bitmap.createBitmap() 会旋转我的图像?
问题描述
我有一张需要使用 TFLite 在 Android 客户端上进行手写识别的图像。
为了测试这一点,我剪切了图像的一些部分并将它们传递给模型,但尽管模型的准确度为 90%,但准确度却很差。
为了进一步调试,我正在检查我的切割部分是否正确。以下代码是我用来裁剪图像的代码。
Bitmap test = Bitmap.createBitmap(src, 494,213,30, 33);
当我这样做时,
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();
图像被正确保存到我的存储中。
但是,我尝试了这样的事情。
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();
}
如您所见,我原始的1部分位图已旋转。
有人可以解释为什么会这样吗?一些替代方法也会有所帮助
提前致谢。
更新: 我尝试了以下
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);
我的输出是:
方向为 0
解决方案
推荐阅读
- reactjs - 在测试中为 BrowserRouter 设置路由
- javascript - 按滚动百分比从上到下垂直移动图像
- sharepoint - Sharepoint 警报不适用于一个站点上的一个用户
- function - 我应该如何解开这组 lapply/sapply/mapply
- c# - Client stops working after sending message and server doesn't wait for mutliple data to come
- asp.net-core - InvalidOperationException: No service for type Microsoft.AspNetCore.Identity.UserManager has been registered error using ASP.NET Identity Server
- python - 将 FPDF 整合到适用于 Android 平板电脑的 Kivy 应用程序中
- swift - 用 SciFormatter 划分两个文本字段
- vb.net - 输入数字的总和与 do 循环直到
- r - 按天分组时间序列/时间戳