added webcam-mode and autoplay-mode

This commit is contained in:
2022-07-28 11:02:32 +02:00
parent 700f2593dc
commit 3b59eb8827
4 changed files with 142 additions and 46 deletions

View File

@@ -38,10 +38,10 @@ class SourceManager { //no constructor
void setImage(PImage img) { //set image to source
imageChanged = true;
source = img.get();
fallbackImage = source;
//fallbackImage = source;
nativeResoX = source.width;
nativeResoY = source.height;
println(nativeResoX);
//println(nativeResoX);
}
void fallback() {
@@ -49,7 +49,25 @@ class SourceManager { //no constructor
setImage(fallbackImage); //fallbackImage should always be a copy of the last image that worked
}
void startWebcam() {
String[] cameras = Capture.list();
println(cameras);
cam.start();
webcamMode = true;
}
void stopWebcam() {
cam.stop();
webcamMode = false;
}
void update() {
if (webcamMode) {
if (cam.available()) {
cam.read();
setImage(cam);
}
}
if (source == null) {
fallback();
}
@@ -105,6 +123,7 @@ class SourceManager { //no constructor
if (isImage(path) || isVideo(path)) {
println("Importing file " + path);
if (moviePlaying) movie.stop();
if (webcamMode) gui.webcam.setValue(false);
if (isImage(path)) {
moviePlaying = false;
setImage(loadImage(path));