Java Code Examples for org.bytedeco.javacv.CanvasFrame#isVisible()
The following examples show how to use
org.bytedeco.javacv.CanvasFrame#isVisible() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LivePlayTest2.java From oim-fx with MIT License | 4 votes |
/** * 转流器 * * @param inputFile * @param outputFile * @throws Exception * @throws org.bytedeco.javacv.FrameRecorder.Exception * @throws InterruptedException */ public static void recordPush(String inputFile, int v_rs) throws Exception, org.bytedeco.javacv.FrameRecorder.Exception, InterruptedException { Loader.load(opencv_objdetect.class); long startTime = 0; FrameGrabber grabber = FFmpegFrameGrabber.createDefault(inputFile); try { grabber.start(); } catch (Exception e) { try { grabber.restart(); } catch (Exception e1) { throw e; } } OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage(); Frame grabframe = grabber.grab(); IplImage grabbedImage = null; if (grabframe != null) { System.out.println("取到第一帧"); grabbedImage = converter.convert(grabframe); } else { System.out.println("没有取到第一帧"); } System.out.println("开始推流"); CanvasFrame frame = new CanvasFrame("camera", CanvasFrame.getDefaultGamma() / grabber.getGamma()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setAlwaysOnTop(true); while (frame.isVisible() && (grabframe = grabber.grab()) != null) { System.out.println("推流..."); frame.showImage(grabframe); grabbedImage = converter.convert(grabframe); Frame rotatedFrame = converter.convert(grabbedImage); if (startTime == 0) { startTime = System.currentTimeMillis(); } Thread.sleep(40); } frame.dispose(); grabber.stop(); System.exit(2); }