java - Webcam has low FPS when recording using OpenCV? -
i've been working on building java application using opencv grabs data webcam , records it. however, i've been unable achieve frame rates greater 10 fps (intel i5-5200u, 8 gb ram), doesn't seem right me. webcam supports 30 fps , 1280 x 720 resolution. recording @ 640 x 480 increases 12 fps. recording @ 720p (which need application) nets aforementioned 10. first idea videocapture.read() function takes relatively long time process, tried moving calls thread pool, gave no gain. i've read how fast library supposed be, must doing wrong. below loop 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 storing camera images, provided opencv arraylist<mat> frameslist = new arraylist<>(); long starttime = system.currenttimemillis(); if( ! cam.isopened()) { system.err.println("camera not 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);
Comments
Post a Comment