# List of cameras available but none accessible

**URL:** <https://discourse.processing.org/t/list-of-cameras-available-but-none-accessible/41721>\
**Category:** Libraries\
**Created:** [April 14, 2023, 12:34pm UTC](https://discourse.processing.org/t/list-of-cameras-available-but-none-accessible/41721 "2023-04-14T12:34:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![loom](https://avatars.discourse-cdn.com/v4/letter/l/b487fb/32.png) [@loom](https://discourse.processing.org/u/loom)\
**Post date:** [April 14, 2023, 12:34pm UTC](https://discourse.processing.org/t/list-of-cameras-available-but-none-accessible/41721/1 "2023-04-14T12:34:06Z")

</div>

Hi there!

I’m trying to run a code that needs to use a camera using the processing.video library but would give me errors. After some trial and error, I found that processing is able to list out the cameras that are connected to my laptop but responds with false when checking using cam.available(). Running the code below would print “no cameras available” and would give the error “WARNING: no real random source present!” no matter which camera I try. Trying external cameras has not helped either. I tried giving it camera access via windows settings but processing won’t show up as an application installed. What could I do to make this work? Many thanks in advance!

```auto
import processing.video.*;

Capture cam;

void setup() {
  // get list of cameras
  String[] cameras = Capture.list();
  for (int i =0; i<cameras.length; i++) {
    String camerainfo = cameras[i];
    println(camerainfo);
  }
    cam = new Capture(this, cameras[0]);
  cam.start(); 
}

void draw() {
  if (cam.available() == true) {
    cam.read();
  }
  else {
   println("no cameras available"); 
  }
  image(cam, 0, 0, width, height);
}

```

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [April 14, 2023, 2:10pm UTC](https://discourse.processing.org/t/list-of-cameras-available-but-none-accessible/41721/2 "2023-04-14T14:10:26Z")

</div>

Hi

> **[Video](https://processing.org/tutorials/video/)**
>
> How to display live and recorded video.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 16, 2023, 1:11pm UTC](https://discourse.processing.org/t/list-of-cameras-available-but-none-accessible/41721/3 "2023-04-16T13:11:13Z")

</div>

Hello @loom,

> [@loom](#):
>
> ```auto
> if (cam.available() == true) {
> cam.read();
> }
> else {
> println("no cameras available"); 
> }
> 
> ```

See:

> **[available() / Libraries](https://processing.org/reference/libraries/video/Capture_available_.html)**
>
> Returns "true" when a new frame from the device is available to read.

The camera frame rate is slower than _draw()_ and your print statement will print when it is not available.

This print statement would better reflect the condition:  
` println("new frame from the device is NOT available to read.");`

This will help to visualize when a frame is not available and show a red background between updated cam frames:

```auto
void draw() 
  {
  background(255, 0, 0); // Try with and without this line
  if (cam.available() == true) 
    {
    cam.read();
    image(cam, 0, 0, width, height); // Try with this here or below
    }
  //image(cam, 0, 0, width, height); // Try with this here or below 
  }

```

Keep in mind that image() is displaying the last frame that was captured and only updated when a new one is available.

This may be of interest:

> **[captureEvent() / Libraries](https://processing.org/reference/libraries/video/captureEvent_.html)**
>
> This event function is run when a new camera frame is available. Use the read() method to capture this frame. If there is more than one capture device in the program, captureEvent() is c…

Another related topic:

> [@Processing can't find the camera - Video Libraries don't work](https://discourse.processing.org/t/processing-cant-find-the-camera-video-libraries-dont-work/25128/13):
>
> I think you want to try removing all the capture list stuff and just use - cam = new Capture(this, "pipeline:autovideosrc");

It helps to resolve problems if you share which Processing version, Video library and operating system you are using.

I am using:

- Processing 4.2
- Video Library for Processing 2.2.2
- Windows 10

This shows up in the console with your code (else printl() removed):

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/1/b/1b8083df17294326d01c37b10f3d790780899cca.png)

`:)`
