本文整理匯總了Java中com.github.sarxos.webcam.Webcam.getDefault方法的典型用法代碼示例。如果您正苦於以下問題:Java Webcam.getDefault方法的具體用法?Java Webcam.getDefault怎麽用?Java Webcam.getDefault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.sarxos.webcam.Webcam
的用法示例。
在下文中一共展示了Webcam.getDefault方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: takePic
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
public void takePic() {
// get default webcam and open it
Webcam webcam = Webcam.getDefault();
Dimension[] nonStandardResolutions = new Dimension[] { WebcamResolution.PAL.getSize(),
WebcamResolution.HD720.getSize(), new Dimension(2000, 1000), new Dimension(1000, 500), };
webcam.setCustomViewSizes(nonStandardResolutions);
webcam.setViewSize(WebcamResolution.HD720.getSize());
webcam.open();
// get image
BufferedImage image = webcam.getImage();
// save image to PNG file
try {
ImageIO.write(image, "PNG", new File("src/capture/test.png"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
webcam.close();
}
示例2: VideoLlamada
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
public void VideoLlamada() {
Webcam webcam = Webcam.getDefault();
WebcamPanel panel = new WebcamPanel(webcam);
panel.setFPSDisplayed(true);
JFrame window = new JFrame("VIDEO CALL");
window.setTitle("Haciendo videollamada con " + jt_Name_Contacts.getText());
window.setExtendedState(MAXIMIZED_BOTH);
panel.setFillArea(true);
window.add(panel);
window.pack();
window.setVisible(true);
}
示例3: Capture
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
public static void Capture(String filePath, String fileName, int widthx, int heighty) throws IOException {
Webcam webcam = Webcam.getDefault();
if (webcam != null) {
// System.out.println("Webcam: " + webcam.getName());
webcam.setViewSize(new Dimension(widthx, heighty));
webcam.open();
ImageIO.write(webcam.getImage(), "PNG", new File(filePath + fileName + ".png"));
webcam.close();
}
}
示例4: snapImg
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
/**
* CamBot requires dependencies for Sarxos Webcam Capture.
* If this is not a needed function in your environment,
* please exclude them to reduce payload size, and comment out the imports
* in this file.
*
*/
public static void snapImg() throws IOException
{
try
{
Webcam wc = Webcam.getDefault();
wc.open();
File tgt = new File ("C:/ClassPolicy/cam.png");
if (tgt.exists()) {
tgt.delete();
}
ImageIO.write(wc.getImage(), "PNG", tgt);
Chocolat.println("[CamBot] Successfully snapped a shot!");
}
catch (Exception e)
{
Chocolat.println("[CamBot] Encountered an exception: " + e);
}
}
示例5: getWebcam
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
/**
* Tries to obtain the requested webcam.
*
* @return the webcam, null if failed to obtain
*/
protected Webcam getWebcam() {
Webcam result;
result = null;
if (m_WebcamID.isEmpty()) {
result = Webcam.getDefault();
}
else {
for (Webcam webcam: Webcam.getWebcams()) {
if (webcam.getName().equals(m_WebcamID)) {
result = webcam;
break;
}
}
}
return result;
}
示例6: run
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
@Override
public void run() {
Webcam webcam = Webcam.getDefault();
webcam.setViewSize(WebcamResolution.VGA.getSize());
webcam.open();
JFrame frame=new JFrame();
frame.setTitle("webcam capture");
// frame.setLayout(new FlowLayout());
JLabel lbl = new JLabel();
frame.add(lbl);
frame.setVisible(true);
while (true) {
if (!webcam.isOpen()) break;
BufferedImage image = webcam.getImage();
if (image == null) break;
frame.setSize(image.getWidth(),image.getHeight());
lbl.setIcon(new ImageIcon(image));
}
}
示例7: main
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
public static void main(String[] args) throws InterruptedException {
Webcam webcam = Webcam.getDefault();
webcam.setViewSize(WebcamResolution.VGA.getSize());
WebcamPanel panel = new WebcamPanel(webcam);
panel.setFPSDisplayed(true);
// panel.setDisplayDebugInfo(true);
panel.setImageSizeDisplayed(true);
panel.setMirrored(true);
JFrame window = new JFrame("Test webcam panel");
window.add(panel);
window.setResizable(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.pack();
window.setVisible(true);
}
示例8: getWebcam
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
public Webcam getWebcam()
{
if (webcam == null)
{
webcam = Webcam.getDefault();
if (webcam == null)
{
throw new AdempiereException("@" + ERR_WEBCAM_NOT_FOUND + "@");
}
//
// Set to maximum allowed size (if any)
final Dimension[] viewSizes = webcam.getViewSizes();
if (viewSizes != null && viewSizes.length > 0)
{
// they're ordered by size, so get the last one (maximum)
final Dimension viewSize = viewSizes[viewSizes.length - 1];
webcam.setViewSize(viewSize);
}
}
return webcam;
}
示例9: getDefault
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
public static Optional<Camera> getDefault() {
Camera defaultCam;
if (isMac) {
if (defaultWebcam == null)
defaultCam = null;
else
defaultCam = new SarxosCaptureCamera(defaultWebcam.getName());
} else {
final Webcam cam = Webcam.getDefault();
defaultCam = cam == null ? null : new SarxosCaptureCamera(cam.getName());
}
if (defaultCam == null && !registeredCameras.isEmpty()) {
defaultCam = registeredCameras.get(0);
}
return Optional.ofNullable(defaultCam);
}
示例10: showDialog
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
/**
* Show the scan dialog
*
* @param parent Parent frame
* @return Text string from the QR code or null
*/
public static String showDialog(JDialog parent) {
String result = null;
try {
Webcam webcam = Webcam.getDefault();
if (webcam == null) {
JOptionPane.showMessageDialog(parent, "No webcam available", "No Webcam", JOptionPane.ERROR_MESSAGE);
} else {
log.info("Using webcam " + webcam.getName());
ScanDialog dialog = new ScanDialog(parent, webcam);
dialog.pack();
dialog.setLocationRelativeTo(parent);
dialog.setVisible(true);
result = dialog.qrString;
}
} catch (Exception exc) {
Main.logException("Exception while displaying dialog", exc);
}
return result;
}
示例11: init
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
@Override
public void init() {
//Initialize the libgdx objects
spriteBatch = new SpriteBatch();
background = new Texture(width,height,Format.RGB888);
//Initialize the image buffers
image = new byte[width*height*3];
imageByteBuffer = ByteBuffer.allocateDirect(width*height*3);
//Initialize the device camera interface
camera = Webcam.getDefault();
camera.setViewSize(new Dimension(width,height));
camera.open();
//Launch the device camera listener
cameraThread = new Thread(){
@Override
public void run(){
webcamRunner();
}
};
running = true;
cameraThread.start();
}
示例12: show
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
public void show()
{
picturePanel.setText("");
frame.setVisible(true);
webcam = Webcam.getDefault();
webcam.open(); //open the webcam
updatePreviewTimer = new Timer();
saveSampleTimer = new Timer();
countdownTimer = new Timer();
updatePreviewTimer.schedule(updatePreviewTask, 40, 40); //run the timer which updates the webcam preview
time = 5;
countdownTimer.schedule(countdownTask, 1000, 1000); //run the timer which counts 5 seconds before actual taking samples
}
示例13: prepare
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
private void prepare()
{
webcam = Webcam.getDefault();
webcam.open(); //opens the webcam
refreshTimer = new Timer();
refreshTimer.schedule(refreshTask, 40, 40); //runs the webcam preview update timer
takeSampleTimer = new Timer();
takeSampleTimer.schedule(takeSampleTask, 1000, 1000); //runs the taking a face sample timer
}
示例14: findWebcam
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
private static Webcam findWebcam(String url) throws MalformedURLException {
if (url != null) {
Webcam.setDriver(new IpCamDriver());
IpCamDeviceRegistry.register(new IpCamDevice("Set", url, IpCamMode.PULL));
}
Webcam webcam = Webcam.getDefault();
if (webcam == null) {
throw new IllegalStateException("Cannot find webcam");
}
webcam.open();
return webcam;
}
示例15: startUp
import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
@Override
protected void startUp() throws Exception {
detector = new MotionDetector(Webcam.getDefault());
detector.setInterval(500);
//DEFAULT_AREA_THREASHOLD = 0.2;
//AreaThreshold: The percentage threshold of image that has different pixels for motion to be detected (a double 0-100, with default 0.2).
detector.setAreaThreshold(eyeballsConfiguration.getAreaThreshold());
//DEFAULT_PIXEL_THREASHOLD = 25;
//PixelThreshold: Intensity threshold whereby a pixel is deemed to different (an int 0 - 255, with default 25).
detector.setPixelThreshold(eyeballsConfiguration.getPixelDifferentThreshold());
detector.addMotionListener(motionDetectedListener);
detector.start();
}