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


Java Webcam.getWebcams方法代碼示例

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


在下文中一共展示了Webcam.getWebcams方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: start

import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
@Override
public void start() throws Exception {
  List<Webcam> found = Webcam.getWebcams();
  webcam = found.get(cameraIndex);
  Dimension[] sizes = webcam.getViewSizes();
  int bestError = Integer.MAX_VALUE;
  Dimension best = null;
  for (Dimension d : sizes) {
    int error = (d.width - desiredWidth) * (d.height - desiredHeight);
    if (error < bestError) {
      bestError = error;
      best = d;
    }
  }
  webcam.setViewSize(best);
  webcam.open();
  Dimension actualSize = webcam.getViewSize();
  log.info("Camera Open With Resolution {}", actualSize);
}
 
開發者ID:MyRobotLab,項目名稱:myrobotlab,代碼行數:20,代碼來源:SarxosFrameGrabber.java

示例7: createUIComponents

import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
private void createUIComponents() {
    Dimension size = WebcamResolution.QVGA.getSize();
    java.util.List<Webcam> webcams = Webcam.getWebcams();
    if (webcams.size() > 0) {
        webcam = webcams.get(0);
        webcam.setViewSize(size);
        panel = new WebcamPanel(webcam);
        panel.setPreferredSize(size);
        scanPanel.add(panel);
    } else {
        onCancel();
        new MessageDialog(LocaliserUtils.getString("camer_is_not_available")).showMsg();
    }

}
 
開發者ID:bither,項目名稱:bither-desktop-java,代碼行數:16,代碼來源:ScanQRCodeDialog.java

示例8: findAllDevices

import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
public static void findAllDevices()
{
	destroyAllDevices();

	try
	{
		for ( Webcam w : Webcam.getWebcams( 30, TimeUnit.SECONDS ) )
		{
			RegisterNewInput( w );
		}
	}
	catch ( WebcamException | TimeoutException e )
	{
		e.printStackTrace();
	}
}
 
開發者ID:PenoaksDev,項目名稱:OpenSpaceDVR,代碼行數:17,代碼來源:InputRegistry.java

示例9: init

import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
public static void init()
{
	LinkedHashMap<String, Webcam> detectedCameras = new LinkedHashMap<String, Webcam>();
	List<Webcam> cams = Webcam.getWebcams();
	for (Webcam cam : cams)
	{
		log.info("Found webcam: " + cam.getName());
		detectedCameras.put(cam.getName(), cam);
	}
	if (detectedCameras.size() == 0)
	{
		throw new RuntimeException("The WebUI module has been enabled but no webcams are connected to the machine");
	}
	if (NMOConfiguration.INSTANCE.integrations.webUI.webcams.size() == 0)
	{
		throw new RuntimeException("You must specify at least one webcam in the NMO config file if the WebUI module is enabled");
	}
	webcams = new WebcamData[NMOConfiguration.INSTANCE.integrations.webUI.webcams.size()];
	webcamNames = new String[NMOConfiguration.INSTANCE.integrations.webUI.webcams.size()];
	int id = 0;
	for (String cc : NMOConfiguration.INSTANCE.integrations.webUI.webcams.keySet())
	{
		String camName = NMOConfiguration.INSTANCE.integrations.webUI.webcams.get(cc);
		webcams[id] = initCamera(cc, camName);
		webcamNames[id] = camName;
		id++;
	}
}
 
開發者ID:PolyphasicDevTeam,項目名稱:NoMoreOversleeps,代碼行數:29,代碼來源:WebcamCapture.java

示例10: refreshWebcams

import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
/**
 * Refreshes the combobox with the available
 */
protected void refreshWebcams() {
  m_ModelWebcamAvailable.removeAllElements();
  for (Webcam webcam: Webcam.getWebcams())
    m_ModelWebcamAvailable.addElement(webcam.getName());
  if (m_ModelWebcamAvailable.getSize() > 0)
    m_ComboBoxWebcamAvailable.setSelectedIndex(0);
  updatePreviewRecorders();
}
 
開發者ID:fracpete,項目名稱:screencast4j,代碼行數:12,代碼來源:ScreencastPanel.java

示例11: refreshWebcams

import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
/**
 * Refreshes the list of webcams
 */
public void refreshWebcams() {
    Webcam selectedWebcam = getCurrentWebcam();
    webcamModel.removeAllElements();
    for (Webcam webcam : Webcam.getWebcams()) {
        webcamModel.addElement(webcam);
    }
    if (selectedWebcam != null) {
        webcamModel.setSelectedItem(selectedWebcam);
    }
}
 
開發者ID:Jelmerro,項目名稱:UniCam,代碼行數:14,代碼來源:SettingsDialog.java

示例12: SearchQRCode

import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
public SearchQRCode(){
	Dimension size = WebcamResolution.QVGA.getSize();
	List<Webcam> webcams = Webcam.getWebcams();
	if(webcams != null && webcams.size() > 0){
		webcam = webcams.get(0);
		webcam.setViewSize(size);
	}else{
		throw new RuntimeException("No webcam found...");
	}
}
 
開發者ID:devmel,項目名稱:SerialTerminal,代碼行數:11,代碼來源:SearchQRCode.java

示例13: getInfos

import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
public static CameraInfo[] getInfos() {
	try {
		List<Webcam> cams = Webcam.getWebcams(5000);
		CameraInfo[] result = new CameraInfo[cams.size()];
		int idx = 0;
		for(Webcam cam : cams)
			result[idx++] = new CameraInfo(cam);
		return result;
	} catch (WebcamException | TimeoutException e) {
		return new CameraInfo[0];
	}
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:13,代碼來源:CameraInfo.java

示例14: selectDevice

import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
/**
 *
 * @return
 */
public static List<String> selectDevice() {
  List<String> devices = new ArrayList<>();
  for (Webcam wc : Webcam.getWebcams()) {
    devices.add(wc.getName());
  }
  return devices;
}
 
開發者ID:LavaJUG,項目名稱:stream-catcher,代碼行數:12,代碼來源:WebcamPlugin.java

示例15: getWebcams

import com.github.sarxos.webcam.Webcam; //導入方法依賴的package包/類
public static List<Camera> getWebcams() {
	if (isMac) return knownWebcams;

	final List<Camera> webcams = new ArrayList<>();

	int cameraIndex = 0;
	for (final Webcam w : Webcam.getWebcams()) {
		final Camera c;
		if (w.getDevice() instanceof IpCamDevice)
			c = new IpCamera(w);
		else
			c = new SarxosCaptureCamera(w.getName(), cameraIndex);

		synchronized (openCameras) {
			// If we already have an open instance of the camera
			// go ahead and reuse it in this list as opposed to
			// the newly created camera
			final int i = openCameras.indexOf(c);

			if (logger.isTraceEnabled()) logger.trace("Looking in openCameras for {} found at {}", w.getName(), i);
			if (i >= 0) {
				webcams.add(openCameras.get(i));
			} else {
				webcams.add(c);
			}
		}

		cameraIndex++;
	}

	webcams.addAll(registeredCameras);

	return webcams;
}
 
開發者ID:phrack,項目名稱:ShootOFF,代碼行數:35,代碼來源:CameraFactory.java


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