import org.bytedeco.javacpp.*;import org.bytedeco.javacv.*;importorg.junit.Test;import javax.swing.*;importjava.io.File;importjava.math.RoundingMode;importjava.net.MalformedURLException;importjava.util.Map;importjava.util.concurrent.TimeUnit;import staticorg.bytedeco.javacpp.opencv_core.Mat;import staticorg.bytedeco.javacpp.opencv_imgproc.COLOR_BGRA2GRAY;public classJavaCVTest {private void showFrames(String winTitle, FrameGrabber grabber) throwsFrameGrabber.Exception, InterruptedException {
CanvasFrame canvas= new CanvasFrame(winTitle,1);//新建一个窗口
canvas.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
canvas.setAlwaysOnTop(true);while (true) {if (!canvas.isVisible()) {break;
}
Frame frame=grabber.grab();
canvas.showImage(frame);
Thread.sleep(50);//50毫秒刷新一次图像
}
}private void showFramesWithFace(String winTitle, FrameGrabber grabber) throwsFrameGrabb