mirror of
https://github.com/unclshura/splitter.git
synced 2026-06-22 00:22:01 +00:00
oprimised camera controiller parameters. Looks good now.
This commit is contained in:
parent
9d72ede1d2
commit
1d337cf5bf
@ -17,15 +17,14 @@ public sealed class CameraController
|
||||
private readonly int _cropWidth;
|
||||
private readonly int _cropHeight;
|
||||
private readonly KalmanTracker _kalman;
|
||||
private readonly int _lostFreezeFrames;
|
||||
private readonly float _cameraEasing;
|
||||
private int _dropoutCounter;
|
||||
|
||||
// --- Dropout tolerance ---
|
||||
private const int DropoutToleranceFrames = 20;
|
||||
private int _dropoutCounter;
|
||||
private const float EmaFactor = 0.65f; // smoother but responsive
|
||||
private const float CameraEasing = 0.03f; // stronger follow-through
|
||||
private const int LostFreezeFrames = 60; // 2 seconds at 30 FPS
|
||||
|
||||
// --- NEW: EMA smoothing ---
|
||||
private const float EmaFactor = 0.85f; // 0.85 = smooth but responsive
|
||||
|
||||
private int _lostFrames;
|
||||
private Point2f _cameraCenter;
|
||||
@ -40,17 +39,14 @@ public sealed class CameraController
|
||||
int videoHeight,
|
||||
int cropWidth,
|
||||
int cropHeight,
|
||||
KalmanTracker kalman,
|
||||
int lostFreezeFrames,
|
||||
float cameraEasing)
|
||||
KalmanTracker kalman
|
||||
)
|
||||
{
|
||||
_videoWidth = videoWidth;
|
||||
_videoHeight = videoHeight;
|
||||
_cropWidth = cropWidth;
|
||||
_cropHeight = cropHeight;
|
||||
_kalman = kalman;
|
||||
_lostFreezeFrames = lostFreezeFrames;
|
||||
_cameraEasing = cameraEasing;
|
||||
|
||||
_cameraCenter = new Point2f(videoWidth / 2f, videoHeight / 2f);
|
||||
_state = TrackState.Tracking;
|
||||
@ -100,7 +96,7 @@ public sealed class CameraController
|
||||
{
|
||||
_lostFrames++;
|
||||
|
||||
if (_lostFrames <= _lostFreezeFrames)
|
||||
if (_lostFrames <= LostFreezeFrames)
|
||||
{
|
||||
_state = TrackState.LostFreeze;
|
||||
objectCenter = null;
|
||||
@ -132,16 +128,10 @@ public sealed class CameraController
|
||||
smoothedCenter.Y * (1 - EmaFactor) + _cameraCenter.Y * EmaFactor
|
||||
);
|
||||
|
||||
// fast easing
|
||||
float fastEasing = 0.015f;
|
||||
_cameraCenter = new Point2f(
|
||||
_cameraCenter.X + (smoothedCenter.X - _cameraCenter.X) * fastEasing,
|
||||
_cameraCenter.Y + (smoothedCenter.Y - _cameraCenter.Y) * fastEasing);
|
||||
_cameraCenter.X + (smoothedCenter.X - _cameraCenter.X) * CameraEasing,
|
||||
_cameraCenter.Y + (smoothedCenter.Y - _cameraCenter.Y) * CameraEasing);
|
||||
|
||||
// configurable easing
|
||||
_cameraCenter = new Point2f(
|
||||
_cameraCenter.X + (smoothedCenter.X - _cameraCenter.X) * _cameraEasing,
|
||||
_cameraCenter.Y + (smoothedCenter.Y - _cameraCenter.Y) * _cameraEasing);
|
||||
}
|
||||
else if (_state == TrackState.LostFreeze)
|
||||
{
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
{
|
||||
"profiles": {
|
||||
"splitter": {
|
||||
"WSL": {
|
||||
"commandName": "WSL2",
|
||||
"distributionName": ""
|
||||
},
|
||||
"Prod": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "\"C:\\Users\\uncls\\Pictures\\2026\\2026 - Secret Rule\\20260426_212004.mp4\" \"C:\\Users\\uncls\\Pictures\\2026\\2026 - Secret Rule\\Shorts\" --crop --detect=body"
|
||||
},
|
||||
"Debug": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "\"C:\\Users\\uncls\\Pictures\\2026\\2026 - Secret Rule\\20260426_212004.mp4\" \"C:\\Users\\uncls\\Pictures\\2026\\2026 - Secret Rule\\Shorts\" --crop --detect=body --debug --text"
|
||||
}
|
||||
|
||||
@ -12,9 +12,6 @@ public class TrackingSplitter(
|
||||
Action<double /*percent*/, TimeSpan /*duration*/, double /*fps*/> drawProgress
|
||||
) : LoggingBase(log, drawProgress)
|
||||
{
|
||||
private const int LostFreezeFrames = 60; // 2 seconds at 30 FPS
|
||||
private const float CameraEasing = 0.03f;
|
||||
|
||||
public async Task TrackAndExtract(
|
||||
string srcFileName,
|
||||
string destFileName,
|
||||
@ -70,9 +67,8 @@ public class TrackingSplitter(
|
||||
videoHeight,
|
||||
originalCropWidth,
|
||||
originalCropHeight,
|
||||
kalman,
|
||||
LostFreezeFrames,
|
||||
CameraEasing);
|
||||
kalman
|
||||
);
|
||||
|
||||
var startTime = DateTime.UtcNow;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user