summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/tracking/src/matlab/calcPyrLKTrack.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/tracking/src/matlab/calcPyrLKTrack.m')
-rwxr-xr-xSD-VBS/benchmarks/tracking/src/matlab/calcPyrLKTrack.m108
1 files changed, 0 insertions, 108 deletions
diff --git a/SD-VBS/benchmarks/tracking/src/matlab/calcPyrLKTrack.m b/SD-VBS/benchmarks/tracking/src/matlab/calcPyrLKTrack.m
deleted file mode 100755
index c965c2b..0000000
--- a/SD-VBS/benchmarks/tracking/src/matlab/calcPyrLKTrack.m
+++ /dev/null
@@ -1,108 +0,0 @@
1function [newFPnt, valid] = calcPyrLKTrack(iP, iDxP, iDyP, jP, fPnt, nFeatures, winSize, accuracy_th, max_iter)
2
3cellDims = size(iP);
4GOOD_FEATURE_LAMBDA_TH = accuracy_th;
5
6for i=1:(cellDims(1))
7 curImgDims = size(iP{i});
8 imgDims(i,1)= curImgDims(1);
9 imgDims(i,2)= curImgDims(2);
10
11end
12
13pLevel = cellDims(1);
14
15rate=[1, 0.5, 0.25, 0.125, 0.0625, 0.03125];
16winSizeSq=4*winSize*winSize;
17iPatch=cell(1, winSizeSq);
18jPatch=cell(1, winSizeSq);
19iDxPatch=cell(1,winSizeSq);
20iDyPatch=cell(1,winSizeSq);
21
22valid(1:nFeatures) = 1;
23newFPnt = zeros(2,nFeatures);
24
25for i=1:nFeatures
26
27 dX=0;
28 dY=0;
29
30%% x is rows here and y is cols
31
32 x=fPnt(1,i)*rate(pLevel+1); %half size of real level
33 y=fPnt(2,i)*rate(pLevel+1);
34
35 for level=pLevel:-1:1
36
37 x = x+x;
38 y = y+y;
39 dX = dX+dX;
40 dY = dY+dY;
41 imgSize(1)=imgDims(level,1); %y,x
42 imgSize(2)=imgDims(level,2); %y,x
43
44 c_xx = 0;
45 c_xy = 0;
46 c_yy = 0;
47
48 %when feature goes out to the boundary.
49
50 if ((x-winSize)<1 || (y-winSize)<1 || (y+winSize+1)>imgSize(1) || (x+winSize+1)>imgSize(2))
51 %winSize+1due to interpolation
52 %error or skip the level??
53 valid(i) = 0;
54 break;
55 end
56
57
58 iPatch = getInterpolatePatch(iP{level}, imgSize(1), imgSize(2), x, y, winSize);
59 iDxPatch = getInterpolatePatch(iDxP{level}, imgSize(1), imgSize(2), x, y, winSize);
60 iDyPatch = getInterpolatePatch(iDyP{level}, imgSize(1), imgSize(2), x, y, winSize);
61
62 for idx=1:winSizeSq
63 c_xx = c_xx + iDxPatch(idx) * iDxPatch(idx);
64 c_xy = c_xy + iDxPatch(idx) * iDyPatch(idx);
65 c_yy = c_yy + iDyPatch(idx) * iDyPatch(idx);
66 end
67
68 c_det = c_xx * c_yy - c_xy * c_xy;
69
70 if (c_det/(c_xx+c_yy+0.00001)) < GOOD_FEATURE_LAMBDA_TH
71 valid(i)=0;
72 break;
73 end
74
75 c_det=1/c_det;
76
77 for k=1:max_iter
78 if ((x+dX-winSize)<1 || (y+dY-winSize)<1 || (y+dY+winSize+1)>imgSize(1) || (x+dX+winSize+1)>imgSize(2))
79 %winSize+1due to interpolation
80 %error or skip the level??
81 valid(i)=0;
82 break;
83 end
84
85 jPatch = getInterpolatePatch(jP{level}, imgSize(1), imgSize(2), x+dX, y+dY, winSize);
86 eX = 0;
87 eY = 0;
88 for idx=1:winSizeSq
89 dIt = iPatch(idx) - jPatch(idx);
90 eX = eX + (dIt*iDxPatch(idx));
91 eY = eY + (dIt*iDyPatch(idx));
92 end
93
94 mX = c_det*(eX*c_yy-eY*c_xy);
95 mY = c_det*(-eX*c_xy+eY*c_xx);
96 dX = dX + mX;
97 dY = dY + mY;
98
99
100 if ((mX*mX+mY*mY)<accuracy_th)
101 break;
102 end
103 end
104 end
105
106 newFPnt(1, i) = fPnt(1,i)+dX;
107 newFPnt(2, i) = fPnt(2,i)+dY;
108end