capture image to slow with java
open webcam, read and releas takes about 600ms. Is there a way to speed-up? Using it on Windows 7 with latest java and recent opencv:
VideoCapture webcam = new VideoCapture();
boolean opened = webcam.opened();
if (opened) {
return null;
}
try {
webcam.open(0);
} catch (Exception e) {
return null;
}
if (!webcam.opened()) {
return null;
}
try {
Mat frame = new Mat();
webcam.read(frame);
//do somethinig
webcam.release();
} catch (Exception e) {
null
}
return null;
So many information about your system, camera etc.
@Monster You're right. I did add more information
Does it speed up if you dont use try catch?
No, it doesn't help.
Would it be possible for you to try the same on c++? If it takes the same time, you wont really be able to speed it up I guess
Never used c++, so it gonna take a while
What might bring a little speed is to directly call new VideoCapture(0) and then only check once webcam.opened(), but maybe only a little bit.
Well, camera initialization does take a while, even in pure C/C++.
(sorry, initially posted as answer, now posting as comment, I'm a little new to this site)
Can you confirm which part of the code is slow? Is it opening the camera, or reading frames?
I'm asking because I have discovered that opening a connection to an IP camera in Java is horribly slow (have to wait a whole minute), but getting frames from the camera afterwards runs at reasonable speed.