Closed GoogleCodeExporter closed 8 years ago
I don't see "Demo" anywhere in your stack trace. If there is more to the strack
trace, please provide it, otherwise, I cannot help you.
Original comment by samuel.a...@gmail.com
on 27 Feb 2011 at 2:13
Hi,
I have a problem. I'm using Win7, JDK 6, Eclipse, OpenCV 2.2. I put :
javacpp.jar javacv-windows-x86.jar javacv.jar and jnacv.jar to my project
classpath. Also, OpenCV has been installed with Add to path.. option, means
C:\OpenCV2.2\bin path is included to system path.
The code I have is
package javacv;
import static com.googlecode.javacv.cpp.opencv_core.CV_AA;
import static com.googlecode.javacv.cpp.opencv_core.IPL_DEPTH_8U;
import static com.googlecode.javacv.cpp.opencv_core.cvGetSeqElem;
import static com.googlecode.javacv.cpp.opencv_core.cvLoad;
import static com.googlecode.javacv.cpp.opencv_core.cvPoint;
import static com.googlecode.javacv.cpp.opencv_core.cvRectangle;
import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImage;
import static com.googlecode.javacv.cpp.opencv_highgui.cvSaveImage;
import static com.googlecode.javacv.cpp.opencv_imgproc.CV_BGR2GRAY;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvCvtColor;
import static com.googlecode.javacv.cpp.opencv_objdetect.cvHaarDetectObjects;
import com.googlecode.javacv.JavaCvErrorCallback;
import com.googlecode.javacv.cpp.opencv_core.CvMemStorage;
import com.googlecode.javacv.cpp.opencv_core.CvRect;
import com.googlecode.javacv.cpp.opencv_core.CvScalar;
import com.googlecode.javacv.cpp.opencv_core.CvSeq;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import com.googlecode.javacv.cpp.opencv_objdetect.CvHaarClassifierCascade;
public class FaceDetection {
private static final String CASCADE_FILE = "C:\\OpenCV2.2\\data\\haarcascades\\haarcascade_frontalface_alt.xml";
public static void main(String[] args) throws Exception {
// new JavaCvErrorCallback().toString();
IplImage originalImage = cvLoadImage("daniel1.jpg", 1);
IplImage grayImage = IplImage.create(originalImage.width(), originalImage.height(), IPL_DEPTH_8U, 1);
cvCvtColor(originalImage, grayImage, CV_BGR2GRAY);
CvMemStorage storage = CvMemStorage.create();
CvHaarClassifierCascade cascade = new CvHaarClassifierCascade(cvLoad(CASCADE_FILE));
CvSeq faces = cvHaarDetectObjects(grayImage, cascade, storage, 1.1, 1, 0);
for (int i = 0; i < faces.total(); i++) {
CvRect r = new CvRect(cvGetSeqElem(faces, i));
cvRectangle(originalImage, cvPoint(r.x(), r.y()), cvPoint(
r.x() + r.width(), r.y() + r.height()), CvScalar.YELLOW, 1, CV_AA,
0);
}
cvSaveImage(args[1], originalImage);
}
}
And the exception I got is :
OpenCV Error: Unspecified error (The node does not represent a user object
(unknown type?)) in unknown function, file
..\..\..\..\ocv\opencv\modules\core\src\persistence.cpp, line 4811
Exception in thread "main" java.lang.RuntimeException:
..\..\..\..\ocv\opencv\modules\core\src\persistence.cpp:4811: error: (-2) The
node does not represent a user object (unknown type?)
at com.googlecode.javacv.cpp.opencv_core.cvLoad(Native Method)
at com.googlecode.javacv.cpp.opencv_core.cvLoad(opencv_core.java:3919)
at javacv.FaceDetection.main(FaceDetection.java:49)
line 49 is :
CvHaarClassifierCascade cascade = new
CvHaarClassifierCascade(cvLoad(CASCADE_FILE));
I'm Java programmer, I don't have any clue about C or C++ programming.
Please, help me with this. I have to do a face recognition project.
Any idea will be helpful.
Thank you.
Original comment by darius...@googlemail.com
on 27 Feb 2011 at 11:09
Hi Samuel,
Here is the stack trace:
[java] Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniCvScalar in java.library.path
[java] at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
[java] at java.lang.Runtime.loadLibrary0(Runtime.java:823)
[java] at java.lang.System.loadLibrary(System.java:1028)
[java] at com.googlecode.javacpp.Loader.load(Loader.java:311)
[java] at com.googlecode.javacpp.Loader.load(Loader.java:258)
[java] at com.googlecode.javacv.cpp.opencv_core$CvScalar.<clinit>(opencv_core.java:2151)
[java] at java.lang.Class.forName0(Native Method)
[java] at java.lang.Class.forName(Class.java:169)
[java] at com.googlecode.javacpp.Loader.load(Loader.java:276)
[java] at com.googlecode.javacpp.Loader.load(Loader.java:258)
[java] at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:120)
[java] at java.lang.Class.forName0(Native Method)
[java] at java.lang.Class.forName(Class.java:169)
[java] at com.googlecode.javacpp.Loader.load(Loader.java:276)
[java] at com.facebase.detector.Demo.main(Unknown Source)
Here is how I start example code.
/usr/lib/jvm/java-6-sun-1.6.0.22/jre/bin/java -classpath
/home/dieman/workspace/facematch/faceparser/lib/javacpp.jar:/home/dieman/workspa
ce/facematch/faceparser/lib/javacv-linux-x86.jar:/home/dieman/workspace/facematc
h/faceparser/lib/javacv.jar:/home/dieman/workspace/facematch/faceparser/demo.jar
com.detector.Demo
Here is the simplest code that produces the exception:
package com.detector;
import com.googlecode.javacv.cpp.opencv_core;
import static com.googlecode.javacv.cpp.opencv_core.*;
public class Demo {
public static void main(String[] args) throws Exception {
com.googlecode.javacpp.Loader.load(opencv_core.class);
}
}
Original comment by dmitriy.kuptsov@gmail.com
on 27 Feb 2011 at 12:14
Dimitry, this probably means you did not install OpenCV 2.2 correctly.. When
you tried to install it, did you run *both*
make install
and
ldconfig
? Please read the documentation of OpenCV 2.2 to understand how to install it
properly, thank you.
Darius, you need to add this line before cvLoad(), as clearly indicated in the
README.txt file:
Loader.load(opencv_objdetect.class);
Original comment by samuel.a...@gmail.com
on 27 Feb 2011 at 1:02
Thank you!
Original comment by dmitriy.kuptsov@gmail.com
on 27 Feb 2011 at 1:27
And JDK update 22 is kind of old.. Maybe there are bugs in there preventing
JavaCPP from working properly. Please update to the latest version and let me
know if this solves your issue.
Original comment by samuel.a...@gmail.com
on 27 Feb 2011 at 2:16
I have update to sun-jdk-1.6.24 and also recompiled the OpenCV library (made
make install). Still the same error:
[java] Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniCvErrorCallback in java.library.path
[java] at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
[java] at java.lang.Runtime.loadLibrary0(Runtime.java:840)
[java] at java.lang.System.loadLibrary(System.java:1047)
[java] at com.googlecode.javacpp.Loader.load(Loader.java:309)
[java] at com.googlecode.javacpp.Loader.load(Loader.java:258)
[java] at com.googlecode.javacv.cpp.opencv_core$CvErrorCallback.<clinit>(opencv_core.java:3962)
[java] at java.lang.Class.forName0(Native Method)
[java] at java.lang.Class.forName(Class.java:186)
[java] at com.googlecode.javacpp.Loader.load(Loader.java:275)
[java] at com.googlecode.javacpp.Loader.load(Loader.java:258)
[java] at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:120)
[java] at java.lang.Class.forName0(Native Method)
[java] at java.lang.Class.forName(Class.java:186)
[java] at com.googlecode.javacpp.Loader.load(Loader.java:275)
[java] at com.facebase.detector.Demo.main(Unknown Source)
Original comment by dmitriy.kuptsov@gmail.com
on 27 Feb 2011 at 3:06
I have tried also to switch to OpenJDK. Did not help. I wonder why it tries to
load jniCvErrorCallback as a "so" library? Compilation of javacv does not
produce such library.
Original comment by dmitriy.kuptsov@gmail.com
on 27 Feb 2011 at 3:08
I have also noticed (when debugging) that Loader tries to load native libraries
for nested classes CvErrorCallback, CvScalar and CvSize found in opencv_core
class:
linux-x86/libjniCvErrorCallback.so
linux-x86/libjniCvScalar.so
linux-x86/libjniCvSize.so
Should such libraries exist in com/googlecode/javacv/cpp/linux-x86 ?
If yes then javacpp does not compile them. If not then why does loader tries to
load them anyways?
--Dmitriy
Original comment by dmitriy.kuptsov@gmail.com
on 27 Feb 2011 at 10:00
No, it should not try to load them.. the only reason I can see why this is
happening must have something to do with bugs inside your Java, some mix up in
the files it's supposed to use, or maybe even a bad Java compiler (the
incremental one from Eclipse, notoriously)
Original comment by samuel.a...@gmail.com
on 28 Feb 2011 at 1:53
Fine, I have compiled on different machine and it worked. I wonder, what could
be the reason?
Original comment by dmitriy.kuptsov@gmail.com
on 28 Feb 2011 at 9:55
Good question, please let me know if you find out... IMO, it's probably
something in your classpath interfering with the system class loader. You know,
try to empty your lib/ext directory and such.
Original comment by samuel.a...@gmail.com
on 28 Feb 2011 at 10:01
Hi,
I did as you said and not I'm having other exception
The code is
public class FaceDetection {
private static final String CASCADE_FILE = "haarcascade_frontalface_default.xml";
public static void main(String[] args) throws Exception {
Loader.load(opencv_objdetect.class);
IplImage originalImage = cvLoadImage("daniel1.jpg", 1);
IplImage grayImage = IplImage.create(originalImage.width(), originalImage.height(), IPL_DEPTH_8U, 1);
cvCvtColor(originalImage, grayImage, CV_BGR2GRAY);
CvMemStorage storage = CvMemStorage.create();
// Even I put Loader.load(opencv_objdetect.class); here the exception is the same.
CvHaarClassifierCascade cascade = new CvHaarClassifierCascade(cvLoad(CASCADE_FILE));
CvSeq faces = cvHaarDetectObjects(grayImage, cascade, storage, 1.1, 1, 0);
for (int i = 0; i < faces.total(); i++) {
CvRect r = new CvRect(cvGetSeqElem(faces, i));
cvRectangle(originalImage, cvPoint(r.x(), r.y()), cvPoint(
r.x() + r.width(), r.y() + r.height()), CvScalar.YELLOW, 1, CV_AA,
0);
}
cvSaveImage("result.jpg", originalImage);
}
}
What I'm receiving now is :
Exception in thread "main" java.lang.UnsatisfiedLinkError:
C:\Users\Daniel\AppData\Local\Temp\jniopencv_core4539731836344541513.dll: Can't
find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:308)
at com.googlecode.javacpp.Loader.load(Loader.java:258)
at com.googlecode.javacv.cpp.opencv_core$CvPoint.<clinit>(opencv_core.java:1733)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacpp.Loader.load(Loader.java:258)
at com.googlecode.javacv.cpp.opencv_core$CvSize.<clinit>(opencv_core.java:2047)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacpp.Loader.load(Loader.java:258)
at com.googlecode.javacv.cpp.opencv_core$CvScalar.<clinit>(opencv_core.java:2151)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacpp.Loader.load(Loader.java:258)
at com.googlecode.javacv.cpp.opencv_core$CvErrorCallback.<clinit>(opencv_core.java:3962)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacpp.Loader.load(Loader.java:258)
at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:120)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:87)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:88)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacv.cpp.opencv_objdetect.<clinit>(opencv_objdetect.java:85)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at javacv.FaceDetection.main(FaceDetection.java:37)
Thank you, Samuel.
Original comment by darius...@googlemail.com
on 28 Feb 2011 at 2:59
Line 37, from previous code snapshot is :
Loader.load(opencv_objdetect.class);
Original comment by darius...@googlemail.com
on 28 Feb 2011 at 3:01
Hi, I have resolved the problem. It was the directory where I have installed
OpenCV libraries/include files: change from /usr/local to /usr/ solved the
issue. I guess these paths are hard coded in javacpp, are they?
Original comment by dmitriy.kuptsov@gmail.com
on 28 Feb 2011 at 5:19
Dmitriy, as detailed in OpenCV's documentation, if you wish to install OpenCV
in /usr/local/, you need to make sure your Linux is looking for libraries in
/usr/local/. This is NOT enabled by default. Please read the documentation when
someone asked you to read the documentation, thank you.
Darius, I think your installation of Java 6 or OpenCV 2.2 has changed.. What
happens if you place Loader.load(opencv_core.class) before
Loader.load(opencv_objdetect.class)? If you still get that error, please try to
figure out what may have changed with your installations of Java 6 and OpenCV
2.2
Original comment by samuel.a...@gmail.com
on 1 Mar 2011 at 1:59
Hi Samuel,
dario probe code and I shot this problem
import static name.audet.samuel.javacv.jna.cxcore.*;
import static name.audet.samuel.javacv.jna.cv.*;
import static name.audet.samuel.javacv.jna.highgui.*;
import static name.audet.samuel.javacv.jna.cvaux.*;
import java.util.concurrent.TimeUnit;
import name.audet.samuel.javacv.CanvasFrame;
import name.audet.samuel.javacv.FrameGrabber;
import name.audet.samuel.javacv.JavaCvErrorCallback;
import name.audet.samuel.javacv.OpenCVFrameGrabber;
public class mainPrg
{
public static void main(String[] args) throws Exception
{
new JavaCvErrorCallback().redirectError();
IplImage imageCam = null;
FrameGrabber ofg = new OpenCVFrameGrabber("test.avi");
CanvasFrame window = new CanvasFrame("Video Player");
try
{
ofg.start();
} catch (Exception e)
{ e.printStackTrace(); }
try
{
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e)
{ e.printStackTrace(); }
while ((imageCam = ofg.grab()) != null)
{
if (imageCam != null)
window.showImage(imageCam);
cvReleaseImage(imageCam.pointerByReference());
}
window.dispose();
}
}
And the exception I got is :
OpenCV Error: Null pointer (Invalid classifier cascade) in unknown function,
file ..\..\..\..\ocv\opencv\modules\objdetect\src\haar.cpp, line 1013
Exception in thread "main" java.lang.RuntimeException:
..\..\..\..\ocv\opencv\modules\objdetect\src\haar.cpp:1013: error: (-27)
Invalid classifier cascade
at com.googlecode.javacv.cpp.opencv_objdetect.cvHaarDetectObjects(Native Method)
at com.googlecode.javacv.cpp.opencv_objdetect.cvHaarDetectObjects(opencv_objdetect.java:226)
at otrosUtilizanjavacv.FaceDetection.main(FaceDetection.java:67)
Please, help me with this
Original comment by mariovir...@gmail.com
on 1 Mar 2011 at 12:11
I thought Darius said he figured out what was wrong with his code. Anyway,
everything that you guys have been discussing here don't seem to be issues with
JavaCV. If you still have problems /using/ JavaCV, please post your questions
on the mailing list, thank you
Original comment by samuel.a...@gmail.com
on 5 Mar 2011 at 2:27
java.lang.UnsatisfiedLinkError:
C:\Users\Administrator\AppData\Local\Temp\jniopencv_core7516365096713185536.dll:
Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at com.googlecode.javacpp.Loader.load(Loader.java:332)
at com.googlecode.javacpp.Loader.load(Loader.java:266)
at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:118)
at Main.<clinit>(Main.java:25)
Exception in thread "main"
Original comment by saileizh...@gmail.com
on 24 Aug 2011 at 11:33
FYI:
Common issues with OpenCV under Windows 7
http://code.google.com/p/javacv/wiki/Windows7AndOpenCV
Original comment by samuel.a...@gmail.com
on 27 Aug 2011 at 7:55
Original issue reported on code.google.com by
dmitriy.kuptsov@gmail.com
on 26 Feb 2011 at 3:51