We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I've come across a weird problem in my program. I am making a program that launches a video after I use the function launch() inside it that initializes another program called video_segmentation. This program generates a txt file with information about when each shot and scene of the selected video begins and ends.
The problem here is that this program will not launch inside my selectInput()
unless I put another selectInput()
before it. Here's my code:
import processing.video.*;
import gab.opencv.*;
import java.awt.*;
import java.util.*;
import java.io.*;
OpenCV openCv;
PrintWriter output;
StringList kf;
StringList [] movieScenes;
int c=0;
BufferedReader HowManyScenes;
int lines;
String line = "1";
String [] scenes;
Movie theMov;
File selectionF, selectionT;
String selectText;
int fc;
ArrayList <PImage> frames= new ArrayList();
int avgFrameColor;
Boolean trufals=false;
Boolean process=true;
void setup() {
size(1280, 720);
//frameRate(200);
selectInput("Select a film to process:", "selectFilm");
}
void selectFilm(File selection) {
println("ola");
if (selection == null) {
println("Window was closed or you hit cancel.");
} else {
theMov = new Movie (this, selection.getAbsolutePath());
// println(selection.getAbsolutePath());
String [] params = split (selection.getAbsolutePath(), "\\");
String [] segmentation = {"C:/Users/Nuno/Desktop/Segmentation/windows64/video_segmentation", params[params.length-1]};
launch(segmentation);
println(segmentation);
//process=true;
}
}
void draw() {
if (theMov == null || selectText == null) {
trufals=false;
} else {
trufals=true;
}
//rest of my code which doesnt start untill I select both a video file and a txt file
}
The problem I have is in the setup I believe, because if I put another random selectInput()
before it all works fine and video_segmentation.exe will run. Example:
void setup(){
size(1280,720);
selectInput("hi","hi");
selectInput("Select a film to process:", "selectFilm", selectionF)
}
I discovered this because I was running another selectInput()
that initializes the function selectScenes()
which reads the file generated by video_segmentation.exe.
I would appreciate some help if anyone has any idea what this is about.
Answers
boolean
variables which function as task flags for the main draw().true
when in some foreign Thread. Then set them tofalse
& execute the task while finally in "Animation" Thread.Hello, and thank for your response. I read what you said so I made a little sketch following your instructions. This is what I have:
Once more, the line
launch(segmentation);
does not run the program unless I uncomment lineselectInput("hi","hi");
. Also the sketch doesnt give any errors or anything. It simply doesn't initializesvideo_segmentation.exe
.So I made a little test and I made him open a video instead of this program with the line
launch("C:/Users/Nuno/Desktop/Segmentation/windows64/sketch.mp4")
and it works. I don't know why doesnt thislaunch("C:/Users/Nuno/Desktop/Segmentation/windows64/ video_segmentation sketch.mp4")
work aswell, unless I put that newselectInput()
before the one that selects the file.Any ideas?
I think there's so many flag variables that somewhat makes difficult to reason about the sketch.
I've tweaked your sketch in order to "dry" it a little. :D
Although I've kept launch() there, got no idea whether it works though. :-\"
Its way better than what I had, but still does not work. I really don't know why. It probably has something to do with
video_segmentation.exe
itself. I really appreciate it though.