OpenCV using different webcam source
in
Contributed Library Questions
•
2 years ago
Hi,
I have a very difficult issue with OpenCV. I used to test my OpenCV-app with my MBP internal ISight, in order to see if it worked. It did. However, I always imagined I could easily switch to an external USB-webcam. This proves to be a much harder thing to do then originally thought, as my Macbook Pro forces the use of my internal iSight webcam. It's very cumbersome and for the life of me have no idea why this is so intrusive.
According to the OpenCV processing site,
In order to workaround this problem, i have an intrusive applescript that disables the iSight by moving or temporarily remove the Quicktime component needed for the iSight to function. It makes the computer think the internal iSight isn't there and then switches to the next available source; in this case my webcam.
This works, however hardly reliable. it spawns a myriad of errors and apparantly as somekind of memoryleak as well.
my code is this:
I have a very difficult issue with OpenCV. I used to test my OpenCV-app with my MBP internal ISight, in order to see if it worked. It did. However, I always imagined I could easily switch to an external USB-webcam. This proves to be a much harder thing to do then originally thought, as my Macbook Pro forces the use of my internal iSight webcam. It's very cumbersome and for the life of me have no idea why this is so intrusive.
According to the OpenCV processing site,
- opencv.capture( 320, 240, 0); // open video stream
- 0] "Creative Live! Cam Notebook Pro (VF0400)"
[1] "DV Video"
[2] "DVCPRO HD (1080i50)"
[3] "DVCPRO HD (1080i60)"
[4] "DVCPRO HD (720p25/50)"
[5] "DVCPRO HD (720p60)"
[6] "IIDC FireWire Video"
[7] "USB Video Class Video"
In order to workaround this problem, i have an intrusive applescript that disables the iSight by moving or temporarily remove the Quicktime component needed for the iSight to function. It makes the computer think the internal iSight isn't there and then switches to the next available source; in this case my webcam.
This works, however hardly reliable. it spawns a myriad of errors and apparantly as somekind of memoryleak as well.
- 2011-01-07 15:34:56.004 java[5360:10503] Error loading /System/Library/QuickTime/QuickTimeUSBVDCDigitizer.component/Contents/MacOS/QuickTimeUSBVDCDigitizer: dlopen(/System/Library/QuickTime/QuickTimeUSBVDCDigitizer.component/Contents/MacOS/QuickTimeUSBVDCDigitizer, 262): no suitable image found. Did find:
/System/Library/QuickTime/QuickTimeUSBVDCDigitizer.component/Contents/MacOS/QuickTimeUSBVDCDigitizer: open() failed with errno=13
2011-01-07 15:34:56.620 java[5360:10503] The Manufacturer ID bytes match OmniVision.
2011-01-07 15:34:56.637 java[5360:10503] The sensor appears to be in the OV76xx series (73).
2011-01-07 15:34:57.820 java[5360:10503] Setting brightness to 7f.
2011-01-07 15:34:57.834 java[5360:10503] Returned brightness is 7f.
2011-01-07 15:34:57.834 java[5360:10503] Setting saturation to 70.
2011-01-07 15:34:57.849 java[5360:10503] Returned saturation is 70.
2011-01-07 15:34:58.016 java[5360:10503] *** __NSAutoreleaseNoPool(): Object 0x118cf20 of class NSThread autoreleased with no pool in place - just leaking
my code is this:
- import hypermedia.video.*;
import java.awt.Rectangle;
import processing.video.*;
OpenCV opencv;
// videocapture
int contrast_value = 0;
int brightness_value = 0;
void setup() {
frameRate(15);
size(320, 240);
println(Capture.list());
opencv = new OpenCV( this );
opencv.capture( 320, 240, 0); // open video stream
opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); //
}
void draw () {
int camWindowX = 0;
int camWindowY = 0;
opencv.read();
opencv.convert( GRAY );
// opencv.flip( OpenCV.FLIP_HORIZONTAL); // flip vertically and horizontally
opencv.contrast( contrast_value );
opencv.brightness( brightness_value );
// proceed detection
Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 20, 20 );
// display the image
image( opencv.image(), camWindowX, camWindowY);
// draw face area(s)
noFill();
stroke(255,0,0);
for( int i=0; i<faces.length; i++ ) {
rect(camWindowX + faces[i].x, camWindowY + faces[i].y, faces[i].width, faces[i].height );
}
}
4