VideoCapture (0) of opencv 3.4.5 in eclipse does not work for me. The program crashes. I don't know if it has to do with Catalina's permits.
How can I fix the error?
Thanks in advance.
This is the code:
package prueba;
import java.awt.AWTException; import java.awt.image.BufferedImage; import java.awt.image.DataBufferByte; import java.awt.image.WritableRaster; import java.io.File; import java.io.IOException; import java.time.LocalTime;
import javax.imageio.ImageIO;
import org.opencv.core.Core; import org.opencv.core.Mat;
import org.opencv.videoio.VideoCapture;
public class prueba {
public static void main (String args[]) throws InterruptedException{
int i=0;
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
File directorio=new File("Capturas");
directorio.mkdir();
VideoCapture camera = new VideoCapture(0);//program crashes
System.out.println("It doesn't arrive here");
Mat frame = new Mat();
while (i<20) {
if(!camera.isOpened()){
System.out.println("Error");
}
else {
System.out.println("all right");
}
i++;
}
camera.release();//close
}
}