It seems that your device does not support camera

孤者浪人 提交于 2019-12-08 07:28:58

问题


I have come across an error which I guess is very common in OpenCV apps. When I try to run the app, it says "it seems that your device does not support camera(or it is locked)". I have seen this and this and I have already done whatever they have said, like granting camera permission and rebooting the device etc. But still problem persists. I know this problem means that any other app must be using camera and hence it is locked. When I clear the cache of all the apps using camera which might me using camera, then it works but just once. After that same issue. Any solution to this problem?

Thank you.


回答1:


I have just run into the same problem with OpenCV for Android, and found that going to the phone's Settings -> Apps (or similar) -> Your app -> Permissions and enabling the Camera permission seems to solve the problem.

Hope this helps.


Update

As noted by @F43nd1r in the comments below, asking the user to update their permissions in the app settings menu should not be done for your own apps. What should be done is to ask the user for permission to access the camera/whatever, as per https://developer.android.com/training/permissions/requesting.html.




回答2:


I actually received this error in BlueStack but I solved it by going to Task Manager and ending all the processes of BlueStack. Started BlueStack again and it is working perfect. You can do same if you encounter this problem on your phone. Just restart the phone and it will work fine.




回答3:


Edit org.opencv.android.JavaCameraView.java and search

Szie frameSize = calculateCameraFrameSize(sizes, new JavaCameraSizeAccessor(), width, height);

Replace with follow

Size frameSize;
                if(width>height)
                {
                    frameSize = calculateCameraFrameSize(sizes, new JavaCameraSizeAccessor(), width, height);
                }
                else
                {
                    frameSize = calculateCameraFrameSize(sizes, new JavaCameraSizeAccessor(), height, width);
                }



回答4:


Accordingly to 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 new Android devices you also need to request a runtime permission to use, for instance, the camera.

I posted an answer with the piece of code you need to the question you mentioned.

Check this out: https://stackoverflow.com/a/44087946/4398784

Hope it helps!




回答5:


Changing the line 143 in the JavaCameraView.java (opencv for android library)

Size frameSize = calculateCameraFrameSize(sizes, new JavaCameraSizeAccessor(), width, height);

to

Size frameSize = new Size(width,height);//calculateCameraFrameSize(sizes, new JavaCameraSizeAccessor(), width, height);


来源:https://stackoverflow.com/questions/29811835/it-seems-that-your-device-does-not-support-camera

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!