Screenshots during a simulation.
CCameraShot takes screenshots during a simulation. This can be either a single screenshot or a series at given framerate to create a video. The screenshots are saved to file.
To create a video, ffmpeg can be used, for example using the following command:
ffmpeg -i shot%d.png -r 30 -c:v libx264 -x264opts crf=20 video.avi
- Author
- Karl-Johan Reite
Example configuration excerpt
<Lib
LibName = "fhsim_base"
SimObject = "Camera/Shot"
Name = "camshot"
Filename = "shot1.png"
Start = "0"
Video = "1"
Stop = "260"
FrameRateControl = "FPS"
FrameRateValue = "30"
Refinement = "1"
Path = ""
/>
Name | Width | Description |
Pos1 | 3 | The position of the first target. |
PosN1 | 3 | The position of the N'th target. |
Output Ports
No output ports available.
Configuration parameters
Name | Width | Description |
Filename | 1 | The base name of the file, e.g. shot.png. This will be expanded to shotN.png, where N is the frame index. |
Start | 1 | The time (in seconds from simulation start) to take the first shot. |
Video | 1 | A bool telling if a series or only a single shot should be taken. |
Stop | 1 | The time to stop taking screenshots. |
FrameRateControl | 1 | Should be either FPS (Frames Per Second simulationtime) or SPF (Steps Per Frame). Default is FPS. |
FrameRateValue | 1 | Framrate, in frames per second. Default is 24. |
Refinement | 1 | The screenshot is created by tiling this number of screenshots vertical and horizontal, increasing the reolution of the screenshot. |
Path | 1 | The path to the screenshots. If empty (the default), the screenshots will be placed in screenshots/<time_string>. |
Initial conditions
This SimObject contains no initial conditions.
Full example file
<Contents>
<OBJECTS>
<Lib
LibName = "fhsim_base"
SimObject = "Camera/Controller2"
Name = "CAM"
NumInput = "4"
Time = "0,1,2,3"
UseDegrees = "1"
Interpolate ="1"
/>
<Lib
LibName = "base"
SimObject = "Body/Mass"
Name = "M1"
Scale = "1"
Mass = "1"
Material = "Simple/Red"
/>
<Lib
LibName = "base"
SimObject = "Body/Mass"
Name = "M2"
Scale = "1"
Mass = "1"
Material = "Simple/Green"
/>
<Lib
LibName = "base"
SimObject = "Body/Mass"
Name = "M3"
Scale = "1"
Mass = "1"
/>
<Lib
LibName = "base"
SimObject = "Body/Mass"
Name = "M4"
Scale = "1"
Mass = "1"
Material = "Simple/Black"
/>
<Lib
LibName = "fhsim_base"
SimObject = "Camera/Shot"
Name = "camshot"
Filename = "shot.png"
Start = "0"
Video = "1"
Stop = "5"
FrameRateControl = "FPS"
FrameRateValue = "30"
Refinement = "1"
Path = ""
/>
<Lib
LibName = "base"
SimObject = "DefaultEnvironment"
Name = "Env"
Seadepth = "500"
Density = "1000"
CurrentVelocity = "0,0,0"
/>
</OBJECTS>
<INTERCONNECTIONS>
<Connection
CAM.Position1 = "-10,0,0"
CAM.Position2 = "0,-10,0"
CAM.Position3 = "10,0,0"
CAM.Position4 = "0,10,0"
CAM.Pitch1 = "0"
CAM.Pitch2 = "0"
CAM.Pitch3 = "0"
CAM.Pitch4 = "0"
CAM.Yaw1 = "0"
CAM.Yaw2 = "90"
CAM.Yaw3 = "180"
CAM.Yaw4 = "270"
M1.Force = "0,0,0"
M2.Force = "0,0,0"
M3.Force = "0,0,0"
M4.Force = "0,0,0"
/>
</INTERCONNECTIONS>
<INITIALIZATION>
<InitialCondition
M1.Pos = "0,0,0"
M2.Pos = "10,-20,0"
M3.Pos = "20,-10,0"
M4.Pos = "-10,20,0"
M1.Vel = "0,0,0"
M2.Vel = "0,0,0"
M3.Vel = "0,0,0"
M4.Vel = "0,0,0"
/>
</INITIALIZATION>
<INTEGRATION>
<Engine
IntegratorMethod = "2"
NumCores = "1"
TOutput = "0,5"
LogStates = "1"
stepsize = "0"
HMax = "0.002"
HMin = "0.00000001"
AbsTol = "1e-3"
RelTol = "1e-3"
UseRSSNormInsteadOfInfNorm = "0"
FileOutput = "objects:all"
/>
</INTEGRATION>
</Contents>
This SimObject is referred to as Camera/Shot