Anooj Krishnan G
Anooj Krishnan G

Reputation: 859

JAVACV : Webcam capturing using javacv

Tried to capture from a webcam using the JAVACV library. But it throws an UnsatisfiedLinkError. Stack trace is as follows:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
C:\Users\anooj\AppData\Local\Temp\javacpp7955905460040\jniopencv_core.dll: %1 is not a valid Win32 application
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1928)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1825)
at java.lang.Runtime.load0(Runtime.java:792)
at java.lang.System.load(System.java:1059)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:418)
at com.googlecode.javacpp.Loader.load(Loader.java:368)
at com.googlecode.javacpp.Loader.load(Loader.java:315)
at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:131)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.googlecode.javacpp.Loader.load(Loader.java:334)
at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:96)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.googlecode.javacpp.Loader.load(Loader.java:334)
at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:91)
at com.googlecode.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:170)
at javaapplication16.JavaApplication16.captureframe(JavaApplication16.java:24)
at javaapplication16.JavaApplication16.main(JavaApplication16.java:38)
Java Result: 1

Our code is below:

import com.googlecode.javacv.OpenCVFrameGrabber;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import static com.googlecode.javacv.cpp.opencv_highgui.cvSaveImage;

public class JavaApplication16 {

/**
 * @param args the command line arguments
 */
    public static void captureframe()
    {
        OpenCVFrameGrabber grabber=new OpenCVFrameGrabber(0);
        try
        {
            grabber.start();
            IplImage img=grabber.grab();
            if(img!=null)
            {
                cvSaveImage("capture.jpg", img);
            }
        }
        catch(Exception ae)
        {
            ae.printStackTrace();

        }
    }
    public static void main(String[] args) {
        captureframe();
    }    
}

Upvotes: 1

Views: 8834

Answers (3)

Ishwor
Ishwor

Reputation: 181

Remember that the version of openCV and javaCV must match. Download latest version openCV 2..46 http://opencv.org/downloads.html

and download the javacp https://code.google.com/p/javacv/downloads/list [Note: choose the javacv-0.6-cppjars.zip 85.0 MB]

In this case you will not get Exception in thread "main" java.lang.UnsatisfiedLinkError:

My Code is running successfully.

Upvotes: 2

codeDEXTER
codeDEXTER

Reputation: 1261

see this link to solve the error you got Link1

see this link for the program to capture the image from camera, save it in a JPG format and show it on a canvas Link2

hope it solves your query.

Upvotes: 1

nikhil
nikhil

Reputation: 408

Upvotes: 2

Related Questions