mirror of
https://github.com/processing/processing4.git
synced 2026-01-30 03:41:15 +01:00
Capture throws runtime error when no camera is available, fix in checkResolutions() method to correctly use fps
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user