Loading...
Logo
Processing Forum
thokanson's Profile
1 Posts
1 Responses
0 Followers

Activity Trend

Last 30 days
Show:
Private Message
    Hello all,

    I'm working on a robot that drives a USB camera around on a physical gantry.  My system is OSX 10.7.5, and I'm running Processing 2.0b8.  I've got everything working except for the video image, which is supposed to show up as a live feed in the Processing window when the sketch is run.  When I plug the camera in, Photobooth recognizes it automatically at full resolution and full frame rate.  However, when I try the  boilerplate Capture() code on the Processing site, I get a very long list of possible cameras.  These include many versions of the same device, and often cause the process to stall and error out:
    Exception in thread "Animation Thread" java.lang.RuntimeException: Waited 5000ms for: <1a99836, 148083b>[count 2, qsz 0, owner <AWT-EventQueue-0>] - <Animation Thread>
    ... and when it does work, here's the list:
    vailable cameras:
    name=PC Cam,size=1600x1200,fps=30
    name=PC Cam,size=1600x1200,fps=15
    name=PC Cam,size=1600x1200,fps=1
    name=PC Cam,size=800x600,fps=30
    name=PC Cam,size=800x600,fps=15
    name=PC Cam,size=800x600,fps=1
    name=PC Cam,size=400x300,fps=30
    name=PC Cam,size=400x300,fps=15
    name=PC Cam,size=400x300,fps=1
    name=PC Cam,size=200x150,fps=30
    name=PC Cam,size=200x150,fps=15
    name=PC Cam,size=200x150,fps=1
    name=PC Cam,size=100x75,fps=30
    name=PC Cam,size=100x75,fps=15
    name=PC Cam,size=100x75,fps=1
    name=FaceTime HD Camera (Built-in),size=1280x720,fps=30
    name=FaceTime HD Camera (Built-in),size=1280x720,fps=15
    name=FaceTime HD Camera (Built-in),size=1280x720,fps=1
    name=FaceTime HD Camera (Built-in),size=640x360,fps=30
    name=FaceTime HD Camera (Built-in),size=640x360,fps=15
    name=FaceTime HD Camera (Built-in),size=640x360,fps=1
    name=FaceTime HD Camera (Built-in),size=320x180,fps=30
    name=FaceTime HD Camera (Built-in),size=320x180,fps=15
    name=FaceTime HD Camera (Built-in),size=320x180,fps=1
    name=FaceTime HD Camera (Built-in),size=160x90,fps=30
    name=FaceTime HD Camera (Built-in),size=160x90,fps=15
    name=FaceTime HD Camera (Built-in),size=160x90,fps=1
    name=FaceTime HD Camera (Built-in),size=80x45,fps=30
    name=FaceTime HD Camera (Built-in),size=80x45,fps=15
    name=FaceTime HD Camera (Built-in),size=80x45,fps=1
    Now, after reading many post on this forum, I've arrived at the following:
    1. import processing.video.*;
    2. Capture cam;
    3. void setup() {
    4.   size(800, 600, P2D);
    5.   frameRate(30);
    6.   String[] cameras = Capture.list();
       
    7.   if (cameras.length == 0) {
    8.     println("There are no cameras available for capture.");
    9.     exit();
    10.   } else {
    11.     println("Available cameras:");
    12.     for (int i = 0; i < cameras.length; i++) {
    13.       println(cameras[i]);
    14.     }
    15.     cam = new Capture(this, "name=PC Cam");
    16.     cam.start();    
    17.   }     
    18. }
    19. void draw() {
    20.   if (cam.available() == true) {
    21.     cam.read();
    22.   }
    23.   image(cam, 0, 0);
    24. }
    I think that line 15 is the key here.  The code recognizes that I want my external webcam, but it does not know which resolution I want.  It's smart enough to report that:
    Resolution information not available, attempting to open the capture device at 320x240
    ... but then it grabs a very low res image.  On the bright side, this small image runs at the maximum frame rate.

    So!  I feel like I'm close, but I need some guidance about how to pick a specific camera (with resolution and framerate) off my available cam list.  When I just select the list number with
    1. cam = new Capture(this, cameras[0]);
    ... I get the correct res but a terribly slow frame rate.  The same applies to lower res camera settings on the list, so I don't think it's just a matter of too much data for Processing to handle.  I've also tried specifying the full camera name from the list:
    1.      cam = new Capture(this, "name=PC Cam,size=800x600,fps=30");
    ... but this is also really slow.  Any thoughts on how to effectively select both my res and frame rate are appreciated!

    Thanks for reading.