Commit fbdd80c4 authored by BRUNEAU Julien's avatar BRUNEAU Julien
Browse files

+ Fix recording animation

parent e2e8b54d
......@@ -38,6 +38,8 @@ public class CamRecorder : MonoBehaviour
public float timeToStop = 60; // Time when recording shall stop
public int framerate = 25; // Framerate at which screenshot are taken
public string saveDir = "Img/capture/"; // Directory where to save all the data
private bool runOncePerFrame = false;
#endregion
/// <summary>
......@@ -67,41 +69,54 @@ public class CamRecorder : MonoBehaviour
imageIncrement = 0;
}
private void Update()
{
runOncePerFrame = true;
}
/// <summary>
/// Create screenshot during recording time
/// </summary>
protected virtual void LateUpdate()
{
if (record && !(Time.timeSinceLevelLoad < timeToStart))
{
if (Time.captureFramerate == 0)
Time.captureFramerate = framerate;
if (Time.timeSinceLevelLoad > timeToStop)
{
record = false;
Time.captureFramerate = 0;
Debug.Log("record stopped !");
Application.Quit();
return;
}
if (Time.timeScale==0)
return;
//ScreenCapture.CaptureScreenshot(saveDir + "Images/" + imageIncrement.ToString("D" + 4) + ".png");
this.GetComponent<FiltersControl>().Save(imageIncrement.ToString("D" + 4) + ".png",ConfigReader.recordingWidth,ConfigReader.recordingHeight, saveDir);
// Record data need for deep learning
foreach (DeepRecorder rec in gameObject.GetComponentsInChildren<DeepRecorder>())
{
rec.RecordDeepData(imageIncrement);
}
imageIncrement++;
} else
Time.captureFramerate = 0;
//protected virtual void LateUpdate()
private void OnGUI()
//private void OnPostRender()
{
if (runOncePerFrame)
{
Debug.Log(Time.fixedTime);
if (record && !(Time.timeSinceLevelLoad < timeToStart))
{
if (Time.captureFramerate == 0)
Time.captureFramerate = framerate;
if (Time.timeSinceLevelLoad > timeToStop)
{
record = false;
Time.captureFramerate = 0;
Debug.Log("record stopped !");
Application.Quit();
return;
}
if (Time.timeScale == 0)
return;
//ScreenCapture.CaptureScreenshot(saveDir + "/" + imageIncrement.ToString("D" + 4) + ".png");
this.GetComponent<FiltersControl>().Save(imageIncrement.ToString("D" + 4) + ".png", ConfigReader.recordingWidth, ConfigReader.recordingHeight, saveDir);
// Record data need for deep learning
foreach (DeepRecorder rec in gameObject.GetComponentsInChildren<DeepRecorder>())
{
rec.RecordDeepData(imageIncrement);
}
imageIncrement++;
}
else
Time.captureFramerate = 0;
runOncePerFrame = false;
}
}
}
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