cheddadi / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

Cannot find Loader.class #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add the Jar files to the project in Eclipse.
2. The project will compile and begin to run just fine.
3. The first JavaCV statement it reaches will cause it to crash saying, "The 
source attachment does 
not contain the source for the file Loader.class."

What is the expected output? What do you see instead?
I expect it to run over the line of code: new 
JavaCvErrorCallback().redirectError();
Instead, it crashes.

What version of the product are you using? On what operating system?
I am using the most recent version as of 5:07 PST on Tuesday, May 4, 2010. I am 
running Mac OS 
X 10.6.3.

Please provide any additional information below.
When I downloaded the link you had for jna.jar, it gave me a folder called 
jna.jar instead of a jar 
file. I then went into the folder with all the classes and used the manifest 
file to create a new jar. I 
used that new jar as my jna.jar file.

I also added the javacv.jar, ffmpeg-java.jar, procamlib.jar, and 
procamtracker.jar files, even 
though I am not using a camera. I am decoding a byte array. The code compiles 
just fine. I am 
not sure what else you would need from me. Thank you.

Original issue reported on code.google.com by jpjenkin...@gmail.com on 5 May 2010 at 12:13

GoogleCodeExporter commented 8 years ago
This seems to be a problem with the Eclipse debugger... can you confirm that it 
runs
correctly *outside* Eclipse, from the command line? Thank you

Samuel

Original comment by samuel.a...@gmail.com on 5 May 2010 at 12:50

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I am brand new to Java, so I am not entirely sure how to compile it outside of 
an IDE. I tried "javac *" from the 
current directory, but it complained.

What I did instead was downloaded NetBeans and tried it from there. This time I 
got a different error about a 
missing library:

debug:
Have no FileObject for 
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/jsfd.jar
Have no FileObject for 
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/sunrsasign.ja
r
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load 
library 'cxcore': 
dlopen(libcxcore.dylib, 9): image not found
        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:164)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:237)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:200)
        at name.audet.samuel.javacv.jna.Loader.load(Loader.java:44)
        at name.audet.samuel.javacv.jna.cxcore.<clinit>(cxcore.java:114)
        at name.audet.samuel.javacv.JavaCvErrorCallback.redirectError(JavaCvErrorCallback.java:95)
        at com.JohnJenkins.VideoFaceRecognition.FindFaces.FindFacesImage(FindFaces.java:32)
        at com.JohnJenkins.VideoFaceRecognition.VideoFaceServer.main(VideoFaceServer.java:16)
Java Result: 1
BUILD SUCCESSFUL (total time: 27 seconds)

I am now starting to believe that it is something I am missing and not your 
library, but I would appreciate any 
assistance you could give me. Where can I obtain a library with cxcore in it? 
Thank you.

Original comment by jpjenkin...@gmail.com on 5 May 2010 at 7:01

GoogleCodeExporter commented 8 years ago
You said you could compile it fine under Eclipse, so compile it under Eclipse, 
close
Eclipse, open a command line (aka terminal, console, whatever name Mac OS X 
uses),
and run Java from there

The error from NetBeans indicates that you did not install JNA 3.2.4 or more 
recent,
or OpenCV 1.0, 1.1pre1, 2.0 or 2.1. You need to install JNA 3.2.4 or more 
recent as
well as OpenCV 1.0, 1.1pre1, 2.0 or 2.1. All the URLs, sites, explanations and
everything is all in the README.txt file. Please take the time to reread it 
once more.

Samuel

Original comment by samuel.a...@gmail.com on 6 May 2010 at 3:12

GoogleCodeExporter commented 8 years ago
What I had originally done was install the OpenCV Framework as well as import 
an OpenCV.jar file, but neither of 
these were adequate. I have now installed OpenCV from source, and it appears to 
work until it loads the cascade 
file. It will crash giving different errors depending on if I am using Eclipse 
or NetBeans, but I believe they are 
both representing the same problem. Here is the relevant code:

        final String CASCADE_PATH = 
"/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.or
g_release_ports_graphics_o
pencv/work/OpenCV-2.0.0/data/haarcascades/";

    String cascadeName = CASCADE_PATH + "haarcascade_frontalface_alt.xml";
        CvHaarClassifierCascade cascade = new CvHaarClassifierCascade(cvLoad(cascadeName));

The cascade XML files are world readable, so that shouldn't be an issue. I have 
also tried different files, 
"haarcascade_frontalface_alt2.xml" for example, and they give the same error.

The error from Eclipse is:

OpenCV Error: Unspecified error (The node does not represent a user object 
(unknown type?))
in function cvRead, 
/Users/Phoenix/Downloads/OpenCV-2.1.0/src/cxcore/cxpersistence.cpp(4720)
java.lang.Exception: Stack trace
    at java.lang.Thread.dumpStack(Thread.java:1230)
    at name.audet.samuel.javacv.JavaCvErrorCallback.callback(JavaCvErrorCallback.java:67)
    at name.audet.samuel.javacv.jna.cxcore.cvLoad(Native Method)
    at name.audet.samuel.javacv.jna.cxcore.cvLoad(cxcore.java:3973)
    at com.JohnJenkins.VideoFaceRecognition.FindFaces.FindFacesImage(FindFaces.java:67)
    at com.JohnJenkins.VideoFaceRecognition.VideoFaceServer.main(VideoFaceServer.java:16)
terminate called after throwing an instance of 'cv::Exception'
  what():  /Users/Phoenix/Downloads/OpenCV-2.1.0/src/cxcore/cxpersistence.cpp:4720: error: (-2) The node 
does not represent a user object (unknown type?) in function cvRead

The error in NetBeans is correctly caught by my try-catch expression. It gives 
an exception type of 
"UncompilableSourceCode". This leads me to believe that the XML files are 
potentially corrupt or that I am 
supposed to be getting them from somewhere else. I looked at the files 
themselves, and they appear to be fine. 
Should I not be using the ones that come with the installation of OpenCV?

Thank you for your help.

Original comment by jpjenkin...@gmail.com on 7 May 2010 at 6:01

GoogleCodeExporter commented 8 years ago
That problem is not related to JavaCV... the "solution" is well documented on
OpenCV's wiki:
http://opencv.willowgarage.com/wiki/FaceDetection

Marking this issue as "done" as everything appears to be working as expected 
now...?

Original comment by samuel.a...@gmail.com on 8 May 2010 at 12:38

GoogleCodeExporter commented 8 years ago
Well, I openly admit my ignorance to OpenCV, but this code seems 
straightforward and is almost directly taken from your example.

package com.JohnJenkins.VideoFaceRecognition;

import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.imageio.ImageIO;

import name.audet.samuel.javacv.*;
import static name.audet.samuel.javacv.jna.cxcore.*;
import static name.audet.samuel.javacv.jna.cv.*;

public class FindFaces
{
        private static final String CASCADE_PATH = 
"/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.or
g_release_ports_graphics_opencv/work/OpenCV-
2.0.0/data/haarcascades/";

    public static FaceInfoArray FindFacesImage(Images images)
    {
        int i = 0;

                new JavaCvErrorCallback().redirectError();

                String cascadeName = CASCADE_PATH + "haarcascade_frontalface_default.xml";
                CvHaarClassifierCascade cascade = new CvHaarClassifierCascade(cvLoad(cascadeName)); // Throws error.

That is all the code it gets through before it throws the "Uncompilable Source 
Code" exception. This is taken almost directly from your 
example and is roughly equivalent to the example in the link you posted, so I 
don't see how this could be a problem with OpenCV, as 
opposed to JavaCV. 

I looked into it a little further and took out the cvLoad(cascadeName) from the 
CvHaarClassifierCascade() and created a local variable as 
such,

Pointer test = cvLoad(cascadeName);

which crashed with the same error.

Finally, I created a C++ program by copying the code that you linked to using 
the "haarcascade_frontalface_default.xml" file, and it worked 
just fine. This, to me, appears to localize the problem to JavaCV.

Original comment by jpjenkin...@gmail.com on 8 May 2010 at 2:08

GoogleCodeExporter commented 8 years ago
"Almost" is not "exactly the same". Copy/paste the Test2 class from
http://code.google.com/p/javacv/, *do not modify it*, and it will run.

Samuel

Original comment by samuel.a...@gmail.com on 8 May 2010 at 2:12

GoogleCodeExporter commented 8 years ago
Hi samuel,  
I want to suggest you to add the path "/opt/local/lib" in the cxcore class for 
those who installed opencv via 
Macports (that's the default installation directory) to avoid the first error 
discussed in this thread.
ps. thanks for the great work!

Original comment by starome...@gmail.com on 27 May 2010 at 12:38

GoogleCodeExporter commented 8 years ago
Ah, that's good to know.. thanks for letting me know, will do!

Original comment by samuel.a...@gmail.com on 27 May 2010 at 12:40

GoogleCodeExporter commented 8 years ago
Hi Samuel,
I was wondering if you have now included the default path for OpenCV when using 
Macports? Otherwise, any workaround so that I can use it on my Mac?

Thanks!

Original comment by pendieee...@hotmail.com on 25 Jan 2011 at 1:41

GoogleCodeExporter commented 8 years ago
It should work yes, let me know if it does not

Original comment by samuel.a...@gmail.com on 26 Jan 2011 at 4:26

GoogleCodeExporter commented 8 years ago
Hi,

For OpenCV Error: Unspecified error (The node does not represent a user object 
(unknown type?)) in function cvRead

Try to check your xml file. 
<opencv_storage>
<cascade type_id="opencv-haar-classifier">

If you did training and have your own cascade.xml file. Then add the above 
type_id in file. This error will be resolved.

Note: Old format of Xml file is required. so during opencv_traincascade add 
-baseFormatSave.

Thanks,
Lakshmiprabha

Original comment by nslakshm...@gmail.com on 13 Dec 2012 at 10:20