简体   繁体   中英

Eclipse OpenCV image path doesn't work

I tried everything but nothing seems to work here. I just want to read an image using OpendCV. Here is the code:

Mat image = Highgui.imread("/src/resources/figures.png");

This is in the MainApp.java

项目结构

But still getting the same error:

OpenCV Error: Assertion failed ((scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F)) in cv::cvtColor, file ..\..\..\..\opencv\modules\imgproc\src\color.cpp, line 3961

The figures.png image is the one that I am trying to get, I put the same file inside and outside the com.ia package, but still nothing works. I tried:

Mat image = Highgui.imread("figures.png");
Mat image = Highgui.imread("src/com/ia/figures.png");
Mat image = Highgui.imread("/src/com/ia/figures.png");
Mat image = Highgui.imread("/com/ia/figures.png");

And even more combinations, can someone please help me, I am going crazy with this. I also have the same problem with other projects, what is wrong with eclipse's file paths ¿?¿

UnsatisfiedLinkError is because of the OpenCV library not linked, you can first load the lib like this:

System.loadLibrary("lib_name");

And try again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM