English 中文(简体)
尝试用 Highgui. imread (OpenCV + Android) 装入图像
原标题:Try to load image with Highgui.imread (OpenCV + Android)

我试图装入图像 :

    File root = Environment.getExternalStorageDirectory();
    File file = new File(root, "image.gif");
    Mat m = Highgui.imread(file.getAbsolutePath());
    if(file.exists()){
        showToast("Height: " + m.height() + " Width: " + m.width());
    }

但大小=0( 高度/ 高度) 。

最佳回答

文件存在这一事实并不意味着 OpenCV 能够读取文件的内容。

你们应该做的是:

Mat m = Highgui.imread(file.getAbsolutePath());
if (img.data)
{
     showToast("Height: " + m.height() + " Width: " + m.width());
}
else
{
     // print error and abort execution
}

imread () ,上面写着:

函数根据内容而不是文件扩展名来决定图像的类型 。

您在继续前应该检查文档。 确定您可以写入一个简单的 OpenCV 应用程序, 程序在打开更复杂的东西之前, 将磁盘上的图像装入并显示 。

问题回答

尝试使用

IplImage orgImage= cvLoadImage(fileName); 

它正在制作 JavaCV 包装纸。 但我不会在纯 OpenCV 上工作。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签