使用此code的工作,但在Android 4.2和OpenCV 2.4.4失败,但我不知道为什么。任何人都可以摆脱它的任何光线下我吗?
This code used to work but on Android 4.2 and OpenCV 2.4.4 it fails, but I don't know why. Can anyone shed any light on it for me?
感谢您的帮助。
巴兹
public void SaveImage (Mat mat) {
Mat mIntermediateMat = new Mat();
Imgproc.cvtColor(mRgba, mIntermediateMat, Imgproc.COLOR_RGBA2BGR, 3);
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
String filename = "barry.png";
File file = new File(path, filename);
Boolean bool = null;
filename = file.toString();
bool = Highgui.imwrite(filename, mIntermediateMat);
if (bool == true)
Log.d(TAG, "SUCCESS writing image to external storage");
else
Log.d(TAG, "Fail writing image to external storage");
}
布尔回来虚假每次。文件路径/名称是理所应当的(存储/模拟/ 0 /图片/ barry.png)的用户#0和目录的图片是存在的。
bool comes back false every time. The file path/name is as it should be ("storage/emulated/0/Pictures/barry.png") for User #0 and the directory Pictures is there.
是什么让imwrite返回false?
What can make imwrite return false?
我可以在垫子转换为BMP和保存它自己(我在非OpenCV的应用程序做其他地方),但由于Highgui.imwrite是存在的,这code使用时,我在写至2.4工作2.0和测试在Android 3.x中,我想,如果我可以使用它。
I could convert the mat to a bmp and save it myself (which I do elsewhere in a non-OpenCV app) but since Highgui.imwrite is there, and this code used to work when I was writing to 2.4.0 and testing on Android 3.x, I'd like to use it if I can.
感谢
巴兹
我简直不敢相信。 [facepalm]。
I can't believe it. [facepalm].
添加到您的清单文件巴里:
Add this to your manifest file Barry:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
会有人来拍我好吗?我设法从清单中删除写权限所以真的不应该有任何的惊喜,它不会写......
Would somebody come and slap me please? I managed to remove the write permission from the manifest so really there shouldn't be any surprise that it wouldn't write...
卫生署。
巴里