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
the last param should indicate the index of the camera source. When i print the sourcelist i get this:
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"
The first I want to work with. I use Macam to make it work. However, I can't get the MBP to ignore the iSight.
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
Anyone know what i'm doing wrong here? Is it safe to ignore this?
I'm working on an installation with two screens, arduino loaded with firmata. A sketch that creates two windows, (simplified code posted here
question about class-PShapes) This really pushes my macbook pro to its limits.
Everytime I put something extra in, even as simple as a shape or a drawn rectangle of sorts, it strains mijn MBP even more. As soon as I start the sketch up the temperature skyrockets to 95degrees celsius, making the fans put out 6000RPM in order to keep it from overheating. According to activity monitor the sketch takes up 180% of CPU power.
Right now this is my setup:
Arduino Loaded with Firmata, coupled with two sensors, one Sharp IR-sensor and one Maxbotix Ultrasonic. Three pushbuttons. All adequately connected. USB connection to MBP in order to collect recieved data.
1 Main sketch, initiating a second window class called UIwindow which extends PApplet
- enables arduino's functions by communicating with the Firmatacode loaded on the arduino
- handles pushbuttons and sensors, only reads data
- converts read data to simple forms, like a circle.
- loads one SVG-shape
this all happens in one window of 1280x1024
2 the UIWindow class, which creates another window at 1440 X900
- loads two SVG shapes
- outputs text on screen with data from one sensor.
- converts a rect to another color when a button is pressed.
float volts = arduino.analogRead(4)*0.0048828125; // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3 float distance = 65*pow(volts, -1.10); // worked out from graph 65 = theretical distance / (1/Volts)S - luckylarry.co.uk
float factor = 500/170; val = 500 - val; float eyeSize = val * factor;
I want to connect a webcam with face recognition on it later on, but this makes me worry. alot.
Any help regarding this is very much appreciated. I remember using an external powersource to use with Arduino help stabilize sensor readings, perhaps that would help with the sketchload as well. I will try that next.
EDIT ------------------------------------------
I've reviewed the code with help of a friend and it seems that the external window is the culprit. When I disable the external screen it settles to 100%CPU usage. It's still 100% though...
EDIT #2 ---------------------------------------
I managed to track the problem to the arduino and it's sensors. While it's not necessarily their fault, you absolutely need to constrain the amount of sensor readings it does. I put in a delay of (100) in both classes' draw function, and succesfully reduced CPU usage to 80%.
I'm working on a special case, combining Arduino loaded with Firmata with processing.
I use two windows, one invoked from the normal Main script, and one from a public class called UIWindow. PShape works fine in the Main script, but in UIWindow it gets a nullpointerException.
Main script (simplified)
PShape oogSVG;
void setup() {
size(1280, 1024);
// Passing in this applet allows you to call functions in the parent uiWindow = new UIWindow( this, 1440, 900 );
frame.setLocation(0,0);
oogSVG = loadShape ("oog1.svg"); smooth();
void draw() {
// background(backgroundIMG); background(200);
noFill(); shape(oogSVG, 0, 0); }
UIWindow script
public class UIWindow extends PApplet {
Frame frame; int width; int height; Arduino arduino; PShape infoSVG; Main parent;
UIWindow ( Main _parent, int w, int h ) { parent = _parent; arduino = parent.getArduinoClass(); width = w; height = h; frame = new Frame( ); frame.setBounds( 0, 0, width, height ); frame.removeNotify(); frame.setUndecorated(true); frame.setLocation( 0, 0 ); frame.add( this); this.init( ); frame.show( ); }