我在尝试使用Android中的OpenCV 3.0加载放置在资产文件夹中的图像时遇到了麻烦.我在这里阅读了很多答案,但是我无法弄清楚自己在做什么错.
“ my image.jpg”直接放置在Android Studio创建的资产文件夹中.
这是我正在使用的代码.我已经检查过,并且库已正确加载.
Mat imgOr = Imgcodecs.imread("file:///android_asset/myimage.jpg");
int height = imgOr.height();
int width = imgOr.width();
String h = Integer.toString(height);
String w = Integer.toString(width);
if (imgOr.dataAddr() == 0) {
// If dataAddr() is different from zero, the image has been loaded
// correctly
Log.d(TAG, "WRONG UPLOAD");
}
Log.d(h, "height");
Log.d(w, "width");
当我尝试运行我的应用程序时,这是我得到的:
08-21 18:13:32.084 23501-23501/com.example.android D/MyActivity: WRONG UPLOAD
08-21 18:13:32.085 23501-23501/com.example.android D/0: height
08-21 18:13:32.085 23501-23501/com.example.