# It seems that you device dows not support camera (or it is locked)

**URL:** <https://forum.opencv.org/t/it-seems-that-you-device-dows-not-support-camera-or-it-is-locked/17583>\
**Category:** Android/Java\
**Created:** [May 9, 2024, 8:19am UTC](https://forum.opencv.org/t/it-seems-that-you-device-dows-not-support-camera-or-it-is-locked/17583 "2024-05-09T08:19:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_joker\_s](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/_joker_s/32/10440_2.png) [@\_joker\_s](https://forum.opencv.org/u/_joker_s)\
**Post date:** [May 9, 2024, 8:19am UTC](https://forum.opencv.org/t/it-seems-that-you-device-dows-not-support-camera-or-it-is-locked/17583/1 "2024-05-09T08:19:30Z")

</div>

When I switch cameras using Android, this error occurs.  
This is my code for switching cameras.

```auto
public void switchCam(){
        javaCameraView.disableView();
        if(isFrontCamera){
            // javaCameraView.setCameraIndex(CameraBridgeViewBase.CAMERA_ID_FRONT);
            lockCamId = Camera.CameraInfo.CAMERA_FACING_BACK;
            javaCameraView.setCameraIndex(lockCamId);
            isFrontCamera = false;
        }else{
            lockCamId = Camera.CameraInfo.CAMERA_FACING_FRONT;
            javaCameraView.setCameraIndex(lockCamId);
            isFrontCamera=true;
        }

        javaCameraView.enableView();
    }

```

I will first use this to start my camera

```auto
JavaCameraView javaCameraView = new JavaCameraView(context,CameraBridgeViewBase.CAMERA_ID_ANY);

```

Of course, I also thought of using CameraBridgeViewBase.CAMERA\_ID\_FRONT or CameraBridgeViewBase.CAMERA\_ID\_BACK

This way, it is more likely to trigger errors in the title. How should I correctly and reasonably switch cameras

At first, this code ran normally, but when I unplugged the USB camera or replaced it (when exiting the application), I would receive an error message with the title .Attempting to restart the application or Android device cannot effectively resolve the issue.

OpenCVSDK 4.9.0

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [May 9, 2024, 8:29am UTC](https://forum.opencv.org/t/it-seems-that-you-device-dows-not-support-camera-or-it-is-locked/17583/2 "2024-05-09T08:29:56Z")

</div>

Are those _OpenCV_ APIs? They look like Android APIs.

---

<div class="post-metadata">

**Author:** ![\_joker\_s](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/_joker_s/32/10440_2.png) [@\_joker\_s](https://forum.opencv.org/u/_joker_s)\
**Post date:** [May 9, 2024, 8:47am UTC](https://forum.opencv.org/t/it-seems-that-you-device-dows-not-support-camera-or-it-is-locked/17583/3 "2024-05-09T08:47:19Z")

</div>

Yes, these APIs are all from opencv-4.9.0-android-sdk

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [May 9, 2024, 9:15am UTC](https://forum.opencv.org/t/it-seems-that-you-device-dows-not-support-camera-or-it-is-locked/17583/4 "2024-05-09T09:15:11Z")

</div>

they appear to be very new. I can’t even navigate to these APIs from the API docs.

All I found was this tutorial, which claims to be valid only from v4.9 onwards.

[https://docs.opencv.org/4.x/d5/df8/tutorial\_dev\_with\_OCV\_on\_Android.html](https://docs.opencv.org/4.x/d5/df8/tutorial_dev_with_OCV_on_Android.html)

---

<div class="post-metadata">

**Author:** ![\_joker\_s](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/_joker_s/32/10440_2.png) [@\_joker\_s](https://forum.opencv.org/u/_joker_s)\
**Post date:** [May 9, 2024, 9:43am UTC](https://forum.opencv.org/t/it-seems-that-you-device-dows-not-support-camera-or-it-is-locked/17583/5 "2024-05-09T09:43:44Z")

</div>

Thank you for providing documentation assistance

Your document is the simplest example, and I just tried to rebuild it by directly specifying the camera ID (front or rear) without using custom switching. It was found that only the rear camera can function properly, while the front camera cannot function, Tip title error. The front camera is a USB camera. My Android device is the source version of the Android system, which is Android 11

But when I unplug the USB camera, I first start a working camera, then wait for a moment to plug in the USB camera, exit the application, and restart to switch back to the USB camera. Does this require repeated operations to succeed? May I ask if this is a bug or a problem with my application?
