Results 1 to 2 of 2

Thread: JavaCV and WebCam

  1. #1
    Join Date
    Feb 2011
    Beans
    292

    JavaCV and WebCam

    I tried the following code using JavaCV library:

    public class JavaCVSample {

    public static void main(String[] args) throws Exception {
    String classifierName = "/usr/local/OpenCV/data/haarcascades/haarcascade_frontalface_alt.xml";

    Loader.load(opencv_objdetect.class);
    CvHaarClassifierCascade classifier = new

    CvHaarClassifierCascade(cvLoad(classifierName));

    CanvasFrame frame = new CanvasFrame("Some Title");

    // OpenCVFrameGrabber uses opencv_highgui, but other more versatile FrameGrabbers
    // include DC1394FrameGrabber, FlyCaptureFrameGrabber, OpenKinectFrameGrabber,
    // PS3EyeFrameGrabber, VideoInputFrameGrabber, and FFmpegFrameGrabber.
    FrameGrabber grabber = new OpenCVFrameGrabber(0);
    grabber.start();
    }
    }

    Following is the output:

    VIDIOC_QUERYMENU: Invalid argument
    VIDIOC_QUERYMENU: Invalid argument
    VIDIOC_QUERYMENU: Invalid argument
    HIGHGUI ERROR: V4L: Property <unknown property string>(16) not supported by device

    What is the problem? Is it due to the driver? If so, how do I upgrade the driver? The webcam I have is "PC Camera" (according to the manual of my SIS laptop).

  2. #2
    Join Date
    Feb 2011
    Beans
    292

    Re: JavaCV and WebCam

    However, I am still able to grab the image from webcam and display it by using the following code:


    import com.googlecode.javacpp.Loader;
    import com.googlecode.javacv.*;
    import static com.googlecode.javacv.cpp.opencv_core.*;
    import static com.googlecode.javacv.cpp.opencv_imgproc.*;
    import static com.googlecode.javacv.cpp.opencv_calib3d.*;
    import static com.googlecode.javacv.cpp.opencv_objdetect.*;

    public class MotionDetector {

    public static void main(String[] args) throws Exception {
    OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0);
    grabber.start();

    IplImage image = grabber.grab();


    CanvasFrame canvasFrame = new CanvasFrame("Web Cam Detection Going on");
    canvasFrame.setCanvasSize(image.width(), image.height());
    canvasFrame.setDefaultCloseOperation(CanvasFrame.E XIT_ON_CLOSE);

    // CvMemStorage storage = CvMemStorage.create();

    while (true) {
    image=grabber.grab();
    canvasFrame.showImage(image);
    }

    }

    }

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •