changes.
authoryeom <yeom>
Mon, 2 Aug 2010 04:53:32 +0000 (04:53 +0000)
committeryeom <yeom>
Mon, 2 Aug 2010 04:53:32 +0000 (04:53 +0000)
13 files changed:
Robust/src/Benchmarks/oooJava/tracking/BlurPiece.java
Robust/src/Benchmarks/oooJava/tracking/BlurPieceL.java
Robust/src/Benchmarks/oooJava/tracking/IDX.java
Robust/src/Benchmarks/oooJava/tracking/IXL.java
Robust/src/Benchmarks/oooJava/tracking/IXLR.java
Robust/src/Benchmarks/oooJava/tracking/IYL.java
Robust/src/Benchmarks/oooJava/tracking/IYLR.java
Robust/src/Benchmarks/oooJava/tracking/ImageReader.java
Robust/src/Benchmarks/oooJava/tracking/ImageX.java
Robust/src/Benchmarks/oooJava/tracking/ImageY.java
Robust/src/Benchmarks/oooJava/tracking/Lambda.java
Robust/src/Benchmarks/oooJava/tracking/TrackDemo.java
Robust/src/Benchmarks/oooJava/tracking/TrackingBench.java

index 20bd359b43a6f92034be7d38abf3192f2b8c66c9..e5063e7e7ceed2ab5f6325a8758332404adcc84a 100644 (file)
@@ -14,16 +14,19 @@ public class BlurPiece {
     /* id indicating the piece # */
     int m_id;  
     int m_range;
+    int m_pnum;
 
     /* constructor */
     public BlurPiece(int id,
                      int range,
-                     int[] data) {
+                     int[] data,
+                     int pnum) {
       this.m_id = id;
       this.m_range = range;
       this.m_image = data;
       this.m_rows = data[0];
       this.m_cols = data[1];
+      this.m_pnum = pnum;
     }
     
     public int getId() {
@@ -69,6 +72,9 @@ public class BlurPiece {
       cols = this.m_cols;
       this.m_rows_rs = this.m_id * this.m_range;
       this.m_rows_re = (this.m_id + 1) * this.m_range;
+      if(this.m_id == this.m_pnum - 1) {
+        this.m_rows_re = rows;
+      }
       if(rows < this.m_rows_re) {
         this.m_rows_re = rows;
       }
@@ -98,13 +104,15 @@ public class BlurPiece {
       startRow = (2>this.m_rows_rs)?2:(this.m_rows_rs);       //(kernelSize)/2;
       endRow = ((rows-2)<this.m_rows_re)?(rows-2):(this.m_rows_re);  //(rows - (kernelSize)/2);
       
+      // TODO
+     //System.out.println(rows + "[" + startRow+ ", " + endRow + ")");
+      
       int ii = startRow - this.m_rows_rs;
       for(i=startRow; i<endRow; i++){
         for(j=startCol; j<endCol; j++) {
-          temp = 0;
+          temp = 0.0f;
           for(k=-halfKernel; k<=halfKernel; k++) {
-            temp += (float)((inputs[4 + i * cols + (j+k)] 
-                                    * (float)(kernel[k+halfKernel])));
+            temp += (float)(inputs[4 + i * cols + (j+k)]  * (kernel[k+halfKernel]));
           }
 
           image[ii * cols + j] = (float)(temp/kernelSum);
index 0c08727bf6b482b1ccab97edc06cb88562cf5009..0c6dafe79358856ae7da130f8f782311d3ffea17 100644 (file)
@@ -14,16 +14,19 @@ public class BlurPieceL {
     /* id indicating the piece # */
     int m_id;  
     int m_range;
+    int m_pnum;
 
     /* constructor */
     public BlurPieceL(int id,
                       int range,
-                      int[] data) {
+                      int[] data,
+                      int pnum) {
       this.m_id = id;
       this.m_range = range;
       this.m_image = data;
       this.m_rows = data[0];
       this.m_cols = data[1];
+      this.m_pnum = pnum;
     }
     
     public int getId() {
@@ -72,6 +75,9 @@ public class BlurPieceL {
       if(rows < this.m_rows_re) {
         this.m_rows_re = rows;
       }
+      if(this.m_id == this.m_pnum - 1) {
+        this.m_rows_re = rows;
+      }
       this.m_cols_r = this.m_cols;
       image = this.m_result = new float[(this.m_rows_re-this.m_rows_rs)*cols];
 
@@ -104,7 +110,7 @@ public class BlurPieceL {
           temp = 0;
           for(k=-halfKernel; k<=halfKernel; k++) {
             temp += (float)((inputs[4 + i * cols + (j+k)] 
-                                    * (float)(kernel[k+halfKernel])));
+                                    * (kernel[k+halfKernel])));
           }
 
           image[ii * cols + j] = (float)(temp/kernelSum);
index 0584e493882eca7ef184ddc20a5a95b95ce95dcd..cbe4868a0f7d1536fdf0a3fa6411bb777fd2df26 100644 (file)
@@ -17,6 +17,7 @@ public class IDX {
     /* id indicating the piece # */
     int m_id;  
     int m_range;
+    int m_pnum;
 
     /* constructor */
     public IDX(int nfea,
@@ -25,7 +26,8 @@ public class IDX {
                float[] data,
                int rows,
                int cols,
-               int r) {
+               int r,
+               int pnum) {
       this.N_FEA = nfea;
       
       this.m_id = id;
@@ -38,6 +40,10 @@ public class IDX {
 
       this.m_rows_rs = this.m_id * this.m_range;
       this.m_rows_re = (this.m_id + 1) * this.m_range;
+      if(this.m_id == this.m_pnum - 1) {
+        this.m_rows_re = rows;
+      }
+      
       this.m_cols_r = cols;
       
       this.m_ind = new int[(this.m_rows_re - this.m_rows_rs) * this.m_cols_r];
index 6805065769cac890476dcb105244bfc9545af13f..14cfe0b93dcb727d6aaa45e33a5df934163ff74e 100644 (file)
@@ -14,14 +14,16 @@ public class IXL {
   /* id indicating the piece # */
   int m_id;
   int m_range;
+  int m_pnum;
 
   /* constructor */
-  public IXL(int id, int range, float[] data, int rows, int cols) {
+  public IXL(int id, int range, float[] data, int rows, int cols, int pnum) {
     this.m_id = id;
     this.m_range = range;
     this.m_image = data;
     this.m_rows = rows;
     this.m_cols = cols;
+    this.m_pnum = pnum;
   }
 
   public int getId() {
@@ -66,6 +68,9 @@ public class IXL {
 
     this.m_rows_rs = this.m_id * this.m_range;
     this.m_rows_re = (this.m_id + 1) * this.m_range;
+    if(this.m_id == this.m_pnum - 1) {
+      this.m_rows_re = rows;
+    }
     this.m_cols_r = cols;
     result = this.m_result = new float[(this.m_rows_re - this.m_rows_rs) * this.m_cols_r];
 
index a70be64b51193a56093180968a598d0bb035869a..e077d600f0a35e6a94ccdd4f12675dc52bf5baca 100644 (file)
@@ -15,18 +15,21 @@ public class IXLR {
     /* id indicating the piece # */
     int m_id;  
     int m_range;
+    int m_pnum;
     
     /* constructor */
     public IXLR(int id,
                 int range,
                 float[] data,
                 int rows,
-                int cols) {
+                int cols,
+                int pnum) {
       this.m_id = id;
       this.m_range = range;
       this.m_image = data;
       this.m_rows = rows;
       this.m_cols = cols;
+      this.m_pnum = pnum;
     }
     
     public int getId() {
@@ -71,6 +74,9 @@ public class IXLR {
       
       this.m_rows_rs = this.m_id * this.m_range;
       this.m_rows_re = (this.m_id + 1) * this.m_range;
+      if(this.m_id == this.m_pnum - 1) {
+        this.m_rows_re = rows;
+      }
       this.m_cols_r = cols;
       result=this.m_result=new float[(this.m_rows_re-this.m_rows_rs)*this.m_cols_r];
       
index da88bf4699c640fc7d152c6e34eaf557ee33d774..4d236f249b431cfe3daca5e9b6a65f110854fd9b 100644 (file)
@@ -15,18 +15,21 @@ public class IYL {
     /* id indicating the piece # */
     int m_id;  
     int m_range;
+    int m_pnum ;
     
     /* constructor */
     public IYL(int id,
                int range,
                float[] image,
                int rows,
-               int cols) {
+               int cols,
+               int pnum) {
       this.m_id = id;
       this.m_range = range;
       this.m_image = image;
       this.m_rows = rows;
       this.m_cols = cols;
+      this.m_pnum = pnum;
     }
     
     public int getId() {
@@ -77,6 +80,9 @@ public class IYL {
       
       this.m_rows_rs = this.m_id * this.m_range;
       this.m_rows_re = (this.m_id + 1) * this.m_range;
+      if(this.m_id == this.m_pnum - 1) {
+        this.m_rows_re = rows;
+      }
       this.m_cols_r = cols;
       result=this.m_result=new float[(this.m_rows_re-this.m_rows_rs)*this.m_cols_r];
       
index f1eb6ca75e8508bc5ea28d99d20f21aeb6ab585d..66bd0e52eb4d7325e9075fb9867da28d7a0c8d70 100644 (file)
@@ -15,18 +15,21 @@ public class IYLR {
     /* id indicating the piece # */
     int m_id;  
     int m_range;
+    int m_pnum;
     
     /* constructor */
     public IYLR(int id,
                 int range,
                 float[] image,
                 int rows,
-                int cols) {
+                int cols,
+                int pnum) {
       this.m_id = id;
       this.m_range = range;
       this.m_image = image;
       this.m_rows = rows;
       this.m_cols = cols;
+      this.m_pnum = pnum;
     }
     
     public int getId() {
@@ -77,6 +80,9 @@ public class IYLR {
       
       this.m_rows_rs = this.m_id * this.m_range;
       this.m_rows_re = (this.m_id + 1) * this.m_range;
+      if(this.m_id == this.m_pnum - 1) {
+        this.m_rows_re = rows;
+      }
       this.m_cols_r = cols;
       result=this.m_result=new float[(this.m_rows_re-this.m_rows_rs)*this.m_cols_r];
       
index c08b0216307503900970f0cf7401e99df36e300a..15e3e4f8270d468cfcf81a7220f942e20308f400 100644 (file)
@@ -41,7 +41,7 @@ public class ImageReader {
     int nplanes = (((int) bi[13] & 0xff) << 8) | (int) bi[12] & 0xff;
 //    System.out.println("Planes is :" + nplanes);
     int nbitcount = (((int) bi[15] & 0xff) << 8) | (int) bi[14] & 0xff;
-//    System.out.println("BitCount is :" + nbitcount);
+    //System.out.println("BitCount is :" + nbitcount);
     // Look for non-zero values to indicate compression
     int ncompression =
         (((int) bi[19]) << 24) | (((int) bi[18]) << 16) | (((int) bi[17]) << 8) | (int) bi[16];
@@ -88,7 +88,7 @@ public class ImageReader {
 //           +((int)brgb[nindex + 1]&0xff)+"," +((int)brgb[nindex]&0xff)+")");
           int ta=((3*((int)(brgb[nindex + 2]) & 0xff)+6*((int)brgb[nindex + 1]&0xff)+((int)brgb[nindex]&0xff))) /10 ;
           ndata[nwidth * (nheight - j - 1) + i+4] =ta;
-//           System.out.println(ta);
+          //System.out.println((nwidth * (nheight - j - 1) + i+4)+" "+nwidth+" "+nheight);
           nindex += 3;
         }
         nindex += npad;
@@ -130,6 +130,7 @@ public class ImageReader {
         // 0xff)+"," +((int)(bpalette[nindex8+2]) & 0xff)+","
         // +((int)bpalette[nindex8+1]&0xff)+","
         // +((int)bpalette[nindex8]&0xff)+")");
+        
         nindex8 += 4;
       }
       // Read the image data (actually indices into the palette)
@@ -163,6 +164,10 @@ public class ImageReader {
     ndata[2] = nheight * nwidth;
     ndata[3] = 2;
     
+//    for(int i=4;i<5;i++){
+//      System.out.println(ndata[i]);
+//    }
+    
     return ndata;
 
   }
index 07a8c3376f037a7759ee5039c0554d99d739cf7e..c14ba411075870b9192ca5abcb53354524a5cf36 100644 (file)
@@ -14,18 +14,21 @@ public class ImageX {
     /* id indicating the piece # */
     int m_id;  
     int m_range;
+    int m_pnum;
     
     /* constructor */
     public ImageX(int id,
                   int range,
                   float[] data,
                   int rows,
-                  int cols) {
+                  int cols,
+                  int pnum) {
       this.m_id = id;
       this.m_range = range;
       this.m_image = data;
       this.m_rows = rows;
       this.m_cols = cols;
+      this.m_pnum = pnum;
     }
     
     public int getId() {
@@ -70,6 +73,9 @@ public class ImageX {
       
       this.m_rows_rs = this.m_id * this.m_range;
       this.m_rows_re = (this.m_id + 1) * this.m_range;
+      if(this.m_id == this.m_pnum - 1) {
+        this.m_rows_re = rows;
+      }
       this.m_cols_r = cols;
       result=this.m_result=new float[(this.m_rows_re-this.m_rows_rs)*this.m_cols_r];
       
index 531d7c3bde126549e89708b55ae441cc76a87792..7da0a1d93954a7f62723d2744ba994c14a23f378 100644 (file)
@@ -14,18 +14,21 @@ public class ImageY {
     /* id indicating the piece # */
     int m_id;  
     int m_range;
+    int m_pnum;
     
     /* constructor */
     public ImageY(int id,
                   int range,
                   float[] image,
                   int rows,
-                  int cols) {
+                  int cols,
+                  int pnum) {
       this.m_id = id;
       this.m_range = range;
       this.m_image = image;
       this.m_rows = rows;
       this.m_cols = cols;
+      this.m_pnum = pnum;
     }
     
     public int getId() {
@@ -76,6 +79,9 @@ public class ImageY {
       
       this.m_rows_rs = this.m_id * this.m_range;
       this.m_rows_re = (this.m_id + 1) * this.m_range;
+      if(this.m_id == this.m_pnum - 1) {
+        this.m_rows_re = rows;
+      }
       this.m_cols_r = cols;
       result=this.m_result=new float[(this.m_rows_re-this.m_rows_rs)*this.m_cols_r];
       
index d691b7f7361e2b4269427bc5753f6a3cae92bc9d..695faefbb72d94840a745d7ac38d297ff8739846 100644 (file)
@@ -192,7 +192,7 @@ public class Lambda {
       //    result validation
       for(int i=0; i<this.m_rows; i++) {
           for(int j=0; j<this.m_cols; j++) {
-              System.printI((int)(this.m_image[i * this.m_cols + j]*10));
+              System.out.println(this.m_image[i * this.m_cols + j]);
           }
       }
     }
index 3adfb0c401b0b78f60b5268fad0b87273fec69f8..62558bda35724c47b4e43edfcac9081e8e1b9d0b 100644 (file)
@@ -52,7 +52,7 @@ public class TrackDemo {
     this.m_num_bpl = 0;
 
     this.WINSZ = 8;
-    this.N_FEA = 16; // 00;
+    this.N_FEA = 1600; // 00;
     this.SUPPRESION_RADIUS = 10;
     this.LK_ITER = 20;
     this.accuracy = (float) 0.03;
@@ -243,10 +243,11 @@ public class TrackDemo {
 
     for (i = startRow; i < endRow; i++) {
       for (j = startCol; j < endCol; j++) {
-        temp = 0;
+        temp = 0.0f;
         for (k = -halfKernel; k <= halfKernel; k++) {
-          temp += (float) ((image[(i + k) * cols + j] * (float) (kernel[k + halfKernel])));
+          temp +=  image[(i + k) * cols + j] *  kernel[k + halfKernel];
         }
+        //System.out.println(temp*10000 + " " + i + " " + j); // TODO
         image[i * cols + j] = (float) (temp / kernelSum);
       }
     }
@@ -304,7 +305,7 @@ public class TrackDemo {
       for (j = startCol; j < endCol; j += 2) {
         tempVal = 0;
         for (k = -halfKernel; k <= halfKernel; k++) {
-          tempVal += (float) (image[i * cols + (j + k)] * (float) (kernel[k + halfKernel]));
+          tempVal += (float) (image[i * cols + (j + k)] *  (kernel[k + halfKernel]));
         }
         temp[i * outputCols + m] = (float) (tempVal / kernelSum);
         m = m + 1;
@@ -316,7 +317,7 @@ public class TrackDemo {
       for (j = 0; j < outputCols; j++) {
         tempVal = 0;
         for (k = -halfKernel; k <= halfKernel; k++) {
-          tempVal += (float) (temp[(i + k) * outputCols + j] * (float) (kernel[k + halfKernel]));
+          tempVal += (float) (temp[(i + k) * outputCols + j] *  (kernel[k + halfKernel]));
         }
         resized[m * outputCols + j] = (float) (tempVal / kernelSum);
       }
@@ -378,7 +379,7 @@ public class TrackDemo {
       for (j = startCol; j < endCol; j += 2) {
         tempVal = 0;
         for (k = -halfKernel; k <= halfKernel; k++) {
-          tempVal += (float) (image[i * cols + (j + k)] * (float) (kernel[k + halfKernel]));
+          tempVal += (float) (image[i * cols + (j + k)] *  (kernel[k + halfKernel]));
         }
         temp[i * outputCols + m] = (float) (tempVal / kernelSum);
         m = m + 1;
@@ -390,7 +391,7 @@ public class TrackDemo {
       for (j = 0; j < outputCols; j++) {
         tempVal = 0;
         for (k = -halfKernel; k <= halfKernel; k++) {
-          tempVal += (float) (temp[(i + k) * outputCols + j] * (float) (kernel[k + halfKernel]));
+          tempVal += (float) (temp[(i + k) * outputCols + j] *  (kernel[k + halfKernel]));
         }
         resized[m * outputCols + j] = (float) (tempVal / kernelSum);
       }
@@ -408,7 +409,6 @@ public class TrackDemo {
     int r = idx.getR();
     int nfea = this.N_FEA;
     int length = this.m_rows * this.m_cols;
-    System.out.println("length: "+length);
     int[] h_ind = new int[this.N_FEA];
     boolean[] f_ind = new boolean[this.N_FEA];
     for (int i = 0; i < this.N_FEA; i++) {
@@ -427,8 +427,8 @@ public class TrackDemo {
           m3f[2][rindex] = image[localindex];
           h_ind[rindex] = localindex;
           localindex++;
-          m3f[0][rindex] = Math.ceilf((float) (localindex / (float) r));
-          m3f[1][rindex] = (float) localindex - (m3f[0][rindex] - 1) * (float) r * (float) 1.0;
+          m3f[0][rindex] = (float)Math.ceil((float) (localindex / (float) r));
+          m3f[1][rindex] = (float) (localindex - (m3f[0][rindex] - 1) *  r *  1.0);
           f_ind[rindex] = true;
         } else {
           // previously held by some others with the same value
@@ -465,8 +465,8 @@ public class TrackDemo {
           m3f[2][p] = image[localindex];
           h_ind[p] = localindex;
           localindex++;
-          m3f[0][p] = Math.ceilf((float) (localindex / (float) r));
-          m3f[1][p] = (float) localindex - (m3f[0][p] - 1) * (float) r * (float) 1.0;
+          m3f[0][p] = (float)Math.ceil((float) (localindex / (float) r));
+          m3f[1][p] = (float) (localindex - (m3f[0][p] - 1) *  r *  1.0);
           f_ind[p] = true;
         }
       }
@@ -474,7 +474,7 @@ public class TrackDemo {
     }
 
     this.m_num_p--;
-    print3f();
+    //print3f();
 
     return (0 == this.m_num_p);
   }
@@ -504,6 +504,13 @@ public class TrackDemo {
     rows_ipt = rows_ip[0];
     cols_ipt = cols_ip[0];
     rows_ip = cols_ip = null;
+    
+    // TODO
+//    for(int i = 0; i < interestPnts.length; i++) {
+//      if(interestPnts[i] > 0.0) {
+//        System.out.println("index: " + i + " " + interestPnts[i]);
+//      }
+//    }
 
     // fTranspose(interestPnts)
     float[] trans;
@@ -658,15 +665,21 @@ public class TrackDemo {
     int n, i, j, k, validCount, cnt, end, iter, rows, cols;
     int supIdPtr = 0;
 
+    // TODO
+//    for(i = 0; i < rows_f1; i++) {
+//      System.out.println("++ " + f1[i] + " " + f2[i] + " " + f3[i]);
+//    }
+    
     r_sq = (float) (this.SUPPRESION_RADIUS ^ 2);
     points = this.horzcat(f1, rows_f1, cols_f1, f2, rows_f2, cols_f2, f3, rows_f3, cols_f3);
     rows_p = rows_f3;
     cols_p = cols_f1 + cols_f2 + cols_f3;
     n = rows_f3;
+    
     // TODO
-    for(i = 0; i < rows_p*cols_p; i++) {
-      System.out.println("++ " + points[i]);
-    }
+//    for(i = 0; i < points.length; i++) {
+//      System.out.println(points[i]);
+//    }
 
     /** sort() arg 2 is for descend = 1, arg3 = indices. Returns sorted values **/
 
@@ -712,8 +725,7 @@ public class TrackDemo {
       if (suppressR[i] > r_sq) {
         supId[k++] = i;
       }
-    }
-   
+    }   
 
     while (validCount > 0) {
       float[] tempp, temps;
@@ -732,6 +744,7 @@ public class TrackDemo {
         rows_ip[0] = rows_ip[0] + rows_tmp;
         cols_ip[0] = cols_ip[0];
       }
+      
 
       iter++;
 
@@ -770,31 +783,28 @@ public class TrackDemo {
       for (i = 0; i < rows_sp; i++) {
         t = (float) 0;
         t1 = (float) 0;
-        System.out.println("HERE? length="+srtdPnts.length+" idx="+(supId[i] * cols_sp + 2));
-        if ((C_ROBUST * interestPnts[rows1 * cols1 + 2]) >= srtdPnts[supId[i] * cols_sp + 2]) {
-          t = srtdPnts[supId[i] * cols_sp + 0] - interestPnts[rows1 * cols1 + 0];
-          t1 = srtdPnts[supId[i] * cols_sp + 1] - interestPnts[rows1 * cols1 + 1];
+        if ((C_ROBUST * interestPnts[rows1 * cols1 + 2]) >= srtdPnts[i * cols_sp + 2]) {
+          t = srtdPnts[i * cols_sp + 0] - interestPnts[rows1 * cols1 + 0];
+          t1 = srtdPnts[i * cols_sp + 1] - interestPnts[rows1 * cols1 + 1];
           t = t * t + t1 * t1;
           t1 = (float) 0;
         }
 
-        if ((C_ROBUST * interestPnts[rows1 * cols1 + 2]) < srtdPnts[supId[i] * cols_sp + 2]) {
-          t1 = (float) 1 * (float) MAX_LIMIT;
+        if ((C_ROBUST * interestPnts[rows1 * cols1 + 2]) < srtdPnts[i * cols_sp + 2]) {
+          t1 =/* (float) 1 **/ (float) MAX_LIMIT;
         }
 
-        if (suppressR[supId[i]] > (t + t1)) {
-          suppressR[supId[i]] = t + t1;
+        if (suppressR[i] > (t + t1)) {
+          suppressR[i] = t + t1;
         }
       }
 
       validCount = 0;
       for (i = 0; i < rows_sr; i++) {
-        System.out.println(suppressR[i]+"<->"+r_sq);
         if (suppressR[i] > r_sq) {
           validCount++;
         }
       }
-      System.out.println("validCount="+validCount);
 
       k = 0;
       rows_si = validCount;
@@ -822,8 +832,8 @@ public class TrackDemo {
     float a, b, a11, a12, a21, a22;
     int i, j, srcIdxX, dstIdxX, srcIdy, dstIdy, dstIndex;
 
-    a = centerX - (float) (Math.floor(centerX));
-    b = centerY - (float) (Math.floor(centerY));
+    a = (float) (centerX - Math.floor(centerX));
+    b = (float) (centerY - Math.floor(centerY));
 
     a11 = (1 - a) * (1 - b);
     a12 = a * (1 - b);
@@ -972,7 +982,8 @@ public class TrackDemo {
           break;
         }
 
-        if ((float) (c_det / (tr + (float) 0.00001)) < (float) this.accuracy) {
+        //System.out.println((float) (c_det / (tr + (float) 0.00001)) );
+        if ((float) (c_det / (tr + 0.00001)) < (float) this.accuracy) {
           valid[i] = 0;
           break;
         }
@@ -1008,8 +1019,8 @@ public class TrackDemo {
 
           mX = c_det * (eX * c_yy - eY * c_xy);
           mY = c_det * (-eX * c_xy + eY * c_xx);
-          // printf("mx = %d\t%d\t%f\t%f\t%f\t%f\t%f\n", i, level, mX, mY,
-          // c_det, eX, eY);
+//        printf("mx = %d\t%d\t%f\t%f\t%f\t%f\t%f\n", i, level, mX, mY, c_det, eX, eY);
+//          System.out.println(i+" "+level+" "+mX+" "+mY+" "+c_det+" "+eX+" "+eY);
           dX = dX + mX;
           dY = dY + mY;
 
@@ -1027,7 +1038,7 @@ public class TrackDemo {
     return valid;
   }
 
-  public void calcTrack(IXLM ixlm, IYLM iylm, IXLMR ixlmr, IYLMR iylmr) {
+  public void calcTrack(float[] prevImage, float[] prevImageR,IXLM ixlm, IYLM iylm, IXLMR ixlmr, IYLMR iylmr) {
     float[][] Ipyrs = new float[6][];
     int[] rows = new int[6];
     int[] cols = new int[6];
@@ -1036,7 +1047,8 @@ public class TrackDemo {
     int[] status;
     int rows_s, cols_s;
 
-    Ipyrs[0] = ixlm.getImage();
+//    Ipyrs[0] = ixlm.getImage();
+    Ipyrs[0] = prevImage;
     rows[0] = ixlm.getRows();
     cols[0] = ixlm.getCols();
     Ipyrs[2] = ixlm.getResult();
@@ -1046,7 +1058,8 @@ public class TrackDemo {
     rows[3] = iylm.getRowsR();
     cols[3] = iylm.getColsR();
 
-    Ipyrs[1] = ixlmr.getImage();
+//    Ipyrs[1] = ixlmr.getImage();
+    Ipyrs[1]=prevImageR;
     rows[1] = ixlmr.getRows();
     cols[1] = ixlmr.getCols();
     Ipyrs[4] = ixlmr.getResult();
@@ -1065,6 +1078,12 @@ public class TrackDemo {
     status = this.calcPyrLKTrack(Ipyrs, rows, cols, newpoints);
     rows_s = 1;
     cols_s = this.m_cols_f;
+    
+//    //TODO
+//    System.out.println("###########");
+//    for(i=0;i<status.length;i++){
+//      System.out.println(status[i]);
+//    }
 
     // fDeepCopy
     np_temp = new float[newpoints.length];
@@ -1143,7 +1162,7 @@ public class TrackDemo {
     }*/
     System.printI(33333333);
     for (int j = 0; j < this.N_FEA; j++) {
-      System.out.println("-- " + this.m_3f[0][j] + " " + this.m_3f[1][j] + " "+ this.m_3f[2][j]);
+      System.out.println("-- " + this.m_3f[0][j] + ",  " + this.m_3f[1][j] + ",  "+ this.m_3f[2][j]);
     }
   }
 
@@ -1154,7 +1173,7 @@ public class TrackDemo {
     System.out.println("m_features.length="+this.m_features.length);
     for (int i = 0; i < this.m_rows_f; i++) {
       for (int j = 0; j < this.m_cols_f; j++) {
-        System.out.println((int) (this.m_features[i * this.m_cols_f + j] * 10));
+        System.out.println( this.m_features[i * this.m_cols_f + j] );
       }
     }
   }
@@ -1166,23 +1185,31 @@ public class TrackDemo {
     
 //    int[] input = getInput(false);
     int[]  input=imageReader.readImage("1.bmp");
+//    for(int i = 0; i <input.length; i++) {
+ //     System.out.println(input[i]);
+ //   }
     
     int pnum = 32; // 60;
     setBPNum(pnum);
     int range = (input[0]) / pnum;
+    //System.out.println(range + " " + input[0]);
     for (int i = 0; i < pnum; i++) {
-      BlurPiece bp = new BlurPiece(i, range, input);
+      BlurPiece bp = new BlurPiece(i, range, input, pnum);
       bp.blur();
       addBP(bp);
     }
-    postBlur();
-    
+ // TODO
+    /*for(int i = 0; i < this.m_image.length; i++) {
+      System.out.println( this.m_image[i]);
+    }*/
+    postBlur();    
 
     float[] Icur = getImage();
+    
     // TODO
-    for(int tmpi = 0; tmpi < Icur.length; tmpi++) {
-      System.out.println(Icur[tmpi]);
-    }
+    /*for(int i = 0; i < Icur.length; i++) {
+      System.out.println(Icur[i]);
+    }*/
 
     pnum = 16; // 30;
     range = getRows() / pnum;
@@ -1192,7 +1219,7 @@ public class TrackDemo {
     // create ImageX to calc Sobel_dX
     ImageXM imageXM = new ImageXM(pnum, rows, cols);
     for (int i = 0; i < pnum; i++) {
-      ImageX imageX = new ImageX(i, range, Icur, rows, cols);
+      ImageX imageX = new ImageX(i, range, Icur, rows, cols, pnum);
       imageX.calcSobel_dX();
       imageXM.addCalcSobelResult(imageX);
     }
@@ -1202,7 +1229,7 @@ public class TrackDemo {
     // create ImageY to calc Sobel_dY
     ImageYM imageYM = new ImageYM(pnum, rows, cols);
     for (int i = 0; i < pnum; i++) {
-      ImageY imageY = new ImageY(i, range, Icur, rows, cols);
+      ImageY imageY = new ImageY(i, range, Icur, rows, cols, pnum);
       imageY.calcSobel_dY();
       imageYM.addCalcSobelResult(imageY);
     }
@@ -1214,7 +1241,7 @@ public class TrackDemo {
     lda.calcGoodFeature(imageXM, imageYM);
 //    lda.calcGoodFeature(eom_imageXM, eom_imageYM);
     // validation
-    // lda.printImage();
+    //lda.printImage();
     lda.reshape();
     // validation
     // lda.printImage();
@@ -1229,10 +1256,10 @@ public class TrackDemo {
 
     IDX IDXarray[]=new IDX[c_pnum];
     for (int i = 0; i < c_pnum; i++) {
-      IDX idx = new IDX(lda.N_FEA, i, c_range, data, c_rows, c_cols, r);
+      IDX idx = new IDX(lda.N_FEA, i, c_range, data, c_rows, c_cols, r, c_pnum);
       idx.fSortIndices();
       // validation
-     idx.printInd();
+     //idx.printInd();
       IDXarray[i]=idx;
     }
     
@@ -1241,12 +1268,23 @@ public class TrackDemo {
     for (int i = 0; i < c_pnum; i++) {
       addIDX(IDXarray[i]);
     }
+    
+    //print3f();
 
     // TASK:calcFeatures
     calcFeatures();
 
     // TASK:startTrackingLoop
-    do{
+//    do{
+     for(int count=1;count<=m_counter; count++){
+       
+       int prevSize=getRows()*getCols();
+       float[] prevImage=new float[prevSize];
+       System.arraycopy(getImage(), 0, prevImage, 0, prevSize);
+       
+       prevSize=getRowsR()*getColsR();
+       float[] prevImageR=new float[prevSize];
+       System.arraycopy(getImageR(), 0, prevImageR, 0, prevSize);
       
       int pnum1 = 8; // 15; // * 2;
       data = getImage();
@@ -1257,10 +1295,10 @@ public class TrackDemo {
       IXLM ixlm = new IXLM(pnum1, data, rows, cols);
       IYLM iylm = new IYLM(pnum1, data, rows, cols);
       for (int i = 0; i < pnum1; i++) {
-        IXL ixl = new IXL(i, range, data, rows, cols);
+        IXL ixl = new IXL(i, range, data, rows, cols, pnum1);
         ixl.calcSobel_dX();
         ixlm.addCalcSobelResult(ixl);
-        IYL iyl = new IYL(i, range, data, rows, cols);
+        IYL iyl = new IYL(i, range, data, rows, cols, pnum1);
         iyl.calcSobel_dY();
         iylm.addCalcSobelResult(iyl);
       }
@@ -1275,10 +1313,10 @@ public class TrackDemo {
       IYLMR iylmr = new IYLMR(pnum1, data, rows, cols);
   
       for (int i = 0; i < pnum1; i++) {
-        IXLR ixl = new IXLR(i, range, data, rows, cols);
+        IXLR ixl = new IXLR(i, range, data, rows, cols, pnum1);
         ixl.calcSobel_dX();
         ixlmr.addCalcSobelResult(ixl);
-        IYLR imy = new IYLR(i, range, data, rows, cols);
+        IYLR imy = new IYLR(i, range, data, rows, cols, pnum1);
         imy.calcSobel_dY();
         iylmr.addCalcSobelResult(imy);
       }
@@ -1286,9 +1324,12 @@ public class TrackDemo {
       iylmr.calcSobel_dY();
   
       int pnum2 = 32; // 60; // * 2;
-//      input = getInput(true);
-      input = imageReader.readImage("1.bmp");
+      System.out.println("read image: "+count+".bmp");
+      input = imageReader.readImage(count+".bmp");
       this.m_count++;
+//      input = getInput(true);
+//      input = imageReader.readImage((m_count+1)+".bmp");
+//      this.m_count++;
       
       
 //      float ip1[]=new float[getRows()*getCols()];
@@ -1301,7 +1342,7 @@ public class TrackDemo {
       range = (input[0]) / pnum2;
       BlurPieceL bplArray[]=new BlurPieceL[pnum2];
       for (int i = 0; i < pnum2; i++) {
-        BlurPieceL bpl = new BlurPieceL(i, range, input);
+        BlurPieceL bpl = new BlurPieceL(i, range, input, pnum2);
         bpl.blur();
         bplArray[i]=bpl;
       }
@@ -1318,9 +1359,10 @@ public class TrackDemo {
       
       //task calcTrack
    
-      calcTrack(ixlm, iylm, ixlmr, iylmr);
+      calcTrack(prevImage, prevImageR, ixlm, iylm, ixlmr, iylmr);
     
-    }while(!isFinish());
+     }
+//    }while(!isFinish());
     
     printFeatures();
   }
index 2dc50c232354b6eaa1b4b264a4afcc7f26218500..a0b89d3499f80c742190ff76d71d9e6f355e7b72 100644 (file)
@@ -1,7 +1,7 @@
 public class TrackingBench {
 
   public static void main(String args[]) {
-    int nump = 32; // 60;
+    int nump = 32; //32; // 60;
     TrackDemo tdmo = new TrackDemo(nump);
     tdmo.run();
   }