How to check video camera

I have used the basic example code:

import processing.video.*;

Capture cam;

void setup() {
  size(640, 480);

  String[] cameras = Capture.list();

  if (cameras.length == 0) {
    println("There are no cameras available for capture.");
    exit();
  } else {
    println("Available cameras:");
    for (int i = 0; i < cameras.length; i++) {
      println(cameras[i]);
    }

    // The camera can be initialized directly using an 
    // element from the array returned by list():
    cam = new Capture(this, 640, 480,5);
    cam.start();     
  }      
}

void draw() {

  image(cam, 0, 0);
}

void captureEvent(Capture c) {
  if (cam.available() == true) {
    cam.read();
  }
}

I get a list of cameras including my bloggie listed as:

Available cameras:
name=MHS-FS2,size=640x480,fps=5
name=MHS-FS2,size=640x480,fps=30
name=MHS-FS2,size=320x240,fps=5
name=MHS-FS2,size=320x240,fps=30
name=MHS-FS2,size=1280x720,fps=5
name=MHS-FS2,size=1280x720,fps=30

I get a black screen however when the code runs.

The camera is working because I have run it separately using MyCam.

So, camera appears working as a usb webcam fine.

Capture.list() "finds" the camera attached on the USB port.

Nothing gets displayed.

I have tried various strings for the camera name to try to get cam = new Capture(this, 640, 480,"",5) to pick up a specific camera but nothing has worked so far.

I have tried cam = new Capture(this,cameras[0]) but still does not result in anything other than a black dialog.

The camera is not obstructed nor is there a lens cap etc.

What might be the problem here?

I am using a Bloggie Duo, set up as webcam, running Processing 2.2.1 on Windows 7.

Thanks,

A

Answers

  • edited August 2015

    Maybe try out my sample code from the link below. Who knows it might work? :(|)
    https://GitHub.com/processing/processing-video/pull/30

  • edited August 2015

    GoToLoop

    In fact, by the time I debug the code you suggested, it seems it is a convoluted way to get to the same problem as the example code from the processing ref above.

    Camera is still recognised and listed. Nothing gets pumped to dialog.

  • edited August 2015

    Going back to the original code I added the following code before the cam.start():

      if (cam.available() == true) { 
        println("camera available");
       }
       else {
         println("camera not available");
      }
    

    Turns out then, the Capture.list() can "see" the camera but new Capture() fails.

    How is it that the camera can be "seen" by one aspect of Processing video library but not "seen" by Capture constructor?

    Or, what causes the Capture constructor to fail even when a camera is available?

    Cheers, A

  • Ah, I tried the gsvideo library to see if I could get that to work. Same problem. There is a chance, of course, that gsvideo uses the Capture class from Processing Video library in any event.

    I checked the driver in windows, it comes up as a webcam so I am definitely baffled.

  • Same problem with lenovo yoga and with dell windows tablet. Please let me know if you got it working, I have been trying different stuff but about to give up...

  • Forgot to say, if I connect a usb camera to the laptop or the tablet, that camera works fine.

  • @txeni I got it "working" by not using the Processing video library.

    I am using http://webcam-capture.sarxos.pl/ instead.

    Works a treat.

    You need to import the webcam-capture jar and two of its dependencies into your sketch and voila!

    Note there is a trick for converting to PImage (I have to dig around my notes to remind myself ;) but I will get back to you.

    The owner of the webcam-capture library is actually pretty good at responding ... more so than on this site :(

    There is either a trick with this Processing library that I am not seeing or there is a camera protocol they are not taking into account as webcam-capture appears to have a raft of protocols

  • using 5mp webcam but capture.list does not list it. I can see it in Device Manager and access it with commandcam.exe (command line capture utility) and get full 5 mp resolution image to file. like to know more about implementation of webcam-capture. Understand importing .jar but what dependencies to import? Did u find these ?

    U mentioned: Note there is a trick for converting to PImage (I have to dig around my notes to remind myself but I will get back to you.

  • @Asterion can you provide me the code that you use? i'm having the same problem

Sign In or Register to comment.