From 627a85bd69b4627005575c35ea8e082b9cbd1445 Mon Sep 17 00:00:00 2001 From: tentacle Date: Sat, 4 Mar 2006 15:26:09 +0000 Subject: [PATCH] fixed fextracker normalization added copyright notice Originally committed to SVN as r196. --- FexTrackerSource/FexGenericFilter.cpp | 12 ++- .../FexGenericFilter_BaseFloatImage.cpp | 3 + .../FexGenericFilter_BaseFloatImageApply.h | 3 + .../FexGenericFilter_Contribution.h | 3 + .../FexGenericFilter_FexImage.cpp | 3 + .../FexGenericFilter_FexImageApply.h | 3 + .../FexGenericFilter_FilteringCore.h | 3 + FexTrackerSource/FexGenericFilter_Include.h | 3 + FexTrackerSource/FexGenericFilter_StaticFor.h | 3 + FexTrackerSource/FexImgPyramid.cpp | 14 +-- FexTrackerSource/FexImgPyramid.h | 3 + FexTrackerSource/FexMovement.cpp | 21 +---- FexTrackerSource/FexMovement.h | 4 +- FexTrackerSource/FexTracker.cpp | 11 +-- FexTrackerSource/FexTracker.h | 3 + FexTrackerSource/FexTrackerMovement.cpp | 94 +------------------ FexTrackerSource/FexTrackingFeature.cpp | 3 + FexTrackerSource/FexTrackingFeature.h | 3 + FexTrackerSource/StdAfx.cpp | 3 + FexTrackerSource/StdAfx.h | 7 ++ FexTrackerSource/tenlist.h | 3 + 21 files changed, 79 insertions(+), 126 deletions(-) diff --git a/FexTrackerSource/FexGenericFilter.cpp b/FexTrackerSource/FexGenericFilter.cpp index 5ca377cb1..5ac8c8306 100644 --- a/FexTrackerSource/FexGenericFilter.cpp +++ b/FexTrackerSource/FexGenericFilter.cpp @@ -1,3 +1,6 @@ +// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + #include #include "FexGenericFilter_Include.h" @@ -21,19 +24,24 @@ f(x) = e^(-x^2 / t) width: SOLVE(0.1 = f(x), x, Real) x = - sqrt(t LN(10) ? x = sqrt(t LN(10) +x = - 1.517427129·sqrt t ? x = 1.517427129·sqrt t +x = - sqrt(2*s*s* LN(10)) ? x = sqrt(2*s*s* LN(10)) +x = - 2.145966026·s ? x = 2.145966026·s sum: Integral from -sqrt(t LN(10) to sqrt(t LN(10) of f(x) dx 1.715955662·sqrt(t) +2.426727768·s */ FexFilter_Gauss::FexFilter_Gauss( double sigma ) { Sigma = sigma; TwoSigmaSq = 2*sigma*sigma; - Width = sqrt( TwoSigmaSq*log(10) ); - Normalize = 1.0 / (1.715955662 * sqrt( TwoSigmaSq )); + Width = 2.145966026 * sigma; + Normalize = 1.0 / (2.426727768 * sigma); + Normalize *= 1.0 + 0.1 / Width; //its the 0.1 we left out } FexFilter_Gauss::~FexFilter_Gauss() { diff --git a/FexTrackerSource/FexGenericFilter_BaseFloatImage.cpp b/FexTrackerSource/FexGenericFilter_BaseFloatImage.cpp index edd4caabc..df8cef3f1 100644 --- a/FexTrackerSource/FexGenericFilter_BaseFloatImage.cpp +++ b/FexTrackerSource/FexGenericFilter_BaseFloatImage.cpp @@ -1,3 +1,6 @@ +// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + #include "stdio.h" #include "math.h" #include "memory.h" diff --git a/FexTrackerSource/FexGenericFilter_BaseFloatImageApply.h b/FexTrackerSource/FexGenericFilter_BaseFloatImageApply.h index aff908fc9..17809b0f8 100644 --- a/FexTrackerSource/FexGenericFilter_BaseFloatImageApply.h +++ b/FexTrackerSource/FexGenericFilter_BaseFloatImageApply.h @@ -1,3 +1,6 @@ +// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + { #define PixelType float #define PixelMin 0 diff --git a/FexTrackerSource/FexGenericFilter_Contribution.h b/FexTrackerSource/FexGenericFilter_Contribution.h index 13e8a4dcb..77ad0210e 100644 --- a/FexTrackerSource/FexGenericFilter_Contribution.h +++ b/FexTrackerSource/FexGenericFilter_Contribution.h @@ -1,3 +1,6 @@ +// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + { double width = FilterWidth; #ifdef CONTRIB_XSCALE diff --git a/FexTrackerSource/FexGenericFilter_FexImage.cpp b/FexTrackerSource/FexGenericFilter_FexImage.cpp index 1c7489d13..ed36a7ea4 100644 --- a/FexTrackerSource/FexGenericFilter_FexImage.cpp +++ b/FexTrackerSource/FexGenericFilter_FexImage.cpp @@ -1,3 +1,6 @@ +// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + #include "stdafx.h" #include "FexSystem.h" #include "ext\imdebug.h" diff --git a/FexTrackerSource/FexGenericFilter_FexImageApply.h b/FexTrackerSource/FexGenericFilter_FexImageApply.h index 0f7b515b4..721828ca5 100644 --- a/FexTrackerSource/FexGenericFilter_FexImageApply.h +++ b/FexTrackerSource/FexGenericFilter_FexImageApply.h @@ -1,3 +1,6 @@ +// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + { #define PixelType BYTE #define PixelMin 0 diff --git a/FexTrackerSource/FexGenericFilter_FilteringCore.h b/FexTrackerSource/FexGenericFilter_FilteringCore.h index 28cce3174..fbdebfece 100644 --- a/FexTrackerSource/FexGenericFilter_FilteringCore.h +++ b/FexTrackerSource/FexGenericFilter_FilteringCore.h @@ -1,3 +1,6 @@ +// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + { FexFilterContribution* Contrib = new FexFilterContribution[ ImageOutSX ]; double XScale = (double)ImageOutSX / (double) ImageInSX; diff --git a/FexTrackerSource/FexGenericFilter_Include.h b/FexTrackerSource/FexGenericFilter_Include.h index acb106b7f..61155ad3c 100644 --- a/FexTrackerSource/FexGenericFilter_Include.h +++ b/FexTrackerSource/FexGenericFilter_Include.h @@ -1,3 +1,6 @@ +// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + class FexFilter { public: FexFilter(); diff --git a/FexTrackerSource/FexGenericFilter_StaticFor.h b/FexTrackerSource/FexGenericFilter_StaticFor.h index db63cd034..208f1938c 100644 --- a/FexTrackerSource/FexGenericFilter_StaticFor.h +++ b/FexTrackerSource/FexGenericFilter_StaticFor.h @@ -1,3 +1,6 @@ +// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + #if ImagePlanes==1 #define STATIC_FOR {DOFOR(0)} #elif ImagePlanes==3 diff --git a/FexTrackerSource/FexImgPyramid.cpp b/FexTrackerSource/FexImgPyramid.cpp index 19b13a156..7d2830a93 100644 --- a/FexTrackerSource/FexImgPyramid.cpp +++ b/FexTrackerSource/FexImgPyramid.cpp @@ -1,3 +1,6 @@ +// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + // FexImgPyramid.cpp: implementation of the FexImgPyramid class. // ////////////////////////////////////////////////////////////////////// @@ -15,6 +18,11 @@ void BaseFloatImage_LanczosRescale( float* in, int inSx, int inSy, float* out, i ////////////////////////////////////////////////////////////////////// +//turn off image debugging +#ifndef imdebug +#define imdebug // +#endif + FexImgPyramidLevel::FexImgPyramidLevel( int isx, int isy ) { @@ -34,12 +42,6 @@ FexImgPyramidLevel::~FexImgPyramidLevel() void FexImgPyramidLevel::Fill( float* iImg, float DetectSmoothSigma ) { -/* - for( int y=0;y'z' ) - Name[i] = '_'; - } - wcscat( Name, L".fexmove" ); - return Name; -} -*/ FEXTRACKER_API void DeleteMovement( FexMovement* delme ) { delete delme; diff --git a/FexTrackerSource/FexMovement.h b/FexTrackerSource/FexMovement.h index 897300d3b..a0a9c7221 100644 --- a/FexTrackerSource/FexMovement.h +++ b/FexTrackerSource/FexMovement.h @@ -1,3 +1,6 @@ +// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + // FexMovement.h: interface for the FexMovement class. // ////////////////////////////////////////////////////////////////////// @@ -32,6 +35,5 @@ FEXTRACKER_API FexMovement* CreateMovement(); FEXTRACKER_API void LoadMovement( FexMovement* me, const unsigned short* Filename ); FEXTRACKER_API void SaveMovement( FexMovement* me, const unsigned short* Filename ); FEXTRACKER_API void DeleteMovement( FexMovement* delme ); -//WCHAR* FEXTRACKER_API GetUniqueName(); #endif // !defined(AFX_FEXMOVEMENT_H__63D8ADD8_4EA1_4C56_8D6F_7B587A1A61A4__INCLUDED_) diff --git a/FexTrackerSource/FexTracker.cpp b/FexTrackerSource/FexTracker.cpp index 8c45e3364..b6b7857c7 100644 --- a/FexTrackerSource/FexTracker.cpp +++ b/FexTrackerSource/FexTracker.cpp @@ -1,9 +1,11 @@ +// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + // FexTracker.cpp : Defines the entry point for the DLL application. // #include "StdAfx.h" #include "stdio.h" -//#include "mmsystem.h" FexTracker::FexTracker( int sx, int sy, int inFeatures ) { @@ -45,10 +47,6 @@ FexTracker::FexTracker( int sx, int sy, int inFeatures ) PyramidMaxLevels = (int) (val + 0.99); PyramidSubsampling = 8; } -/* - PyramidMaxLevels = 2; - PyramidSubsampling = 2; -*/ } FexTracker::~FexTracker() { @@ -58,7 +56,6 @@ FexTracker::~FexTracker() void FexTracker::ProcessImage( float *Img, bool bFirst ) { -//DWORD t = timeGetTime(); if( bFirst || !CurImg ) { CurFrame = 0; @@ -80,8 +77,6 @@ void FexTracker::ProcessImage( float *Img, bool bFirst ) NextImg = 0; } CurFrame++; -//DWORD t2 = timeGetTime(); -//printf( "ProcessImage: %d ms\n", (t2-t) ); } void FexTracker::ProcessingDone() diff --git a/FexTrackerSource/FexTracker.h b/FexTrackerSource/FexTracker.h index 7e82b238b..943107334 100644 --- a/FexTrackerSource/FexTracker.h +++ b/FexTrackerSource/FexTracker.h @@ -1,3 +1,6 @@ +// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + // The following ifdef block is the standard way of creating macros which make exporting // from a DLL simpler. All files within this DLL are compiled with the FEXTRACKER_EXPORTS diff --git a/FexTrackerSource/FexTrackerMovement.cpp b/FexTrackerSource/FexTrackerMovement.cpp index 82ab8d98a..0ab8a760c 100644 --- a/FexTrackerSource/FexTrackerMovement.cpp +++ b/FexTrackerSource/FexTrackerMovement.cpp @@ -1,9 +1,11 @@ +// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle) +// All rights reserved but the aegisub project is allowed to use it. + // FexTrackerMovement.cpp // #include "StdAfx.h" #include "stdio.h" -//#include "mmsystem.h" @@ -28,97 +30,7 @@ void FexTracker::InfluenceFeatures( int Frame, float x, float y, float off ) } } -/* -void LineTracing( haAssLine *c, vec2& TracePos, vec2& TraceScale, int Frame, vec2 InScreenPlace ) -{ - TracePos = vec2(0,0); - TraceScale = vec2(0,0); - vec2 Sum1Pos = vec2(0,0); - vec2 Sum2Pos = vec2(0,0); - float TraceScaleV=0; - - float wsum = 0; - - for( int i=0;iFeatureIdList.GetSize();i++ ) - { - tenFeatureLink l = c->FeatureIdList[i]; - tenFeature f = Trace_GetFeatureByID( l.id, Frame ); - if( f.id < 0 || l.weight<0.01 ) - continue; - Sum1Pos += vec2( - (f.x)/float(ncols)*float(AssRes[0]), - (f.y)/float(nrows)*float(AssRes[1]) - )*l.weight; - Sum2Pos += vec2( - (l.sub.x)/float(ncols)*float(AssRes[0]), - (l.sub.y)/float(nrows)*float(AssRes[1]) - )*l.weight; - wsum += l.weight; - } - if( wsum>0.01 ) - { - Sum1Pos /= wsum; - Sum2Pos /= wsum; - TracePos = Sum1Pos - Sum2Pos; - - wsum = 0; - CArray DistList; - CArray WeightList; - -//now we know weighted mid point, gen vectors from points to mid - for( int i=0;iFeatureIdList.GetSize();i++ ) - { - tenFeatureLink l = c->FeatureIdList[i]; - tenFeature f = Trace_GetFeatureByID( l.id, Frame ); - if( f.id < 0 || l.weight<0.01 ) - continue; - vec2 mid = vec2( - (f.x)/float(ncols)*float(AssRes[0]), - (f.y)/float(nrows)*float(AssRes[1]) - ); - vec2 midToMe = mid - Sum1Pos; - vec2 stdMidToMe = vec2( - (l.sub.x)/float(ncols)*float(AssRes[0]), - (l.sub.y)/float(nrows)*float(AssRes[1]) - ) - Sum2Pos; - - float stdlen = sqrtf( stdMidToMe.x*stdMidToMe.x + stdMidToMe.y*stdMidToMe.y ); - if( stdlen < 3 ) - {//too much error amplification.skip - continue; - } - - float len = sqrtf( midToMe.x*midToMe.x + midToMe.y*midToMe.y ); - float scale = len/stdlen; - // TRACE( "%f\n", scale ); - float addme = scale*l.weight; - TraceScaleV += addme; - DistList.Add( scale ); - WeightList.Add( l.weight ); - wsum += l.weight; - } - TraceScaleV /= wsum; - - float TraceScaleV2=0; - for( i=0;i