jloyd / javacv

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

javacv imposible to load image (OpenCV 2.2) #42

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.i install OpenCV-2.2.0-win32-vs2010 in c:\openCV
2.Then i create a new project in the NETBEANS at windows XP platform
Then i add javaCV and JNA in the library of the projrct in the netbeans
3.Then i use the following code    

 import static com.googlecode.javacv.jna.cv.CV_BGR2GRAY;
import static com.googlecode.javacv.jna.cv.cvCvtColor;
import static com.googlecode.javacv.jna.cv.cvHaarDetectObjects;
import static com.googlecode.javacv.jna.cxcore.CV_AA;
import static com.googlecode.javacv.jna.cxcore.IPL_DEPTH_8U;
import static com.googlecode.javacv.jna.cxcore.cvGetSeqElem;
import static com.googlecode.javacv.jna.cxcore.cvLoad;
import static com.googlecode.javacv.jna.cxcore.cvPoint;
import static com.googlecode.javacv.jna.cxcore.cvRectangle;
import static com.googlecode.javacv.jna.highgui.cvLoadImage;
import static com.googlecode.javacv.jna.highgui.cvSaveImage;
import com.googlecode.javacv.JavaCvErrorCallback;
import com.googlecode.javacv.jna.cv.CvHaarClassifierCascade;
import com.googlecode.javacv.jna.cxcore.CvMemStorage;
import com.googlecode.javacv.jna.cxcore.CvPoint;
import com.googlecode.javacv.jna.cxcore.CvRect;
import com.googlecode.javacv.jna.cxcore.CvScalar;
import com.googlecode.javacv.jna.cxcore.CvSeq;
import com.googlecode.javacv.jna.cxcore.IplImage;
import java.io.IOException;

public class test {

    // The cascade definition to be used for detection.
private static final String CASCADE_FILE = "haarcascade_frontalface_alt.xml";

    public static void main(String arg[])throws Exception
    {
        // This will redirect the OpenCV errors to the Java console to give you
        // feedback about any problems that may occur.
        new JavaCvErrorCallback().redirectError();

        // Load the original image.
        IplImage originalImage= cvLoadImage("E:\\PhotoGallery\\Sceneries\\golf insignia.jpg",1);

        // We need a grayscale image in order to do the recognition, so we
        // create a new image of the same size as the original one.
        IplImage grayImage = IplImage.create(originalImage.width, originalImage.height, IPL_DEPTH_8U, 1);

        // We convert the original image to grayscale.
        cvCvtColor(originalImage, grayImage, CV_BGR2GRAY);

        CvMemStorage storage = CvMemStorage.create();

        // We instantiate a classifier cascade to be used for detection, using the cascade definition.
        CvHaarClassifierCascade cascade = new CvHaarClassifierCascade(cvLoad(CASCADE_FILE));

        // We detect the faces.
        CvSeq faces = cvHaarDetectObjects(grayImage, cascade, storage, 1.1, 1, 0);

        //We iterate over the discovered faces and draw yellow rectangles around them.
            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);

            }

        // Save the image to a new file.
        cvSaveImage("E:\\PhotoGallery", originalImage);

    }

}

What is the expected output? What do you see instead?
i except the output images with rectangles at the faces , But u got the 
following error

run:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load 
library 'cxcore': The specified module could not be found.

        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:199)
        at com.googlecode.javacv.jna.Loader.load(Loader.java:44)
        at com.googlecode.javacv.jna.cxcore.<clinit>(cxcore.java:113)
        at com.googlecode.javacv.JavaCvErrorCallback.redirectError(JavaCvErrorCallback.java:95)
        at samplejavacv.test.main(test.java:43)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

What version of the product are you using? On what operating system?

I am using NETBEANS 6.9.1 in WINDOWS XP professional platform

But one doubt : may i need to build the openCV with cmake ? (here i didn't do 
that)  

Please provide any additional information below.

Original issue reported on code.google.com by sijopull...@gmail.com on 29 Dec 2010 at 3:49

GoogleCodeExporter commented 9 years ago
JavaCV does not work with OpenCV 2.2 yet

Original comment by samuel.a...@gmail.com on 30 Dec 2010 at 1:59

GoogleCodeExporter commented 9 years ago
Latest version supports OpenCV 2.2. Please change status to "Verified".

Original comment by samuel.a...@gmail.com on 19 Feb 2011 at 3:51