We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I just got a new USB Camera from Amazon
Using the camera capture sketch included in the examples I am doing some tests. However, I ran into a few problems accessing the lower resolutions.
When I print out the available resolutions in the console I get this:
Available cameras:
0name=HD USB Camera,size=2592x1944,fps=30
1name=HD USB Camera,size=2592x1944,fps=15
2name=HD USB Camera,size=2592x1944,fps=1
3name=HD USB Camera,size=1296x972,fps=30
4name=HD USB Camera,size=1296x972,fps=15
5name=HD USB Camera,size=1296x972,fps=1
6name=HD USB Camera,size=648x486,fps=30
7name=HD USB Camera,size=648x486,fps=15
8name=HD USB Camera,size=648x486,fps=1
9name=HD USB Camera,size=324x243,fps=30
10name=HD USB Camera,size=324x243,fps=15
11name=HD USB Camera,size=324x243,fps=1
12name=FaceTime HD Camera,size=1280x720,fps=30
13name=FaceTime HD Camera,size=1280x720,fps=15
14name=FaceTime HD Camera,size=1280x720,fps=1
15name=FaceTime HD Camera,size=640x360,fps=30
16name=FaceTime HD Camera,size=640x360,fps=15
17name=FaceTime HD Camera,size=640x360,fps=1
18name=FaceTime HD Camera,size=320x180,fps=30
19name=FaceTime HD Camera,size=320x180,fps=15
20name=FaceTime HD Camera,size=320x180,fps=1
21name=FaceTime HD Camera,size=160x90,fps=30
22name=FaceTime HD Camera,size=160x90,fps=15
23name=FaceTime HD Camera,size=160x90,fps=1
24name=FaceTime HD Camera,size=80x45,fps=30
25name=FaceTime HD Camera,size=80x45,fps=15
26name=FaceTime HD Camera,size=80x45,fps=1
** (Processing core video:706): WARNING **: ColorConverter: size 163296 is not a multiple of unit size 157464
Notice the error at the bottom. When I run the camera on the setting [0] it is fine. However, it is too big for the application. I want the [6] or the [9] selection. However, as soon as I go to a lower res than [5] I get the error and the program does not run. How can I resolve these errors and get the camera to display properly?
/**
* Getting Started with Capture.
*
* Reading and displaying an image from an attached Capture device.
*/
import processing.video.*;
Capture cam;
void setup() {
size(640, 480);
String[] cameras = Capture.list();
if (cameras == null) {
println("Failed to retrieve the list of available cameras, will try the default...");
cam = new Capture(this, 640, 480);
}
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(i + cameras[i]);
}
// The camera can be initialized directly using an element
// from the array returned by list():
// cam = new Capture(this, cameras[0]);
// Or, the settings can be defined based on the text in the list
//cam = new Capture(this, 640, 480, "Built-in iSight", 30);
// Low Res Webcam
// cam = new Capture(this, 640, 360, "FaceTime HD Camera", 30);
// Trying for Amaazon Cam
// cam = new Capture(this, 648, 486, "HD USB Camera", 30);
// Manually selected
cam = new Capture(this, cameras[9]);
// Start capturing the images from the camera
cam.start();
}
}
void draw() {
if (cam.available() == true) {
cam.read();
}
image(cam, 0, 0);
// The following does the same as the above image() line, but
// is faster when just drawing the image without any additional
// resizing, transformations, or tint.
//set(0, 0, cam);
}
Answers
I found I was able to get it working by typing in resolutions slightly different that what was printed out.
For instance, if I used the hard typed line for selecting the camera and typed in a slightly different resolution for a working example it would give me the same error.
For the lower resolutions I desired, 324 x 243, I thought, "Wow, that is really close to 320 x 240"
If I tried that it worked just fine.
Very happy camper here. I think these cameras are going to be very handy!
On to making it IR!