refreshing current vdig

hi

i have to refresh an external vdig from time to time, but can’t make this code work in of like it does in processing…

i assign a key to the following code:

  
  
		vision.camera.close(); // close it  
		vision.camera.setDeviceID(0); // reopen  
		vision.camera.initGrabber(320,240);  
  

but the result is that the vdig no longer sends images, only black frames.

in processing, the same vdig, works fine, vdig is refreshed and keeps sending frames through the following code, eg,

  
  
  
   String dev = Capture.list()[0];  
   video.stop();  
   video.dispose();  
   video =  new Capture(this, 256, 256,dev, 25);  
  
  

wondering is someone has done this in of, or could suggest workarounds…

many thanks

a

hey,

why do you need to ‘refresh’ it? why not just leave it running?

a possible workaround is to have your videoGrabber as a pointer, and delete the old one and create a new one, eg

  
  
videoGrabber* vg;  
  
....  
  
vg = new videoGrabber();  
vg->setDeviceID(0);  
vg->initGrabber(320,240);  
  
...  
  
delete vg;  
vg = new videoGrabber();  
vg->setDeviceID(0);  
vg->initGrabber(320,240);  
  
...  

not sure whether or not you’ll leak memory doing it this way though.

hey damian, thanks, it works like you say.
the vdig is refreshed and the frames keep coming in.
have to check if it’s leaking memory or not.
thanks for the tip.

i need this because my usb digitizer is misdisplaced, and i dont feel
like buying the drivers for this firewire one, i found that only have to
reinstantiate it like that to get good behaviour once again.