We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › make Capture, kill Capture, make again
Page Index Toggle Pages: 1
make Capture, kill Capture, make again (Read 1236 times)
make Capture, kill Capture, make again
Jun 13th, 2006, 9:40pm
 
I am working on a project where I need to be able to resize the webcam input on the fly.  I have tried a few things here and there but all lead to errors.

Code:

quicktime.QTNullPointerException: QuickTime MUST be initialized:quicktime.qd.QDGraphics
at quicktime.QTObject._ID(QTObject.java:75)


Basically, I make a new capture at the beginning. If you press the '-' or '+' key, I want to change the dimensions of the webcam.  So I tried this.

Code:

capture = new Capture(this, xRes, yRes);

and later

capture.dispose();
capture = null;
xRes ++; yRes ++;

and then

capture = new Capture(this, xRes, yRes);


Errors abound.  I am making sure nothing is accessing the capture data while I am making the switch.  It happens at the very end of the draw loop if the resizeCamera boolean flag is set to true.  It inits the camera fine the first time, but as soon as I try to change things, i get the quicktime error.

Thoughts?
Re: make Capture, kill Capture, make again
Reply #1 - Jun 13th, 2006, 9:41pm
 
BTW, the full error message is:

Code:

quicktime.QTNullPointerException: QuickTime MUST be initialized:quicktime.qd.QDGraphics
at quicktime.QTObject._ID(QTObject.java:75)

java.lang.RuntimeException: java.lang.RuntimeException: Error while setting up Capture
at processing.opengl.PGraphicsGL.requestDisplay(PGraphicsGL.java:239)
at processing.core.PApplet.run(PApplet.java:1152)
at java.lang.Thread.run(Thread.java:552)
Caused by: java.lang.RuntimeException: Error while setting up Capture
at processing.core.PApplet.die(PApplet.java:2112)
at processing.core.PApplet.die(PApplet.java:2130)
at processing.video.Capture.<init>(Capture.java:215)
at processing.video.Capture.<init>(Capture.java:106)
at Temporary_5144_8523$Cam.initCam(Temporary_5144_8523.java:287)
at Temporary_5144_8523$Cam.resize(Temporary_5144_8523.java:294)
at Temporary_5144_8523.resizeCam(Temporary_5144_8523.java:91)
at Temporary_5144_8523.draw(Temporary_5144_8523.java:81)
at processing.core.PApplet.handleDisplay(PApplet.java:1336)
at processing.opengl.PGraphicsGL$1.display(PGraphicsGL.java:127)
at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:77)
at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:262)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:128)
at javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:279)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:179)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:478)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:178)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:170)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

Re: make Capture, kill Capture, make again
Reply #2 - Jun 15th, 2006, 11:23am
 
hi robert,

looking into the source over at dev it reveals that QTSession is closed upon dispose() (that's where your error comes from). you should rather call stop() on capture, then set it null (not sure this is needed), then create a new instance.

can't test, no cam here.

F
Re: make Capture, kill Capture, make again
Reply #3 - Jun 15th, 2006, 12:37pm
 
Thought I'd try the test myself as this relates to my field. Tried stop(). Looks like the device is still reserved for use after killing the capture.
Code:

import processing.video.*;
Capture capture;

void setup(){
size(640, 480);
capture = new Capture(this, "Creative WebCam Live! Pro #3-WDM", width, height);
//println(capture.list());
}

void draw(){
background(0);
if(capture != null){
image(capture, 0, 0);
}
}

void mousePressed(){
capture.stop();
capture = null;
capture = new Capture(this, mouseX, mouseY);
}

void captureEvent(Capture capture){
capture.read();
}

Whether the device is specified or not delivers a couldn't get required component.
Code:

quicktime.std.StdQTException[QTJava:6.1.3g1],-9405=couldntGetRequiredComponent,QT.vers:7038000

at quicktime.std.StdQTException.checkError(StdQTException.java:38)
Re: make Capture, kill Capture, make again
Reply #4 - Jun 15th, 2006, 5:08pm
 
yeah, so this is prolly just something i need to fix. the library wasn't written to support it, which is why the qt object is diposed, and there isn't a method to resize or release the resources of the camera so it can be reused..

i've added it to my todo list, but of course, anybody who wants to figure out how to 1) add a size() method that will let you resize the camera and 2) figure out a better place to call qtsession dispose (actually, this should be in the dispose method of the qt lib, but also needs to sync itself with the movie lib).. your help would be appreciated.
Re: make Capture, kill Capture, make again
Reply #5 - Jun 15th, 2006, 7:29pm
 
Well, I am glad it wasn't something silly I was overlooking.  I ended up going with a more practical solution involving bringing in the webcam input at the max size I will need and copying it over to a PImage that I can resize on the fly.  Works fine.  But yeah, capture.size() would be a nice addition but certainly not anything high priority i would suspect.

Thanks all.
Page Index Toggle Pages: 1