Ask Your Question

Schiawo's profile - activity

2013-09-27 12:40:01 -0500 commented question javacv NullpointerException loading image.

OK, i fixed the other one too.

2013-09-27 12:32:37 -0500 commented question javacv NullpointerException loading image.

It worked, thank you very much! can you say me something about this error? I think is the same problem but the image should be passed like configuration argument and i tried a path like "c:/my/folder/img1.png" but still not works. http://stackoverflow.com/questions/19051102/cvgetsize-error-in-javacv-face-detection-recognition-project

2013-09-27 12:16:20 -0500 asked a question javacv NullpointerException loading image.

I'm trying to execute this simple java class to test opencv and javacv correct installation:

    import static com.googlecode.javacv.cpp.opencv_core.*;
    import static com.googlecode.javacv.cpp.opencv_highgui.*;
    import com.googlecode.javacv.CanvasFrame;

    public class demo1 {
        public static void main(String[] args) {
            //Load image img1 as IplImage
            final IplImage image = cvLoadImage("img1.png");
            System.out.println("Image loaded");
            //create canvas frame named 'Demo'
            final CanvasFrame canvas = new CanvasFrame("Demo");
            //Show image in canvas frame
            canvas.showImage(image);
            //This will close canvas frame on exit
            canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
        }
    }

I receive this console output:

Image loaded
Exception in thread "main" java.lang.NullPointerException
    at com.googlecode.javacv.CanvasFrame.showImage(CanvasFrame.java:366)
    at com.googlecode.javacv.CanvasFrame.showImage(CanvasFrame.java:363)
    at demo1.main(demo1.java:14)

I installed OpenCV-2.4.6.0 in my win7 64bit pc

extracted it in C:\opencv,

set the environment variable PATH as C:\opencv\build\x64\vc11\bin,

i've got the Java SDK,

downloaded javacv (source and cppjars)

and added all opencv and javacv jar files in the Eclipse project.

The img1.png is in the same folder of demo1.java

What is the problem? Thank you for help.