webcam-capture icon indicating copy to clipboard operation
webcam-capture copied to clipboard

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

Open ankurb0308 opened this issue 10 years ago • 2 comments

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

ankurb0308 avatar Jul 18 '14 06:07 ankurb0308

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

rakeshbhatt10 avatar Jul 21 '14 08:07 rakeshbhatt10

You need slf4j-nop.jar

karldonitz avatar May 15 '20 13:05 karldonitz