summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/tracking/src/c
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/tracking/src/c')
-rw-r--r--SD-VBS/benchmarks/tracking/src/c/calcAreaSum.c81
-rw-r--r--SD-VBS/benchmarks/tracking/src/c/calcGoodFeature.c78
-rw-r--r--SD-VBS/benchmarks/tracking/src/c/calcPyrLKTrack.c179
-rw-r--r--SD-VBS/benchmarks/tracking/src/c/fillFeatures.c67
-rw-r--r--SD-VBS/benchmarks/tracking/src/c/getANMS.c156
-rw-r--r--SD-VBS/benchmarks/tracking/src/c/getInterpolatePatch.c43
-rw-r--r--SD-VBS/benchmarks/tracking/src/c/script_tracking.c263
-rw-r--r--SD-VBS/benchmarks/tracking/src/c/tracking.h20
8 files changed, 887 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/tracking/src/c/calcAreaSum.c b/SD-VBS/benchmarks/tracking/src/c/calcAreaSum.c
new file mode 100644
index 0000000..40f03dc
--- /dev/null
+++ b/SD-VBS/benchmarks/tracking/src/c/calcAreaSum.c
@@ -0,0 +1,81 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "tracking.h"
6
7/** Compute the sum of pixels over pixel neighborhood.
8 Neighborhood = winSize*winSize
9 This will be useful when we compute the displacement
10 of the neighborhood across frames instead of tracking each pixel.
11
12 Input: src Image
13 # rows, cols, size of window
14 Output: windowed-sum image, ret.
15
16 Example:
17
18 winSize = 4, cols = 8, rows = 16
19 nave_half = 2, nave = 4
20 Say, the first row of the image is:
21 3 8 6 2 4 8 9 5
22 a1 = 0 0 3 8 6 2 4 8 9 5 0 0 (append nave_half zeros to left and right border)
23 asum = (sum the first nave # pixels - 0 0 3 8 ) = 11
24 ret(0,0) = 11
25 For ret(0,1), we need to move the window to the right by one pixel and subtract
26 from a1sum the leftmost pixel. So, we add value 6 and subtract value at a1(0,0), = 0 here.
27 ret(0,1) = 17 = a1sum
28 For ret(0,2), a1sum - a1(0,1) + a1(2+nave) = 17 - 0 + 2 = 19 = a1sum
29 For ret(0,3), a1sum - a1(0,2) + a1(3+nave) = 19 - 3 + 4 = 20 = a1sum
30
31 We proceed this way for all the rows and then perform summantion across all cols.
32**/
33F2D* calcAreaSum(F2D* src, int cols, int rows, int winSize)
34{
35 int nave, nave_half, i, j, k;
36 F2D *ret, *a1;
37 float a1sum;
38
39 nave = winSize;
40 nave_half = floor((nave+1)/2);
41
42 ret = fMallocHandle(rows, cols);
43 a1 = fSetArray(1, cols+nave,0);
44
45 for(i=0; i<rows; i++)
46 {
47 for(j=0; j<cols; j++) {
48 asubsref(a1,j+nave_half) = subsref(src,i,j);
49 }
50 a1sum = 0;
51 for(k=0; k<nave; k++) {
52 a1sum += asubsref(a1,k);
53 }
54 for(j=0; j<cols; j++)
55 {
56 subsref(ret,i,j) = a1sum;
57 a1sum += asubsref(a1,j+nave) - asubsref(a1,j);
58 }
59 }
60 fFreeHandle(a1);
61
62 a1 = fSetArray(1, rows+nave,0);
63 for(i=0; i<cols; i++)
64 {
65 for(j=0; j<rows; j++) {
66 asubsref(a1,j+nave_half) = subsref(ret,j,i);
67 }
68 a1sum = 0;
69 for(k=0; k<nave; k++) {
70 a1sum += asubsref(a1,k);
71 }
72 for(j=0; j<rows; j++)
73 {
74 subsref(ret,j,i) = a1sum;
75 a1sum += asubsref(a1,j+nave) - asubsref(a1,j);
76 }
77 }
78 fFreeHandle(a1);
79
80 return ret;
81}
diff --git a/SD-VBS/benchmarks/tracking/src/c/calcGoodFeature.c b/SD-VBS/benchmarks/tracking/src/c/calcGoodFeature.c
new file mode 100644
index 0000000..0ef1862
--- /dev/null
+++ b/SD-VBS/benchmarks/tracking/src/c/calcGoodFeature.c
@@ -0,0 +1,78 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "tracking.h"
6
7/** Computes lambda matrix, strength at each pixel
8
9 det = determinant( [ IverticalEdgeSq IhorzVertEdge; IhorzVertEdge IhorizontalEdgeSq] ) ;
10 tr = IverticalEdgeSq + IhorizontalEdgeSq;
11 lamdba = det/tr;
12
13 Lambda is the measure of the strength of pixel
14 neighborhood. By strength we mean the amount of
15 edge information it has, which translates to
16 sharp features in the image.
17
18 Input: Edge images - vertical and horizontal
19 Window size (neighborhood size)
20 Output: Lambda, strength of pixel neighborhood
21
22 Given the edge images, we compute strength based
23 on how strong the edges are within each neighborhood.
24
25**/
26
27F2D* calcGoodFeature(F2D* verticalEdgeImage, F2D* horizontalEdgeImage, int cols, int rows, int winSize)
28{
29 int i, j, k, ind;
30 F2D *verticalEdgeSq, *horizontalEdgeSq, *horzVertEdge;
31 F2D *tr, *det, *lambda;
32 F2D *cummulative_verticalEdgeSq, *cummulative_horzVertEdge, *cummulative_horizontalEdgeSq;
33
34 verticalEdgeSq = fMallocHandle(rows, cols);
35 horzVertEdge = fMallocHandle(rows, cols);
36 horizontalEdgeSq = fMallocHandle(rows, cols);
37
38 for( i=0; i<rows; i++)
39 {
40 for( j=0; j<cols; j++)
41 {
42 subsref(verticalEdgeSq,i,j) = subsref(verticalEdgeImage,i,j) * subsref(verticalEdgeImage,i,j);
43 subsref(horzVertEdge,i,j) = subsref(verticalEdgeImage,i,j) * subsref(horizontalEdgeImage,i,j);
44 subsref(horizontalEdgeSq,i,j) = subsref(horizontalEdgeImage,i,j) * subsref(horizontalEdgeImage,i,j);
45 }
46 }
47
48 cummulative_verticalEdgeSq = calcAreaSum(verticalEdgeSq, cols, rows, winSize);
49 cummulative_horzVertEdge = calcAreaSum(horzVertEdge, cols, rows, winSize);
50 cummulative_horizontalEdgeSq = calcAreaSum(horizontalEdgeSq, cols, rows, winSize);
51
52 tr = fMallocHandle(rows, cols);
53 det = fMallocHandle(rows, cols);
54 lambda = fMallocHandle(rows, cols);
55
56 for( i=0; i<rows; i++)
57 {
58 for( j=0; j<cols; j++)
59 {
60 subsref(tr,i,j) = subsref(cummulative_verticalEdgeSq,i,j) + subsref(cummulative_horizontalEdgeSq,i,j);
61 subsref(det,i,j) = subsref(cummulative_verticalEdgeSq,i,j) * subsref(cummulative_horizontalEdgeSq,i,j) - subsref(cummulative_horzVertEdge,i,j) * subsref(cummulative_horzVertEdge,i,j);
62 subsref(lambda,i,j) = ( subsref(det,i,j) / (subsref(tr,i,j)+0.00001) ) ;
63 }
64 }
65
66 fFreeHandle(verticalEdgeSq);
67 fFreeHandle(horzVertEdge);
68 fFreeHandle(horizontalEdgeSq);
69
70 fFreeHandle(cummulative_verticalEdgeSq);
71 fFreeHandle(cummulative_horzVertEdge);
72 fFreeHandle(cummulative_horizontalEdgeSq);
73
74 fFreeHandle(tr);
75 fFreeHandle(det);
76
77 return lambda;
78}
diff --git a/SD-VBS/benchmarks/tracking/src/c/calcPyrLKTrack.c b/SD-VBS/benchmarks/tracking/src/c/calcPyrLKTrack.c
new file mode 100644
index 0000000..3718673
--- /dev/null
+++ b/SD-VBS/benchmarks/tracking/src/c/calcPyrLKTrack.c
@@ -0,0 +1,179 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "tracking.h"
6
7/** calcPyrLKTrack tries to find the displacement (translation in x and y) of features computed in the previous frame.
8 To compute the displacement, we interpolate the existing feature position around the pixel neighborhood.
9 For better results, we perform interpolatations across all pyramid levels.
10
11 Input: Previous frame blurred images, vertical and horizontal
12 Current frame edge images, vertical and horizontal
13 Current frame blurred images, for level 0 and 1
14 Number of features from previous frame