It seems that your device does not support camera(or it is locked)

后端 未结 6 1649
悲哀的现实
悲哀的现实 2020-12-16 12:13

Android opencv samples and tutorials were running fine and suddenly one day I get this for all of those:
\"It seems that your device does not support

相关标签:
6条回答
  • 2020-12-16 12:46

    In my case, the issue was
    My application use Android Camera in another activity
    And another activity was not release the Camera after use it on Destroyed (lock it)
    And after I release the Camera on the another activity, this dialog will not showed again.

    So generally to fix this issue

    1. Check CAMERA permissions
    2. Check CAMERA not locked (by releasing it after usage in any other activities)
    0 讨论(0)
  • 2020-12-16 12:47

    From the Android Docs:

    Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app.

    It means that on Android 23 or above, besides the manifest, you need to request permission on runtime as well. In this case, camera access.

    To do this, you can use the code below:

    // First check android version 
    if (MyVersion > Build.VERSION_CODES.LOLLIPOP_MR1) {
    //Check if permission is already granted
    //thisActivity is your activity. (e.g.: MainActivity.this)
        if (ContextCompat.checkSelfPermission(thisActivity,
                        Manifest.permission.CAMERA)
                != PackageManager.PERMISSION_GRANTED) {
    
            // Give first an explanation, if needed.
            if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
                    Manifest.permission.CAMERA)) {
    
                // Show an explanation to the user *asynchronously* -- don't block
                // this thread waiting for the user's response! After the user
                // sees the explanation, try again to request the permission.
    
            } else {
    
                // No explanation needed, we can request the permission.
    
                ActivityCompat.requestPermissions(thisActivity,
                        new String[]{Manifest.permission.CAMERA},
                        1);
            }
        }
    }
    

    You can also handle the request response, as described on the docs.

    Hope it helps!

    0 讨论(0)
  • 2020-12-16 13:01

    Just had this problem and I solved it by killing any other apps that were using the camera. I had some previous tutorials still running in the background.

    0 讨论(0)
  • 2020-12-16 13:04

    The samples should work because they are using the JavaCamera. I get this problem when I tried to use the Native one. It seems to be that the native one doesn't work for ervery phone. see this.

    I have to add that in some devices the openCV native camera doesn't work at all , bug 2359.

    0 讨论(0)
  • 2020-12-16 13:05

    Go to your device settings -> apps -> YOUR APP -> Permissions -> turn on camera permission..

    Worked for me..

    0 讨论(0)
  • 2020-12-16 13:11

    Check the camera permission in AndroidManifest.xml.

    <uses-permission android:name="android.permission.CAMERA"/>
    
        <uses-feature android:name="android.hardware.camera"/>
        <uses-feature android:name="android.hardware.camera.autofocus"/>
        <uses-feature android:name="android.hardware.camera.front"/>
        <uses-feature android:name="android.hardware.camera.front.autofocus"/>
    

    Its working for me..

    0 讨论(0)
提交回复
热议问题