sarxos / webcam-capture

The goal of this project is to allow integrated or USB-connected webcams to be accessed directly from Java. Using provided libraries users are able to read camera images and detect motion. Main project consist of several sub projects - the root one, which contains required classes, build-in webcam driver compatible with Windows, Linux and Mac OS, which can stream images as fast as your camera can serve them (up to 50 FPS). Main project can be used standalone, but user is able to replace build-in driver with different one - such as OpenIMAJ, GStreamer, V4L4j, JMF, LTI-CIVIL, FMJ, etc.
http://webcam-capture.sarxos.pl
MIT License
2.25k stars 1.11k forks source link

Caused by: java.lang.NullPointerException at org.bytedeco.javacv.FrameGrabber.create(FrameGrabber.java:94) #236

Open ankurb0308 opened 10 years ago

ankurb0308 commented 10 years ago

Hi All,

I am new to this thing and got stuck please have a look below code and Error along with the console output and advice what I am missing. any help or clue would be highly appreciated.

Code :

import javax.swing.JFrame;

import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.WebcamPanel;
import com.github.sarxos.webcam.ds.javacv.JavaCvDriver;
public class CameraCapture {

    static {
        Webcam.setDriver(new JavaCvDriver());
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame("LTI-CIVIL Webcam Capture Driver Example");
        System.out.println("List webcam : "  + Webcam.getWebcams());
        Webcam availableWebcam = null;
        for(Webcam wc : Webcam.getWebcams()){
            if (wc.getName().equalsIgnoreCase("USB Video Device")) {
                availableWebcam = wc;
            }
        }

        frame.add(new WebcamPanel(availableWebcam));
        frame.pack();
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

Error & Console output :

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
List webcam : [Webcam USB Video Device]
Exception in thread "main" com.github.sarxos.webcam.WebcamException: Cannot execute task
    at com.github.sarxos.webcam.WebcamProcessor$AtomicProcessor.process(WebcamProcessor.java:62)
    at com.github.sarxos.webcam.WebcamProcessor.process(WebcamProcessor.java:130)
    at com.github.sarxos.webcam.WebcamTask.process(WebcamTask.java:38)
    at com.github.sarxos.webcam.ds.cgt.WebcamOpenTask.open(WebcamOpenTask.java:20)
    at com.github.sarxos.webcam.Webcam.open(Webcam.java:272)
    at com.psi.test.camera.CameraCapture.main(CameraCapture.java:27)
Caused by: java.lang.NullPointerException
    at org.bytedeco.javacv.FrameGrabber.create(FrameGrabber.java:94)
    at org.bytedeco.javacv.FrameGrabber.createDefault(FrameGrabber.java:117)
    at com.github.sarxos.webcam.ds.javacv.JavaCvDevice.buildGrabber(JavaCvDevice.java:91)
    at com.github.sarxos.webcam.ds.javacv.JavaCvDevice.open(JavaCvDevice.java:113)
    at com.github.sarxos.webcam.ds.cgt.WebcamOpenTask.handle(WebcamOpenTask.java:38)
    at com.github.sarxos.webcam.WebcamProcessor$AtomicProcessor.run(WebcamProcessor.java:71)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

VIDEOINPUT SPY MODE!

SETUP: Looking For Capture Devices
SETUP: 0) USB Video Device 
SETUP: 1 Device(s) found
rakeshbhatt10 commented 10 years ago

Hi ankurb0308,

I have created another issue with same driver you are trying to do. I got unsatisfied link error while javacv and opencv configured correctly and samples of javacv working perfectly. Can you tell me how you resolved unsatisfied link error.

Thanks, Rakesh

karldonitz commented 4 years ago

You need slf4j-nop.jar