本文整理匯總了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);
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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);
}
示例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();
}
}
示例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();
}
}
示例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++;
}
}
示例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();
}
示例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);
}
}
示例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...");
}
}
示例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];
}
}
示例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;
}
示例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;
}