本文整理了Java中com.github.sarxos.webcam.Webcam.isOpen()
方法的一些代码示例,展示了Webcam.isOpen()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Webcam.isOpen()
方法的具体详情如下:
包路径:com.github.sarxos.webcam.Webcam
类名称:Webcam
方法名:isOpen
[英]Is webcam open?
[中]网络摄像头开着吗?
代码示例来源:origin: sarxos/webcam-capture
@Override
protected Void doInBackground() throws Exception {
try {
if (webcam.isOpen()) {
errored = !webcam.close();
}
} catch (WebcamException e) {
errored = true;
throw e;
} finally {
repaintPanel();
}
return null;
}
};
代码示例来源:origin: sarxos/webcam-capture
@Override
protected Void doInBackground() throws Exception {
try {
if (!webcam.isOpen()) {
errored = !webcam.open();
}
} catch (WebcamException e) {
errored = true;
throw e;
} finally {
starting = false;
repaintPanel();
}
return null;
}
};
代码示例来源:origin: sarxos/webcam-capture
@Override
public void run() {
running.set(true);
while (running.get() && webcam.isOpen()) {
try {
detect();
Thread.sleep(interval);
} catch (InterruptedException e) {
break;
} catch (Exception e) {
WebcamExceptionHandler.handle(e);
}
}
running.set(false);
}
}
代码示例来源:origin: sarxos/webcam-capture
/**
* Perform single panel area update (repaint newly obtained image).
*/
private void update() {
// do nothing when updater not running, when webcam is closed, or
// panel repainting is paused
if (!running.get() || !webcam.isOpen() || paused) {
return;
}
// get new image from webcam
BufferedImage tmp = supplier.get();
boolean repaint = true;
if (tmp != null) {
// ignore repaint if image is the same as before
if (image == tmp) {
repaint = false;
}
errored = false;
image = tmp;
}
if (repaint) {
repaintPanel();
}
}
}
代码示例来源:origin: sarxos/webcam-capture
if (webcam.isOpen()) {
代码示例来源:origin: sarxos/webcam-capture
public static final void capture(Webcam webcam, File file, String format) {
if (!webcam.isOpen()) {
webcam.open();
}
try {
ImageIO.write(webcam.getImage(), format, file);
} catch (IOException e) {
throw new WebcamException(e);
}
}
代码示例来源:origin: sarxos/webcam-capture
public static final void capture(Webcam webcam, File file) {
if (!webcam.isOpen()) {
webcam.open();
}
try {
ImageIO.write(webcam.getImage(), ImageUtils.FORMAT_JPG, file);
} catch (IOException e) {
throw new WebcamException(e);
}
}
代码示例来源:origin: sarxos/webcam-capture
if (!webcam.isOpen() || socket.isInputShutdown() || socket.isClosed()) {
br.close();
bos.close();
代码示例来源:origin: sarxos/webcam-capture
protected void detect() {
if (!webcam.isOpen()) {
motion = false;
return;
}
BufferedImage currentOriginal = webcam.getImage();
if (currentOriginal == null) {
motion = false;
return;
}
final BufferedImage currentFiltered = algorithm.filter(currentOriginal);
final boolean motionDetected = algorithm.detect(previousFiltered, currentFiltered);
if (motionDetected) {
motion = true;
lastMotionTimestamp = System.currentTimeMillis();
notifyMotionListeners(currentOriginal);
}
previousOriginal = currentOriginal;
previousFiltered = currentFiltered;
}
代码示例来源:origin: sarxos/webcam-capture
private void tick() {
if (!webcam.isOpen()) {
return;
if (webcam.isOpen()) {
try {
executor.schedule(this, delay, TimeUnit.MILLISECONDS);
代码示例来源:origin: stackoverflow.com
Webcam webcam = Webcam.getDefault(); // non-default (e.g. USB) webcam can be used too
webcam.open();
Result result = null;
BufferedImage image = null;
if (webcam.isOpen()) {
if ((image = webcam.getImage()) == null) {
continue;
}
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
result = new MultiFormatReader().decode(bitmap);
} catch (NotFoundException e) {
// fall thru, it means there is no QR code in image
}
}
if (result != null) {
System.out.println("QR code data is: " + result.getText());
}
代码示例来源:origin: io.rhiot/camel-webcam
private Webcam openWebcam(Webcam webcam, Dimension dimension) {
//Once started another endpoint may want to change from low res to high res, for example
if (webcam.isOpen() && isStarted() && !dimension.equals(webcam.getViewSize())) {
webcam.close();
}
if (!webcam.isOpen() && dimension != null) {
webcam.setCustomViewSizes(new Dimension[]{dimension});
webcam.setViewSize(dimension);
webcam.open(true);
} else if (!webcam.isOpen()) {
webcam.open(true);
}
return webcam;
}
代码示例来源:origin: io.rhiot/camel-webcam
@Override
public void process(Exchange exchange) throws Exception {
Webcam webcam = getEndpoint().getWebcam();
if (webcam == null) {
throw new WebcamNotFoundException("No webcams found");
} else if (!webcam.isOpen() && !webcam.open()) {
throw new IllegalStateException("Unable to open webcam");
}
BufferedImage image = webcam.getImage();
if (image != null) {
exchange.getIn().setBody(ImageUtils.toByteArray(image, getEndpoint().getFormat()));
}
}
代码示例来源:origin: stackoverflow.com
BufferedImage image = null;
if (webcam.isOpen()) {
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-micro
public static void main(String[] args) throws Exception
{
Webcam webcam = Webcam.getDefault();
webcam.setViewSize(WebcamResolution.VGA.getSize());
if(webcam.isOpen())
webcam.close();
webcam.open();
SequenceEncoder enc = new SequenceEncoder(new File("out.ts"));
for(int i=0; i<100; i++)
{
enc.encodeImage(webcam.getImage());
try
{
Thread.sleep(100);
}
catch(Exception e)
{
}
}
enc.finish();
}
}
代码示例来源:origin: io.rhiot/camel-webcam
@Override
protected int poll() throws Exception {
if (getEndpoint().getWebcam() != null && getEndpoint().getWebcam().isOpen()) {
Webcam webcam = getEndpoint().getWebcam();
BufferedImage image = webcam.getImage();
if (image != null) {
WebcamHelper.consumeBufferedImage(image, getProcessor(), getEndpoint(), getExceptionHandler());
return 1;
} else {
log.debug("No image returned from the webcam poll.");
return 0;
}
} else {
return 0;
}
}
内容来源于网络,如有侵权,请联系作者删除!