private void initSequenceGrabber() throws QTException { if (sequenceGrabberInitialized) return; QTSession.open(); sg = new SequenceGrabber(); vc = new SGVideoChannel(sg); // cameraImageSize = new QDRect(320, 240); if (overrideVideoFormat != null) cameraImageSize = new QDRect(overrideVideoFormat.getWidth(), overrideVideoFormat.getHeight()); else { cameraImageSize = vc.getSrcVideoBounds(); logger.info( "Camera image size reported as: " + cameraImageSize.getWidth() + "x" + cameraImageSize.getHeight()); // this is a workaround found at // http://rsb.info.nih.gov/ij/plugins/download/QuickTime_Capture.java // and other places for the isight, which gives the wrong resolution. // TODO: find a better way of identifying the isight. Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); if (cameraImageSize.getHeight() > screen.height - 40) // iSight camera claims to 1600x1200! { logger.warning( "Camera image size reported as: " + cameraImageSize.getWidth() + "x" + cameraImageSize.getHeight() + "; resizing to 640x480"); cameraImageSize.resize(640, 480); } } // On PPC (big endian) we use: k32ARGBPixelFormat // On Intel we use: k32ABGRPixelFormat // fails on PPC with DepthErrInvalid: k32ABGRPixelFormat, k32BGRAPixelFormat, k32RGBAPixelFormat gWorld = new QDGraphics( bigEndian ? QDConstants.k32ARGBPixelFormat : QDConstants.k32ABGRPixelFormat, cameraImageSize); // set a specific pixel format so we can predictably convert to // buffered image below. sg.setGWorld(gWorld, null); vc.setBounds(cameraImageSize); vc.setUsage(quicktime.std.StdQTConstants.seqGrabRecord); vc.setFrameRate(0); myCodec = quicktime.std.StdQTConstants.kComponentVideoCodecType; vc.setCompressorType(myCodec); sequenceGrabberInitialized = true; }
private void disposeSequenceGrabber() throws QTException { if (!sequenceGrabberInitialized) return; try { if (vc != null) vc.disposeQTObject(); if (sg != null) { sg.stop(); sg.disposeQTObject(); } QTSession.close(); } finally { sequenceGrabberInitialized = false; } }