當前位置: 首頁>>代碼示例>>Java>>正文


Java Webcam類代碼示例

本文整理匯總了Java中com.github.sarxos.webcam.Webcam的典型用法代碼示例。如果您正苦於以下問題:Java Webcam類的具體用法?Java Webcam怎麽用?Java Webcam使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Webcam類屬於com.github.sarxos.webcam包,在下文中一共展示了Webcam類的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();
}
 
開發者ID:badarshahzad,項目名稱:SudoTimer,代碼行數:23,代碼來源:MainViewController.java

示例2: 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);
	}
}
 
開發者ID:DrDab,項目名稱:dahak,代碼行數:26,代碼來源:CamBot.java

示例3: 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);
}
 
開發者ID:alexycruz1,項目名稱:LP_Proyecto,代碼行數:17,代碼來源:Principal.java

示例4: 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();
        }
    }
 
開發者ID:tiagorlampert,項目名稱:sAINT,代碼行數:11,代碼來源:Cam.java

示例5: initialize

import com.github.sarxos.webcam.Webcam; //導入依賴的package包/類
@Override
public void initialize(URL arg0, ResourceBundle arg1) {

    fpBottomPane.setDisable(true);
    final ObservableList<WebCamInfo> options = FXCollections.observableArrayList();
    int webCamCounter = 0;
    for (Webcam webcam : Webcam.getWebcams()) {
        final WebCamInfo webCamInfo = new WebCamInfo(webCamCounter, webcam.getName());
        options.add(webCamInfo);
        webCamCounter++;
    }
    cbCameraOptions.setItems(options);
    cbCameraOptions.setPromptText(cameraListPromptText);
    cbCameraOptions.getSelectionModel().selectedItemProperty().addListener((arg01, arg11, arg2) -> {
        if (arg2 != null) {
            LOGGER.info("WebCam Index: " + arg2.webCamIndex + ": WebCam Name:" + arg2.webCamName);
            initializeWebCam(arg2.webCamIndex);
        }
    });
    Platform.runLater(this::setImageViewSize);

    btnStartCamera.setOnAction(this::startCamera);
    btnStopCamera.setOnAction(this::stopCamera);
    btnDisposeCamera.setOnAction(this::disposeCamera);

}
 
開發者ID:Evegen55,項目名稱:main_carauto_board,代碼行數:27,代碼來源:WebCamPreviewController.java

示例6: initializeWebCam

import com.github.sarxos.webcam.Webcam; //導入依賴的package包/類
private void initializeWebCam(final int webCamIndex) {

        EXECUTOR_SERVICE.submit(() -> {
            if (selWebCam == null) {
                selWebCam = Webcam.getWebcams().get(webCamIndex);
                selWebCam.open();
            } else {
                closeCamera();
                selWebCam = Webcam.getWebcams().get(webCamIndex);
                selWebCam.open();
            }
            startWebCamStream();
            return null;
        });

        fpBottomPane.setDisable(false);
        btnStartCamera.setDisable(true);
    }
 
開發者ID:Evegen55,項目名稱:main_carauto_board,代碼行數:19,代碼來源:WebCamPreviewController.java

示例7: 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;
 }
 
開發者ID:fracpete,項目名稱:screencast4j,代碼行數:25,代碼來源:SarxosWebcamRecorder.java

示例8: refreshWebcamSizes

import com.github.sarxos.webcam.Webcam; //導入依賴的package包/類
/**
  * Refreshes the combobox with the available sizes for the currently selected
  * webcam.
  */
 protected void refreshWebcamSizes() {
   String 	id;

   if ((m_ModelWebcamAvailable.getSize() == 0 ) || (m_ComboBoxWebcamAvailable.getSelectedIndex() == -1))
     return;

   m_ModelWebcamSizes.removeAllElements();
   id = (String) m_ComboBoxWebcamAvailable.getSelectedItem();
   for (Webcam webcam: Webcam.getWebcams()) {
     if (id.equals(webcam.getName())) {
for (Dimension dim: webcam.getViewSizes())
  m_ModelWebcamSizes.addElement((int) dim.getWidth() + SIZE_SEPARATOR + (int) dim.getHeight());
break;
     }
   }
   updatePreviewRecorders();
 }
 
開發者ID:fracpete,項目名稱:screencast4j,代碼行數:22,代碼來源:ScreencastPanel.java

示例9: 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));
			}
		}
 
開發者ID:cycronix,項目名稱:cloudturbine,代碼行數:25,代碼來源:CTwebcam.java

示例10: 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);
	}
 
開發者ID:cycronix,項目名稱:cloudturbine,代碼行數:19,代碼來源:CTcamera.java

示例11: init

import com.github.sarxos.webcam.Webcam; //導入依賴的package包/類
/**
 *
 */
@Override
public void init() {

  for (Webcam wc : Webcam.getWebcams()) {
    if (wc.getName().replaceAll(" ", "").equals(deviceName.replaceAll(" ", ""))) {
      webcam = wc;
    }
  }
  Dimension preferred = null;
  for (Dimension dimension : webcam.getViewSizes()) {
    if (dimension.getWidth() < 1025) {
      preferred = dimension;
    }
  }
  if (preferred != null) {
    webcam.setViewSize(preferred);
  }
  webcam.open();
}
 
開發者ID:LavaJUG,項目名稱:stream-catcher,代碼行數:23,代碼來源:WebcamPlugin.java

示例12: 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;
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:23,代碼來源:WebCamReceiptScheduleModel.java

示例13: 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);
}
 
開發者ID:phrack,項目名稱:ShootOFF,代碼行數:21,代碼來源:CameraFactory.java

示例14: SarxosCaptureCamera

import com.github.sarxos.webcam.Webcam; //導入依賴的package包/類
public SarxosCaptureCamera(final String cameraName) {
	final List<Webcam> webcams = Webcam.getWebcams();
	int cameraIndex = -1;

	for (int i = 0; i < webcams.size(); i++) {
		if (webcams.get(i).getName().equals(cameraName)) {
			cameraIndex = i;
			break;
		}
	}

	if (cameraIndex < 0) throw new IllegalArgumentException("Camera not found: " + cameraName);

	camera = new VideoCapture();
	this.cameraIndex = cameraIndex;

}
 
開發者ID:phrack,項目名稱:ShootOFF,代碼行數:18,代碼來源:SarxosCaptureCamera.java

示例15: loadSettings

import com.github.sarxos.webcam.Webcam; //導入依賴的package包/類
private void loadSettings()
{
    Webcam.setDriver(new IpCamDriver());

    try {
        settings = new Properties();
        InputStream in = getClass().getResourceAsStream("settings.properties");
        if(in == null) {
            System.out.println("ERROR");
        }
        settings.load(in);
        in.close();
    } catch(IOException ex) {
        Logger.getLogger(Display.class.getName()).log(Level.SEVERE, null, ex);
    }

}
 
開發者ID:InternationalSchoolBangkok,項目名稱:ROV,代碼行數:18,代碼來源:Display.java


注:本文中的com.github.sarxos.webcam.Webcam類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。