-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
208 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 110 additions & 17 deletions
127
app/src/main/java/de/serviceflow/frankenstein/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,126 @@ | ||
package de.serviceflow.frankenstein; | ||
|
||
import java.util.Arrays; | ||
import org.opencv.core.CvException; | ||
import org.opencv.core.Mat; | ||
|
||
import de.serviceflow.frankenstein.fxml.FxMain; | ||
import de.serviceflow.frankenstein.fxml.ProcessingSceneController; | ||
import de.serviceflow.frankenstein.plugin.api.DefaultSegmentConfigController; | ||
import de.serviceflow.frankenstein.plugin.api.SegmentVideoFilter; | ||
import de.serviceflow.frankenstein.vf.VideoStreamSource; | ||
import javafx.application.Platform; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
|
||
System.out.println("Args: " + Arrays.toString(args)); | ||
|
||
Configuration c = Configuration.cliCreateConfiguration(args); | ||
if (c == null) { | ||
System.out.println(Configuration.getUsage()); | ||
System.exit(0); | ||
} | ||
|
||
if (args.length == 0 || c.isVisual()) { | ||
c.init(); | ||
|
||
if (c.isVisual()) { | ||
FxMain.fxmain(c); | ||
} else { | ||
new Main().runcli(c); | ||
} | ||
} | ||
|
||
private void runcli(Configuration configuration) { | ||
CliProcessingListener l = new CliProcessingListener(); | ||
MovieProcessor processor = new MovieProcessor(configuration); | ||
try { | ||
processor.init(l); | ||
runProcessing(processor, l); | ||
} catch (CvException e) { | ||
// taskError(e.toString()); | ||
} | ||
} | ||
|
||
private void runProcessing(MovieProcessor processor, CliProcessingListener l) { | ||
Runnable r = new Runnable() { | ||
public void run() { | ||
|
||
long seconds = System.currentTimeMillis() / 1000; | ||
|
||
if (processor.processVideo(l)) { | ||
|
||
seconds = System.currentTimeMillis() / 1000 - seconds; | ||
|
||
System.out.println("Done in " + seconds + "s."); | ||
} else { | ||
// taskError("Task failed"); | ||
} | ||
} | ||
}; | ||
ExecutorThread.getInstance().execute(r, new Runnable() { | ||
@Override | ||
public void run() { | ||
ExecutorThread.shutdown(); | ||
System.exit(0); | ||
} | ||
}); | ||
|
||
} | ||
|
||
private class CliProcessingListener implements ProcessingListener { | ||
|
||
@Override | ||
public void configChanged(DefaultSegmentConfigController segmentConfigController, | ||
SegmentVideoFilter selectedFilter) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void videoStarted(int frames, double fps) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void nextFrameLoaded(VideoStreamSource s) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void nextFrameProcessed(Mat frame, int frameId) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void seekDone(int frameId) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void seeking(int i) { | ||
// TODO Auto-generated method stub | ||
|
||
de.serviceflow.frankenstein.fxml.FxMain.fxmain(c); | ||
/* | ||
* Class<?> fxMain; try { fxMain = | ||
* Class.forName("de.serviceflow.frankenstein.fxml.FxMain"); | ||
* Class<?> parameterTypes[] = | ||
* {de.serviceflow.frankenstein.Configuration.class}; Method main = | ||
* fxMain.getDeclaredMethod("fxmain", parameterTypes); Object[] | ||
* invokeArgs = {c}; main.invoke(fxMain, invokeArgs); } catch | ||
* (ClassNotFoundException | IllegalAccessException | | ||
* IllegalArgumentException | InvocationTargetException | | ||
* NoSuchMethodException | SecurityException e) { | ||
* e.printStackTrace(); } | ||
*/ | ||
} | ||
|
||
@Override | ||
public void prematureEnd(int realFrameCount) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void taskUpdate(String timeStamp, String message) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void taskError(String errorMessage) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.