Commit c251df2e authored by ludwig's avatar ludwig

changed methods in post processing so that the ttt.jar can be used as a...

changed methods in post processing so that the ttt.jar can be used as a library in external projects (and each post process step can be accessed individually)

git-svn-id: https://www2.in.tum.de/repos/ttt/trunk@95 0463f305-d864-43cb-8a47-61cf597d4139
parent 0ca107a6
......@@ -646,8 +646,10 @@ public class Index {
// //////////////////////////////////////////////////////////////////
// thumbnails
// //////////////////////////////////////////////////////////////////
public boolean computeScreenshots(int mode, boolean batch) throws IOException {
public boolean computeScreenshots(int mode, boolean batch, boolean ShowProgressMonitor) throws IOException {
if (mode == 0)
return true;
......@@ -673,7 +675,7 @@ public class Index {
System.out.println(name + ".ocr");
ProgressMonitor progressMonitor = null;
if (!batch) {
if (!batch && ShowProgressMonitor) {
// show progress
String text = mode == ScriptCreator.THUMBNAILS ? "Computing thumbnails" : "Computing screenshots";
progressMonitor = new ProgressMonitor(TTT.getRootComponent(), text, null, 0, index.size());
......@@ -747,38 +749,13 @@ public class Index {
Image screenshot = recording.graphicsContext.getScreenshotWithoutAnnotations();
// set thumbnail
if ((mode & ScriptCreator.THUMBNAILS) != 0) {
// // new
// if (true) {
if ((mode & ScriptCreator.THUMBNAILS) != 0) {
// faster image scaling
Image thumbnail = ScriptCreator.getScaledInstance(screenshot, recording.prefs.framebufferWidth
/ thumbnail_scale_factor, recording.prefs.framebufferHeight / thumbnail_scale_factor);
indexEntry.setThumbnail(thumbnail);
// }
//
// // old
// else {
// // old version with slower image scaling
// // TODO: remove after testing new version (see above)
// Image thumbnail = screenshot.getScaledInstance(recording.prefs.framebufferWidth
// / thumbnail_scale_factor, recording.prefs.framebufferHeight / thumbnail_scale_factor,
// Image.SCALE_SMOOTH);
//
// // create new image and paint thumbnail on it
// // approx. 50% slower, but only 5% of memory usage
// // TODO: check if still valid with new image scaler used above
// BufferedImage bimage = new BufferedImage(thumbnail.getWidth(null), thumbnail.getHeight(null),
// BufferedImage.TYPE_INT_RGB);
// // Copy image to buffered image
// Graphics g = bimage.createGraphics();
// // Paint the image onto the buffered image
// g.drawImage(thumbnail, 0, 0, null);
// g.dispose();
// indexEntry.setThumbnail(bimage);
// }
}
// write input for Optical Character Recognition
......
......@@ -1307,76 +1307,17 @@ public class PostProcessorPanel extends GradientPanel {
modified = true;
}
// create screenshot related data
try {
// get combined mode
int mode = 0;
if (thumbnailsCheckBox.isSelected()) {
mode |= ScriptCreator.THUMBNAILS;
modified = true;
}
if (htmlCheckBox.isSelected())
mode |= ScriptCreator.HTML_SCRIPT;
if (pdfCheckBox.isSelected())
mode |= ScriptCreator.PDF_SCRIPT;
if (ocrCheckBox.isSelected())
mode |= ScriptCreator.OCR_OPTIMIZED;
// compute everything specified by mode
recording.createScript(mode, batch);
} catch (Exception e) {
TTT.showMessage("Script/screenshot creation failed: " + e);
e.printStackTrace();
}
createScreenShots();
// now store recording with thumbnails
// NOTE: store thumbnails now, because flash generation may fail due to insufficient memory
// NOTE: store Thumbnails now, because flash generation may fail due to insufficient memory
storeRecordingIfNeeded();
//convert audio file
try {
if (mp3CheckBox.isSelected()) {
LameEncoder.convertAudioFile(recording.getExistingFileBySuffix(new String[] {"wav","mp2"}), recording.getFileBySuffix("mp3"), batch);
}
} catch (Exception e) {
TTT.showMessage("MP3 creation failed: " + e);
e.printStackTrace();
}
// create flash movie
try {
if (flashCheckBox.isSelected()) {
if (!recording.thumbnailsAvailable())
modified = true; // thumbnails will be created by flash generator
recording.createFlash(batch);
}
} catch (Exception e) {
TTT.showMessage("Flash creation failed: " + e);
e.printStackTrace();
}
//create mp4 podcast
try {
if (mp4CheckBox.isSelected()) {
PodcastCreator.createPodcast(recording, batch);
}
} catch (Exception e) {
TTT.showMessage("MP4 creation failed: " + e);
e.printStackTrace();
}
//create camVid
try {
if (camCheckBox.isSelected()) {
ttt.video.VideoCreator newVideo = new ttt.video.VideoCreator();
newVideo.create(recording.getExistingFileBySuffix("bjpg").getPath());
}
} catch (Exception e) {
TTT.showMessage("CamVid creation failed: " + e);
e.printStackTrace();
}
convertAudio();
createFlash();
createMp4();
createWebCamVideo();
// update status fields
updateStatusFields();
......@@ -1386,6 +1327,8 @@ public class PostProcessorPanel extends GradientPanel {
createButton.setForeground(Color.BLACK);
importSearchbaseButton.setForeground(Color.BLUE);
}
});
if (batch)
thread.run();
......@@ -1393,7 +1336,84 @@ public class PostProcessorPanel extends GradientPanel {
thread.start();
}// GEN-LAST:event_createButtonActionPerformed
private void createWebCamVideo() {
//create camVid
try {
if (camCheckBox.isSelected()) {
ttt.video.VideoCreator newVideo = new ttt.video.VideoCreator();
newVideo.create(recording.getExistingFileBySuffix("bjpg").getPath());
}
} catch (Exception e) {
TTT.showMessage("CamVid creation failed: " + e);
e.printStackTrace();
}
}
private void createMp4() {
//create mp4 podcast
try {
if (mp4CheckBox.isSelected()) {
PodcastCreator.createPodcast(recording, batch);
}
} catch (Exception e) {
TTT.showMessage("MP4 creation failed: " + e);
e.printStackTrace();
}
}
public void createFlash(){
// create flash movie
try {
if (flashCheckBox.isSelected()) {
if (!recording.thumbnailsAvailable())
modified = true; // thumbnails will be created by flash generator
recording.createFlash(batch);
}
} catch (Exception e) {
TTT.showMessage("Flash creation failed: " + e);
e.printStackTrace();
}
}
public void convertAudio(){
//convert audio file
try {
if (mp3CheckBox.isSelected()) {
LameEncoder.convertAudioFile(recording.getExistingFileBySuffix(new String[] {"wav","mp2"}), recording.getFileBySuffix("mp3"), batch);
}
} catch (Exception e) {
TTT.showMessage("MP3 creation failed: " + e);
e.printStackTrace();
}
}
public void createScreenShots(){
// create screenshot related data
try {
// get combined mode
int mode = 0;
if (thumbnailsCheckBox.isSelected()) {
mode |= ScriptCreator.THUMBNAILS;
modified = true;
}
if (htmlCheckBox.isSelected())
mode |= ScriptCreator.HTML_SCRIPT;
if (pdfCheckBox.isSelected())
mode |= ScriptCreator.PDF_SCRIPT;
if (ocrCheckBox.isSelected())
mode |= ScriptCreator.OCR_OPTIMIZED;
// compute everything specified by mode
recording.createScript(mode, batch);
} catch (Exception e) {
// TTT.showMessage("Script/screenshot creation failed: " + e);
e.printStackTrace();
}
}
private void searchbaseActionPerformed(java.awt.event.ActionEvent event) {
// import searchbase file
// show file dialog
......
......@@ -974,13 +974,18 @@ public void setExtensions(ArrayList<byte[]> ext){
// mode can be a & combination of HTML_SCRIPT, OCR_OPTIMIZED, THUMBNAILS (of class ScriptCreator)
public boolean createScript(final int mode) throws IOException {
return index.computeScreenshots(mode, false);
return index.computeScreenshots(mode, false, true);
}
public boolean createScript(final int mode, boolean batch) throws IOException {
return index.computeScreenshots(mode, batch);
return index.computeScreenshots(mode, batch, true);
}
public boolean createScript(final int mode, boolean batch, boolean ShowProgressMonitor) throws IOException {
return index.computeScreenshots(mode, batch, ShowProgressMonitor);
}
/*******************************************************************************************************************
* TTT 2 Flash
******************************************************************************************************************/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment