Capture throws runtime error when no camera is available, fix in checkResolutions() method to correctly use fps

This commit is contained in:
codeanticode
2012-06-04 17:49:22 +00:00
parent 9da96940a1
commit 5658c48eec
6 changed files with 19 additions and 12 deletions

View File

@@ -3,8 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011 Andres Colubri
Copyright (c) 2004-09 Ben Fry and Casey Reas
Copyright (c) 2004-12 Ben Fry and Casey Reas
The previous version of this code was developed by Hernando Barragan
This library is free software; you can redistribute it and/or
@@ -589,6 +588,11 @@ public class Capture extends PImage implements PConstants {
HashMap<String, Object> properties, String frameRate) {
this.parent = parent;
String[] cameras = list(sourceName);
if (cameras.length == 0) {
throw new RuntimeException("There are no cameras available for capture.");
}
Video.init();
// register methods
@@ -688,8 +692,7 @@ public class Capture extends PImage implements PConstants {
boolean suppRes = false;
for (int i = 0; i < resolutions.size(); i++) {
Resolution res = resolutions.get(i);
if (reqWidth == res.width && reqHeight == res.height &&
fps.equals("") || fps.equals(res.fpsString)) {
if (reqWidth == res.width && reqHeight == res.height && (fps.equals("") || fps.equals(res.fpsString))) {
suppRes = true;
break;
}

View File

@@ -3,8 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011 Andres Colubri
Based on code by Tal Shalif
Copyright (c) 2011-12 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -31,6 +30,12 @@ import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
/**
* This class loads the gstreamer native libraries.
* By Andres Colubri
* Based on code by Tal Shalif
*
*/
public class LibraryLoader {
public interface DummyLibrary extends Library {

View File

@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011 Andres Colubri
Copyright (c) 2011-12 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -29,7 +29,7 @@ import com.sun.jna.Platform;
class LibraryPath {
// This method returns the folder inside which the gstreamer library folder
// should be located.
// is located.
String get() {
URL url = this.getClass().getResource("LibraryPath.class");
if (url != null) {

View File

@@ -3,8 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011 Andres Colubri
Copyright (c) 2004-07 Ben Fry and Casey Reas
Copyright (c) 2004-12 Ben Fry and Casey Reas
The previous version of this code was developed by Hernando Barragan
This library is free software; you can redistribute it and/or

View File

@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011 Andres Colubri
Copyright (c) 2011-12 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public

View File

@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011 Andres Colubri
Copyright (c) 2011-12 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public