VideoCapture (0) does not work in mac Catalina. The program crashed

asked 2020-01-24 05:05:37 -0500

robertodaza gravatar image

updated 2020-01-24 09:44:22 -0500

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?

edit retag flag offensive close merge delete

Comments

1

it's not an opencv problem, your process needs special permission to use the camera with your os

berak gravatar imageberak ( 2020-01-24 05:08:44 -0500 )edit

How can I create the permission? I would be very grateful if you will help me

robertodaza gravatar imagerobertodaza ( 2020-01-24 05:16:09 -0500 )edit
1

sorry, no idea, you'll have to ask apple users

berak gravatar imageberak ( 2020-01-24 05:34:54 -0500 )edit
1

In version 4.2.0 of opencv throws an 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!

I don't know how to fix it?

robertodaza gravatar imagerobertodaza ( 2020-01-24 09:46:27 -0500 )edit

Upgraded OpenCV 4.2.0.

supra56 gravatar imagesupra56 ( 2020-01-24 21:02:06 -0500 )edit