1 | initial version |
I think the issue is you need to initialise the Mat instance you pass to capture.read(). Its currently null in your code.
Mat image = new Mat();
Also, read() also performs both a grab() and retrieve() internally, so you don't need to call grab() beforehand.
while (i<10) {
try {
capture.read(image);
} catch (Exception e) {
System.out.println("Null Pointer Exception during Read");
}
i=i+1;
}
I had a similar issue earlier, hope this helps!