VideoCapture (0) does not work in mac Catalina. The program crashed
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. Eclipse does not throw error.
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
}
}
upgrade
I just downloaded the latest version of opencv 4.2.0 and now show the following error:
OpenCV: not authorized to capture video (status 0), requesting...
OpenCV: can not spin main run loop from other thread, set OPENCV_AVFOUNDATION_SKIP_AUTH=1 to disable authorization request and perform it in your application.
OpenCV: camera failed to properly initialize!
how i can setup OPENCV_AVFOUNDATION_SKIP_AUTH = 1 to disable the authorization request?
it's not an opencv problem, your process needs special permission to use the camera with your os
How can I create the permission? I would be very grateful if you will help me
sorry, no idea, you'll have to ask apple users
In version 4.2.0 of opencv throws an error:
I don't know how to fix it?
Upgraded OpenCV 4.2.0.