Ask Your Question

aknobloch's profile - activity

2016-03-07 09:35:23 -0600 commented question Can't get > 10 FPS (Java)

Thanks for the reply. Unfortunately I don't have any other cameras at my disposal right now. But other built-in applications can record at 720p up to 20 FPS, so I don't think it's a hardware issue.

I'm not sure how to implement a visualization in OpenCV, but I've done a live stream using a different library called Webcam-Capture and it supplied 30 FPS. But as soon as I attempt to actually record the stream, the FPS staggers, which is understandable. But I would think, then, that moving the actual recording process to a separate thread would at least moderately increase the FPS...but no such luck.

2016-03-07 00:52:14 -0600 asked a question Can't get > 10 FPS (Java)

Hey all, I've been working on building a Java application using OpenCV that grabs data from the webcam and records it. However, I've been unable to achieve frame rates greater than 10 FPS (Intel i5-5200u, 8 GB RAM), which doesn't seem right to me. My webcam supports up to 30 FPS and 1280 x 720 resolution. Recording at 640 x 480 only increases to about 12 FPS. Recording at 720p (which I need to do for my application) nets the aforementioned 10. My first idea was that the VideoCapture.read() function takes a relatively long time to process, so I tried moving those calls to a thread pool, but it gave no gain. I've read all about how fast this library is supposed to be, so I must be doing something wrong. Below is the loop for capturing data:

VideoCapture cam = new VideoCapture();
    cam.open(0);

    // set proper resolution
    cam.set(Videoio.CV_CAP_PROP_FRAME_WIDTH, CAMERA_WIDTH);
    cam.set(Videoio.CV_CAP_PROP_FRAME_HEIGHT, CAMERA_HEIGHT);

    // Matrix for storing camera images, provided by OpenCV
    ArrayList<Mat> framesList = new ArrayList<>();

    long startTime = System.currentTimeMillis();

    if( ! cam.isOpened()) {
        System.err.println("Camera could not be opened.");
    }

    else {
        System.out.println("Capturing...");

        while(System.currentTimeMillis() - startTime < 1000 * SECONDS_TO_RUN) {

            Mat frame = new Mat();
            cam.read(frame);
            framesList.add(frame);

        }

        cam.release();

        System.out.println("Done recording. " + framesList.size() + " frames captured.");
        System.out.println("Framerate : " + framesList.size() / SECONDS_TO_RUN);