2 micaddress micaddress 于 2016.04.28 19:53 提问

求助 JavaCV 的 grabber.stop() 问题 10C

以下是代码:
grabber.start();

CanvasFrame canvasFrame = new CanvasFrame("Camera");

canvasFrame.setVisible(false);
IplImage image;
image = grabber.grab();
int width = image.width();

int height = image.height();
canvasFrame.setCanvasSize(width, height);

final BufferedImage bImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

Graphics2D bGraphics = bImage.createGraphics();

TimerAction timerAction = new TimerAction(canvasFrame);

final Timer timer=new Timer(10, timerAction);

timerAction.setTimer(timer);

int checkPictureContextIsNull = 1;
while(checkPictureContextIsNull == 1){
if((image=grabber.grab()) == null){
continue;
}else{
if(!timer.isRunning()) {

// canvasFrame.showImage(image);

bGraphics.drawImage(image.getBufferedImage(),null,0,0);
timer.start();

// changePicturesNameType = Integer.toString(changePicturesName);
try {

ImageIO.write(bImage, "jpg", new File("d:\pictures.jpg"));

// changePicturesName++;
} catch (IOException e1) {

e1.printStackTrace();

}

checkPictureContextIsNull = 0;
}

}
}
cvReleaseImage(image);

grabber.stop();
canvasFrame.dispose();

        以下是main方法
        public static void main(String[] args) throws InterruptedException, com.googlecode.javacv.FrameGrabber.Exception {
    System.out.println("11111111111111111111111111111111111111111");
    getPictures();
    System.out.println("22222222222222222222222222222222222222222");
}

我每次执行都只能打印出 111111111  语句  因为一执行到 getPictures()这个方法的时候就直接中断了,后来DEBUG调试发现程序运行到 getPictures()方法的 grabber.stop(); 语句时 程序就中断了,在网上查了好多 都没有查到,希望CSDN的牛人可以帮忙解决一下 不胜感激
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!