Java Code Examples for org.bytedeco.javacv.OpenCVFrameGrabber#start()
The following examples show how to use
org.bytedeco.javacv.OpenCVFrameGrabber#start() .
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: CameraOpenCV.java From PapARt with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void start() { OpenCVFrameGrabber grabberCV = new OpenCVFrameGrabber(this.systemNumber); grabberCV.setImageWidth(width()); grabberCV.setImageHeight(height()); grabberCV.setFrameRate(frameRate); grabberCV.setImageMode(FrameGrabber.ImageMode.COLOR); try { grabberCV.start(); this.grabber = grabberCV; this.isConnected = true; } catch (Exception e) { System.err.println("Could not start frameGrabber... " + e); System.err.println("Could not camera start frameGrabber... " + e); System.err.println("Camera ID " + this.systemNumber + " could not start."); System.err.println("Check cable connection, ID and resolution asked."); this.grabber = null; } }
Example 2
Source File: JavaCVExample.java From javacv-cnn-example with MIT License | 5 votes |
/** * Starts the frame grabbers and then the frame processing. Grabbed and processed frames will be displayed in the * {@link #videoPanel} */ public void start() { // frameGrabber = new FFmpegFrameGrabber("/dev/video0"); // The available FrameGrabber classes include OpenCVFrameGrabber (opencv_videoio), // DC1394FrameGrabber, FlyCapture2FrameGrabber, OpenKinectFrameGrabber, // PS3EyeFrameGrabber, VideoInputFrameGrabber, and FFmpegFrameGrabber. frameGrabber = new OpenCVFrameGrabber(0); //frameGrabber.setFormat("mp4"); frameGrabber.setImageWidth(1280); frameGrabber.setImageHeight(720); logger.debug("Starting frame grabber"); try { frameGrabber.start(); logger.debug("Started frame grabber with image width-height : {}-{}", frameGrabber.getImageWidth(), frameGrabber.getImageHeight()); } catch (FrameGrabber.Exception e) { logger.error("Error when initializing the frame grabber", e); throw new RuntimeException("Unable to start the FrameGrabber", e); } SwingUtilities.invokeLater(() -> { window.setVisible(true); }); process(); logger.debug("Stopped frame grabbing."); }
Example 3
Source File: YOLO2_TF_Client.java From SKIL_Examples with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage) throws Exception { if (args.input_camera >= 0) { System.out.println("Opening camara " + args.input_camera); frameGrabber = new OpenCVFrameGrabber(args.input_camera); frameGrabber.start(); } labels = new COCOLabels(); colors = new HashMap<>(); for (int i = 0; i < nClasses; i++) { colors.put( labels.getLabel( i ), Color.web( COLORS[i] ) ); } // make model server network calls for { auth, inference } skilClientGetImageInference( ); Canvas canvas = new Canvas(imageWidth, imageHeight); GraphicsContext ctx = canvas.getGraphicsContext2D(); ctx.drawImage(SwingFXUtils.toFXImage(bufImgConverter.convert(matConverter.convert(imgMat)), null), 0, 0); stage.setScene(new Scene(new StackPane(canvas), this.imageWidth, this.imageHeight)); renderJavaFXStyle( ctx ); stage.setTitle("YOLO2"); stage.show(); if (frameGrabber != null) { new Thread(() -> { try { while (stage.isShowing()) { skilClientGetImageInference( ); ctx.drawImage(SwingFXUtils.toFXImage(bufImgConverter.convert(matConverter.convert(imgMat)), null), 0, 0); renderJavaFXStyle( ctx ); } } catch (Exception e) { e.printStackTrace(); } }).start(); } }