It seems that your device does not support camera
Asked Answered
C

5

1

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.

Crone answered 23/4, 2015 at 1:11 Comment(3)
I am not really sure about solution to your problem but few days back I had the same issue and it turn out that there was some problem in DEFAULT CAMERA.So check if the default camera is set properly.Goodoh
@Rahulgalgali: can you elaborate please? set camera in eclipse or phone?Crone
I know this is probably the first thing you've looked into, but are you certain you're releasing the camera afterwards or disabling the view where the camera preview is being shown?Billetdoux
M
6

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.

Monopetalous answered 27/1, 2016 at 21:24 Comment(3)
Note that Runtime permission start from Android Marshmallow. On devices with lower APIs this won't be the problem. Also: Apps can request the user to grant such permissions. This is what apps should do, instead of asking them to go into the settings.Iraidairan
It was runtime permissions for meFiberboard
As per F43nd1r's comments, this is new runtime permissions from Marshmallow onward: see this discussion , this explanation , and this Developer page.Briticism
C
0

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.

Crone answered 4/5, 2015 at 19:17 Comment(0)
K
0

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);
                }
Korfonta answered 8/3, 2017 at 1:59 Comment(0)
R
0

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://mcmap.net/q/627983/-it-seems-that-your-device-does-not-support-camera-or-it-is-locked

Hope it helps!

Rufinaruford answered 20/5, 2017 at 16:2 Comment(0)
T
0

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);
Thionate answered 15/11, 2019 at 8:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.