0

I am following this tutorial to add opencv and camera support to a new app in Android Studio in Java using Android 11 and Pixel 4 as emulator

I followed some comments and added

mOpenCvCameraView.setCameraPermissionGranted();

Now I get the error It seems that your device does not support camera(or it is locked)

I found some solutions here It seems that your device does not support camera(or it is locked) but I don't know how to implement them

I was able to do it by enabling the camera permissions manually in the emulator's phone settings for my app, however I would like it to request permissions on its own

The answer, 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.

Where do I add this code? Is this even Java code? I am getting so many undefined errors when trying to paste it in the OnCreate function.

Mich
  • 3,188
  • 4
  • 37
  • 85
  • Link to tutorial? Or at least a section of code and document which OpenCV library you are using? Otherwise there is https://developer.android.com/training/permissions/requesting and https://github.com/android/camera-samples – Morrison Chang Feb 25 '23 at 00:43

0 Answers0