gpt4 book ai didi

com.github.sarxos.webcam.WebcamDevice类的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 13:25:05 29 4
gpt4 key购买 nike

本文整理了Java中com.github.sarxos.webcam.WebcamDevice类的一些代码示例,展示了WebcamDevice类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebcamDevice类的具体详情如下:
包路径:com.github.sarxos.webcam.WebcamDevice
类名称:WebcamDevice

WebcamDevice介绍

[英]Webcam device abstraction.
[中]网络摄像头设备抽象。

代码示例

代码示例来源:origin: sarxos/webcam-capture

@Override
  protected void handle() {

    WebcamDevice device = getDevice();

    if (device.isOpen()) {
      return;
    }

    if (device.getResolution() == null) {
      device.setResolution(device.getResolutions()[0]);
    }

    LOG.info("Opening webcam {}", device.getName());

    device.open();
  }
}

代码示例来源:origin: sarxos/webcam-capture

public static void main(String[] args) throws IOException {
    for (WebcamDevice d : new Gst1Driver().getDevices()) {
      System.out.println(d);
      d.getResolutions();
      d.open();
      ImageIO.write(d.getImage(), "JPG", new File("a.jpg"));
      d.close();
    }

  }
}

代码示例来源:origin: sarxos/webcam-capture

@Override
  protected void handle() {
    getDevice().dispose();
  }
}

代码示例来源:origin: sarxos/webcam-capture

@Override
  protected void handle() {

    WebcamDevice device = getDevice();
    if (!device.isOpen()) {
      return;
    }

    LOG.info("Closing {}", device.getName());

    device.close();
  }
}

代码示例来源:origin: sarxos/webcam-capture

@Override
  protected void handle() {

    WebcamDevice device = getDevice();
    if (!device.isOpen()) {
      return;
    }

    image = device.getImage();
  }
}

代码示例来源:origin: sarxos/webcam-capture

/**
 * Get webcam name (device name). The name of device depends on the value returned by the
 * underlying data source, so in some cases it can be human-readable value and sometimes it can
 * be some strange number.
 *
 * @return Name
 */
public String getName() {
  assert device != null;
  return device.getName();
}

代码示例来源:origin: sarxos/webcam-capture

/**
 * Get current webcam resolution in pixels.
 *
 * @return Webcam resolution (picture size) in pixels.
 */
public Dimension getViewSize() {
  return device.getResolution();
}

代码示例来源:origin: sarxos/webcam-capture

/**
 * Return list of supported view sizes. It can differ between vary webcam data sources.
 *
 * @return Array of supported dimensions
 */
public Dimension[] getViewSizes() {
  return device.getResolutions();
}

代码示例来源:origin: sarxos/webcam-capture

@Override
public List<WebcamDevice> getDevices() {
  List<WebcamDevice> devices = new GetDevicesTask(this).getDevices();
  if (LOG.isDebugEnabled()) {
    for (WebcamDevice device : devices) {
      LOG.debug("OpenIMAJ found device {}", device.getName());
    }
  }
  return devices;
}

代码示例来源:origin: org.boofcv/boofcv-WebcamCapture

public SimpleSequence(Webcam webcam, ImageType<T> imageType) {
  this.webcam = webcam;
  Dimension d = webcam.getDevice().getResolution();
  width = d.width;
  height = d.height;
  output = imageType.createImage(width,height);
}

代码示例来源:origin: sarxos/webcam-capture

/**
 * Register IP camera.
 *
 * @param ipcam the IP camera to be register
 * @return IP camera device
 */
public static IpCamDevice register(IpCamDevice ipcam) {
  for (WebcamDevice d : DEVICES) {
    String name = ipcam.getName();
    if (d.getName().equals(name)) {
      throw new WebcamException(String.format("Webcam with name '%s' is already registered", name));
    }
  }
  DEVICES.add(ipcam);
  rescan();
  return ipcam;
}

代码示例来源:origin: org.boofcv/WebcamCapture

public SimpleSequence(Webcam webcam, ImageType<T> imageType) {
  this.webcam = webcam;
  Dimension d = webcam.getDevice().getResolution();
  width = d.width;
  height = d.height;
  output = imageType.createImage(width,height);
}

代码示例来源:origin: sarxos/webcam-capture

@Override
public List<WebcamDevice> getDevices() {
  LOG.debug("Searching devices");
  if (grabber == null) {
    WebcamNewGrabberTask task = new WebcamNewGrabberTask(this);
    grabber = task.newGrabber();
    if (grabber == null) {
      return Collections.emptyList();
    }
  }
  List<WebcamDevice> devices = new GetDevicesTask(this).getDevices(grabber);
  if (LOG.isDebugEnabled()) {
    for (WebcamDevice device : devices) {
      LOG.debug("Found device {}", device.getName());
    }
  }
  return devices;
}

代码示例来源:origin: sarxos/webcam-capture

if (nd.getName().equals(od.getName())) {
  ni.remove();
  oi.remove();
  if (webcam.getDevice().getName().equals(device.getName())) {
    notified.add(webcam);
    break;
  if (webcam.getDevice().getName().equals(device.getName())) {
    notifyWebcamFound(webcam, listeners);
    break;

代码示例来源:origin: io.rhiot/camel-webcam

@Override
public void webcamFound(WebcamDiscoveryEvent event) {
  Webcam webcam = event.getWebcam();
  LOG.debug("Discovered webcam : {}", webcam.getDevice().getName());
  webcams.put(webcam.getDevice().getName(), webcam);
}

代码示例来源:origin: io.rhiot/camel-webcam

@Override
public void webcamGone(WebcamDiscoveryEvent event) {
  LOG.info("Webcam : {} is gone", event.getWebcam().getDevice().getName());
  webcams.remove(event.getWebcam().getDevice().getName());
}

代码示例来源:origin: com.github.sarxos/webcam-capture-driver-ipcam

/**
 * Register IP camera.
 *
 * @param ipcam the IP camera to be register
 * @return IP camera device
 */
public static IpCamDevice register(IpCamDevice ipcam) {
  for (WebcamDevice d : DEVICES) {
    String name = ipcam.getName();
    if (d.getName().equals(name)) {
      throw new WebcamException(String.format("Webcam with name '%s' is already registered", name));
    }
  }
  DEVICES.add(ipcam);
  rescan();
  return ipcam;
}

代码示例来源:origin: io.rhiot/camel-webcam

@Override
protected void doStart() throws Exception {
  super.doStart();
  installer = resolveInstaller();
  String requiredPackages = getRequiredPackages();
  try {
    if (!installer.install(requiredPackages) && !ignoreInstallerProblems) {
      throw new IllegalStateException("Unable to start webcam, failed to install dependencies");
    }
  } catch (Exception ex) {
    if(ignoreInstallerProblems) {
      LOG.warn(ex.getMessage());
    } else {
      throw ex;
    }
  }
  
  //Use the provided webcam/s
  if (getWebcams().size() == 0) {
    loadWebcamDriver();
    List<Webcam> webcamList = Webcam.getWebcams(timeout);
    if (webcamList == null || webcamList.size() == 0) {
      throw new IllegalStateException("No webcams found");
    }
    webcamList.forEach(w -> webcams.put(w.getDevice().getName(), w));
    LOG.info("Detected webcams : {}", webcams.keySet());
  }
  
}

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com