I am implementing a simple eye tracker, which requires fast screenshoting of what is happening on the screen simultaneously with capturing the video from webcam.
The thing is that the way of doing it with Robot, mentioned here: https://stackoverflow.com/questions/2475303/java-library-for-capturing-active-window-screenshot is extremely slow.
By the way, retrieving the video from a webcam works much faster and returns the byte array, which is very fast to be processed.
Does anybody know a faster solution? C++ libraries, which can be linked to Java for doing this may help as well.
Thank you!
UPDATE: Decided to switch to OpenCV, now looking for the way to make screenshot with it :)
May be you can make use of JMF.. Checkout the Screen Grabber code @ Oracle's site. I think it will help you solve your problem.
The
robot.createScreenCapture(captureSize);
call takes about 20ms for me.u should definitely give a shot to OpenCV
Here's a Windows-specific version using JNA that I am using in one of my projects.
I have found it to be an order-of-magnitude faster than
Robot
, even with the native call overhead.