public void CaptureFrames()
{
Time pos;
LongoMatch.Core.Common.Image frame;
List<CameraConfig> cameras;
bool quit = false;
int i = 0;
int j = 0;
System.IO.Directory.CreateDirectory (outputDir);
Log.Debug ("Start frames series capture with interval: " + interval);
Log.Debug ("Total frames to be captured: " + totalFrames);
if (evt.CamerasConfig.Count == 0 || fileSet.Count == 1) {
cameras = new List<CameraConfig> { new CameraConfig (0) };
} else {
cameras = evt.CamerasConfig;
}
foreach (CameraConfig cameraConfig in cameras) {
MediaFile file;
if (quit) {
break;
}
Log.Debug ("Start frames series capture for angle " + cameraConfig.Index);
try {
file = fileSet [cameraConfig.Index];
} catch (Exception ex) {
Log.Exception (ex);
Log.Error (string.Format ("Camera index {0} not found in fileset", cameraConfig.Index));
continue;
}
capturer.Open (file.FilePath);
pos = new Time { MSeconds = start.MSeconds };
if (Progress != null) {
Application.Invoke (delegate {
Progress (i, totalFrames, null);
});
}
j = 0;
while (pos <= stop) {
Log.Debug ("Capturing fame " + j);
if (!cancel) {
frame = capturer.GetFrame (pos + file.Offset, true);
if (frame != null) {
string path = String.Format ("{0}_angle{1}_{2}.png", seriesName, cameraConfig.Index, j);
frame.Save (System.IO.Path.Combine (outputDir, path));
frame.ScaleInplace (THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT);
}
if (Progress != null) {
Application.Invoke (delegate {
Progress (i + 1, totalFrames, frame);
});
}
pos.MSeconds += (int)interval;
i++;
j++;
} else {
Log.Debug ("Capture cancelled, deleting output directory");
System.IO.Directory.Delete (outputDir, true);
cancel = false;
quit = true;
break;
}
}
}
capturer.Dispose ();
}