Ask Your Question

DM1's profile - activity

2015-03-18 04:43:45 -0600 received badge  Nice Answer (source)
2014-03-23 00:49:57 -0600 received badge  Teacher (source)
2013-11-28 15:47:28 -0600 received badge  Necromancer (source)
2013-08-17 09:39:38 -0600 received badge  Editor (source)
2013-08-17 09:12:09 -0600 answered a question libpng warning: Image width is zero in IHDR

For some reason, the returned resource path has a '/' prefix (I think I read somewhere this is a known Java bug). Plus, the code cannot handle %20 (space) in the url.
I used this code to solve it:

try{
    String url1 = getClass().getResource("/resources/lena.png").getPath();
    if (url1.startsWith("/", 0))
       url1=url1.replaceFirst("/", "");
    url1=URLDecoder.decode(url1, "UTF-8"); //this will replace %20 with spaces
    Mat image = Highgui.imread(url1); 
}
catch ...
2013-08-16 03:32:33 -0600 answered a question slight ambiguity in opencv java tutorial

On 2.4.6 I used opencv\build\java\x64\ where opencv_java246.dll is located, and that solved the problem.