当前位置: 首页>>代码示例>>Java>>正文


Java FrameGrabber类代码示例

本文整理汇总了Java中org.bytedeco.javacv.FrameGrabber的典型用法代码示例。如果您正苦于以下问题:Java FrameGrabber类的具体用法?Java FrameGrabber怎么用?Java FrameGrabber使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FrameGrabber类属于org.bytedeco.javacv包,在下文中一共展示了FrameGrabber类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: add

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
/**
 * blocking safe exchange of data between different threads external thread
 * adds image data which can be retrieved from the blockingData queue
 * 
 * @param image
 *          - image to be processed through pipeline
 * @return - OpenCVData
 */
public VisionData add(Frame image) {
  FrameGrabber grabber = getGrabber();
  if (grabber == null || grabber.getClass() != BlockingQueueGrabber.class) {
    error("can't add an image to the video processor - grabber must be not null and BlockingQueueGrabber");
    return null;
  }

  BlockingQueueGrabber bqgrabber = (BlockingQueueGrabber) grabber;
  bqgrabber.add(image);

  try {
    VisionData ret = (VisionData) blockingData.take();
    return ret;
  } catch (InterruptedException e) {
    return null;
  }
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:26,代码来源:Vision.java

示例2: add

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
public OpenCVData add(Frame image) {
  FrameGrabber grabber = videoProcessor.getGrabber();
  if (grabber == null || grabber.getClass() != BlockingQueueGrabber.class) {
    error("can't add an image to the video processor - grabber must be not null and BlockingQueueGrabber");
    return null;
  }

  BlockingQueueGrabber bqgrabber = (BlockingQueueGrabber) grabber;
  bqgrabber.add(image);

  try {
    OpenCVData ret = (OpenCVData) videoProcessor.blockingData.take();
    return ret;
  } catch (InterruptedException e) {
    return null;
  }
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:18,代码来源:OpenCV.java

示例3: add

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
/**
 * blocking safe exchange of data between different threads external thread
 * adds image data which can be retrieved from the blockingData queue
 * 
 * @param image - a null value, but could support adding an image
 */
public VisionData add(Frame image) {
	FrameGrabber grabber = getGrabber();
	if (grabber == null || grabber.getClass() != BlockingQueueGrabber.class) {
		processor.error(
				"can't add an image to the video processor - grabber must be not null and BlockingQueueGrabber");
		return null;
	}

	BlockingQueueGrabber bqgrabber = (BlockingQueueGrabber) grabber;
	bqgrabber.add(image);

	/*
	try {
		OpenCVData ret = (OpenCVData) blockingData.take();
		return ret;
	} catch (InterruptedException e) {
		return null;
	}
	*/
	return null;
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:28,代码来源:OpenCVFilterInput.java

示例4: getGrabber

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
public FrameGrabber getGrabber() {
  OpenCVFilterInput inputFilter = (OpenCVFilterInput) getFilter(selectedName);
  if (inputFilter != null) {
    return inputFilter.getGrabber();
  }
  return null;
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:8,代码来源:Vision.java

示例5: start

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:23,代码来源:CameraOpenCV.java

示例6: start

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
@Override
public void start() {
    try {
        FlyCapture2FrameGrabber grabberFly = new FlyCapture2FrameGrabber(this.systemNumber);
        grabberFly.setImageWidth(width());
        grabberFly.setImageHeight(height());

        if (useBayerDecode) {
            grabberFly.setImageMode(FrameGrabber.ImageMode.GRAY);

        } else {
            // Hack for now ... 
            // real Gray colors are not supported by Processing anyway !
            grabberFly.setImageMode(FrameGrabber.ImageMode.COLOR);
        }
        this.grabber = grabberFly;
        grabberFly.start();
        this.isConnected = true;
        
    } catch (Exception e) {
        System.err.println("Could not start FlyCapture frameGrabber... " + e);
        System.err.println("Camera ID " + this.systemNumber + " could not start.");
        System.err.println("Check cable connection, ID and resolution asked.");

    }
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:27,代码来源:CameraFlyCapture.java

示例7: add

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
/**
 * blocking safe exchange of data between different threads external thread
 * adds image data which can be retrieved from the blockingData queue
 * 
 * @param image
 */
public OpenCVData add(IplImage image) {
	FrameGrabber grabber = videoProcessor.getGrabber();
	if (grabber == null || grabber.getClass() != BlockingQueueGrabber.class) {
		error("can't add an image to the video processor - grabber must be not null and BlockingQueueGrabber");
		return null;
	}

	BlockingQueueGrabber bqgrabber = (BlockingQueueGrabber) grabber;
	bqgrabber.add(image);

	try {
		OpenCVData ret = (OpenCVData) videoProcessor.blockingData.take();
		return ret;
	} catch (InterruptedException e) {
		return null;
	}
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:24,代码来源:OpenCV.java

示例8: start

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
@Override
public void start() {
    OpenCVFrameGrabber grabberCV = new OpenCVFrameGrabber(this.systemNumber);
    grabberCV.setImageWidth(width());
    grabberCV.setImageHeight(height());
    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;
    }
}
 
开发者ID:poqudrof,项目名称:PapAR,代码行数:22,代码来源:CameraOpenCV.java

示例9: setFrame

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
/**
 * Sets the frame grabber to the given frame number. This will pause frame grabber from reading
 * successive frames; it can be resumed with {@link #resume()}. This runs asynchronously and
 * will complete at some point in the future after this method is called.
 *
 * @param frameNumber the number of the frame to grab
 *
 * @throws IllegalArgumentException if {@code frameNumber} is negative or exceeds the number of
 *                                  frames in the video file
 */
public void setFrame(int frameNumber) {
  if (frameNumber < 0) {
    throw new IllegalArgumentException("Negative frame number " + frameNumber);
  }
  if (frameNumber > frameGrabber.getLengthInFrames()) {
    throw new IllegalArgumentException(
        "Frame number too high: " + frameNumber + " > " + frameGrabber.getLengthInFrames());
  }
  pause();
  try {
    frameGrabber.setFrameNumber(frameNumber);
  } catch (FrameGrabber.Exception e) {
    getExceptionWitness().flagException(e, "Could not set frame number");
  }
  manualGrabberService.submit(this::grabNextFrame);
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:27,代码来源:VideoFileSource.java

示例10: testStartUpRethrowsFrameGrabberExceptionAsGrabberServiceException

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
@Test(expected = GrabberService.GrabberServiceException.class)
public void testStartUpRethrowsFrameGrabberExceptionAsGrabberServiceException() throws
    GrabberService.GrabberServiceException {
  final String exceptionMessage = "Start: Kaboom!";
  try {
    final GrabberService grabberService = createSimpleGrabberService(
        () -> new SimpleMockFrameGrabber() {
          @Override
          public void start() throws FrameGrabber.Exception {
            throw new FrameGrabber.Exception(exceptionMessage);
          }
        });
    grabberService.startUp();
    fail("Should have thrown an exception when starting");
  } catch (GrabberService.GrabberServiceException e) {
    assertThat(e.getCause()).hasMessage(exceptionMessage);
    throw e;
  }
  fail("Should have rethrown the exception in the catch block");
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:21,代码来源:GrabberServiceTest.java

示例11: run

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
public void run() {
	try {
		grabber = FrameGrabber.createDefault(CAMERA_NUM);
		converter = new OpenCVFrameConverter.ToIplImage();
		grabber.start();

		int posX = 0;
		int posY = 0;
		while (true) {
			img = converter.convert(grabber.grab());
			if (img != null) {
				// show image on window
				cvFlip(img, img, 1);// l-r = 90_degrees_steps_anti_clockwise
				canvas.showImage(converter.convert(img));
				IplImage detectThrs = getThresholdImage(img);

				CvMoments moments = new CvMoments();
				cvMoments(detectThrs, moments, 1);

				double mom10 = cvGetSpatialMoment(moments, 1, 0);
				double mom01 = cvGetSpatialMoment(moments, 0, 1);
				double area = cvGetCentralMoment(moments, 0, 0);
				posX = (int) (mom10 / area);
				posY = (int) (mom01 / area);
				// only if its a valid position
				if (posX > 0 && posY > 0) {
					paint(img, posX, posY);
				}
			}
			// Thread.sleep(INTERVAL);
		}
	} catch (Exception e) {
	}
}
 
开发者ID:MeAnupSarkar,项目名称:ExoVisix,代码行数:35,代码来源:ColoredObjectTracker.java

示例12: grabDepth

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
@Override
public void grabDepth() {
    try {
        depthCamera.currentImage = grabber.grabDepth();

        ((WithTouchInput) depthCamera).newTouchImageWithColor(colorCamera.currentImage);
    } catch (FrameGrabber.Exception ex) {
        Logger.getLogger(CameraOpenKinect.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:11,代码来源:CameraOpenKinect.java

示例13: grabColor

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
@Override
public void grabColor() {
    try {
        colorCamera.updateCurrentImage(grabber.grabVideo());
    } catch (FrameGrabber.Exception ex) {
        Logger.getLogger(CameraOpenKinect.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:9,代码来源:CameraOpenKinect.java

示例14: start

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
@Override
public void start() {
    FFmpegFrameGrabber grabberFF = new FFmpegFrameGrabber(this.cameraDescription);

    grabberFF.setImageMode(FrameGrabber.ImageMode.COLOR);
    
    this.setPixelFormat(PixelFormat.BGR);
    
    grabberFF.setFormat(this.imageFormat);
    grabberFF.setImageWidth(width());
    grabberFF.setImageHeight(height());
    grabberFF.setFrameRate(frameRate);
    

    try {
        grabberFF.start();
        this.grabber = grabberFF;
        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;
    }
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:29,代码来源:CameraFFMPEG.java

示例15: initialize

import org.bytedeco.javacv.FrameGrabber; //导入依赖的package包/类
@Override
public void initialize() throws IOException {
  try {
    frameGrabber = new FFmpegFrameGrabber(path);
    frameGrabber.start();
    final double fps = frameGrabber.getFrameRate();
    fpsSocket.setValue(fps);
    frameCount = frameGrabber.getLengthInFrames();
    if (frameCount <= 1) {
      // Only one frame, no point in scheduling automatic updates to grab the same
      // image over and over
      manualGrabberService.submit(this::grabNextFrame);
    } else {
      grabberFuture = Executors.newSingleThreadScheduledExecutor(DaemonThread::new)
          .scheduleAtFixedRate(
              () -> {
                if (!isPaused()) {
                  grabNextFrame();
                }
              },
              0L,
              (long) (1e3 / fps),
              TimeUnit.MILLISECONDS
          );
    }
  } catch (FrameGrabber.Exception e) {
    throw new IOException("Could not open video file " + path, e);
  }
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:30,代码来源:VideoFileSource.java


注:本文中的org.bytedeco.javacv.FrameGrabber类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。