C ++ OpenCV的imread不是在Android平台 [英] C++ OpenCV imread not working in Android

查看:226
本文介绍了C ++ OpenCV的imread不是在Android平台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读我的C ++图像code

I am trying to read an image in my C++ code

LOGD("Loading image '%s' ...\n", (*inFile).c_str());;
Mat img = imread(*inFile, CV_LOAD_IMAGE_GRAYSCALE);
CV_Assert(img.data != 0);

和得到下面的输出:

09-25 17:08:24.798: D/IRISREC(12120): Loading image '/data/data/com.example.irisrec/files/input/osoba1.jpg' ...
09-25 17:08:24.798: E/cv::error()(12120): OpenCV Error: Assertion failed (img.data != 0) in int wahet_main(int, char**), file jni/wahet.cpp, line 4208

该文件存在。但奇怪的是,如果我用root文件浏览器尝试preVIEW的形象,这只是黑色的。我有手动复制的文件。

The file exists. But strange is, that if I try to preview the image using Root File Browser it is just black. I copied the files there manually.

编辑:

在code在Windows下正常工作与.PNG和.jpg格式。我只是想港口现有的C ++项目虹膜识别到Android。

The code works fine under Windows with .png and .jpg format. I am just trying to port an existing C++ project for Iris Recognition to Android.

推荐答案

我能够只通过复制codeI的图像文件存储他们在我的资源文件夹首先要解决这个问题,并将其复制到下面的内部存储< A HREF =htt​​p://stackoverflow.com/questions/19218775/android-copy-assets-to-internal-storage>这个例子的。
如果有人可以解释这个给我请做到这一点。

I was able to solve this issue only by copying the image files in code.I stored them in my asset folder first and copied them to internal storage following this example. If someone can explain this to me please do this.

这篇关于C ++ OpenCV的imread不是在Android平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆