![JAR search and dependency download from the Maven repository](/logo.png)
com.github.sarxos.webcam.ds.cgt.WebcamReadBufferTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webcam-capture Show documentation
Show all versions of webcam-capture Show documentation
This library allows you to use your PC webcam, IP or network cameras directly from Java. It's compatible with most operating systems (Windows, Linux, MacOS).
package com.github.sarxos.webcam.ds.cgt;
import java.nio.ByteBuffer;
import com.github.sarxos.webcam.WebcamDevice;
import com.github.sarxos.webcam.WebcamDevice.BufferAccess;
import com.github.sarxos.webcam.WebcamDriver;
import com.github.sarxos.webcam.WebcamTask;
public class WebcamReadBufferTask extends WebcamTask {
private volatile ByteBuffer target = null;
public WebcamReadBufferTask(WebcamDriver driver, WebcamDevice device, ByteBuffer target) {
super(driver, device);
this.target = target;
}
public ByteBuffer readBuffer() {
try {
process();
} catch (InterruptedException e) {
return null;
}
return target;
}
@Override
protected void handle() {
WebcamDevice device = getDevice();
if (!device.isOpen()) {
return;
}
if (!(device instanceof BufferAccess)) {
return;
}
((BufferAccess) device).getImageBytes(target);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy