I am currently using the Java Open Cv Library to take a series of consecutive images from a camera. The frame that is captured is then passed to another thread which saves the image. But, for some reason after it takes a certain amount it stops taking new images and instead just repeats the previous one.
If i ask it to take 10 it stops at 5, and for 20 it stops at 11, so it isn't the same value each time.
The code is currently inside of a thread but i do not think that this is affecting it in any way.
Here is the current code.
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
VideoCapture camera = new VideoCapture(0);
camera.open(0);
Mat frame = new Mat();
for (int i = 0; i < 20; i++) {
camera.read(frame);
fileName = "Captures/" + timetoNano + ".png";
fileTime = timetoNano;
fileToSave = frame;
ImageProperties newProperties = new ImageProperties(fileName,
fileToSave, fileTime);
bufferImageProps.add(newProperties);
}
If i put camera.open(0) inside of the for loop, this does fix the issue, it does however decrease performance greatly and i don't think it has to be there as it works up until this "breaking point".
Any feedback would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire