Ask Your Question

Revision history [back]

JavaCV: How to connect USB cam to system and capture?

Using the code posted below I've attempted to connect my Android device to my system. In hopes that I can execute this code and capture from there.

 public static void main(String[] args) {
    private static void captureFrame() {
    final OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(CV_CAP_ANDROID_BACK);
    try {
        IplImage img = grabber.grab();
        if (img != null) {
            cvSaveImage("capture.jpg", img);
    } catch (Exception e) {

This gives me the error of:

com.googlecode.javacv.FrameGrabber$Exception: cvCreateCameraCapture() Error: Could not create camera capture.
    at com.googlecode.javacv.OpenCVFrameGrabber.start(
    at javacv.demos.JavaCVDemos.captureFrame(
    at javacv.demos.JavaCVDemos.main(
BUILD SUCCESSFUL (total time: 1 second)