From: jzhou Date: Thu, 12 Nov 2009 00:43:34 +0000 (+0000) Subject: New Tracking benchmark for scheduling. Still have problem of test data configuration X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f75d6131b9433d3046d5dc9521588dde8d068295;p=IRC.git New Tracking benchmark for scheduling. Still have problem of test data configuration --- diff --git a/Robust/src/Benchmarks/Scheduling/Tracking/BlurPiece.java b/Robust/src/Benchmarks/Scheduling/Tracking/BlurPiece.java new file mode 100644 index 00000000..447dee92 --- /dev/null +++ b/Robust/src/Benchmarks/Scheduling/Tracking/BlurPiece.java @@ -0,0 +1,141 @@ +public class BlurPiece { + flag toblur; + flag toaddBP; + flag finish; + + /* current processing image related */ + int[] m_image; + int m_rows; + int m_cols; + + /* results related */ + float[] m_result; + int m_rows_rs; + int m_rows_re; + int m_cols_r; + + /* id indicating the piece # */ + int m_id; + int m_range; + + /* constructor */ + public BlurPiece(int id, + int range, + int[] data) { + this.m_id = id; + this.m_range = range; + this.m_image = data; + this.m_rows = data[0]; + this.m_cols = data[1]; + } + + public int getId() { + return this.m_id; + } + + public int getRows() { + return this.m_rows; + } + + public int getCols() { + return this.m_cols; + } + + public float[] getResult() { + return this.m_result; + } + + public int getRowsRS() { + return this.m_rows_rs; + } + + public int getRowsRE() { + return this.m_rows_re; + } + + public int getColsR() { + return this.m_cols_r; + } + + public void blur() { + int rows, cols; + float temp; + int[] kernel, imageIn; + int rows_k, cols_k; + int k, i, j; + int kernelSize, startCol, endCol, halfKernel, startRow, endRow, kernelSum; + int[] inputs; + float[] image; + + inputs = this.m_image; + rows = this.m_rows; + 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(rows < this.m_rows_re) { + 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]; + + kernel = new int[5]; + rows_k = 1; + cols_k = 5; + + kernel[0] = 1; + kernel[1] = 4; + kernel[2] = 6; + kernel[3] = 4; + kernel[4] = 1; + + kernelSize = 5; + kernelSum = 16; + + startCol = 2; //((kernelSize)/2); + endCol = cols - 2; //round(cols - (kernelSize/2)); + halfKernel = 2; //(kernelSize-1)/2; + + if((this.m_rows_re <= 2) || (this.m_rows_rs >= rows - 2)) { + return; + } + startRow = (2>this.m_rows_rs)?2:(this.m_rows_rs); //(kernelSize)/2; + endRow = ((rows-2) rows - 1)) { + return; + } + startRow = (1>this.m_rows_rs)?1:(this.m_rows_rs); //(kernelSize)/2; + endRow = ((rows-1) rows - 1)) { + return; + } + startRow = (1>this.m_rows_rs)?1:(this.m_rows_rs); //(kernelSize)/2; + endRow = ((rows-1) rows - 1)) { + return; + } + startRow = (1>this.m_rows_rs)?1:(this.m_rows_rs); //(kernelSize)/2; + endRow = ((rows-1) rows - 1)) { + return; + } + startRow = (1>this.m_rows_rs)?1:(this.m_rows_rs); //(kernelSize)/2; + endRow = ((rows-1) r_sq) { + validCount++; + } + } + + k = 0; + rows_si = validCount; + cols_si = 1; + supId = new int[rows_si * cols_si]; + for (i = 0; i < (rows_sr*cols_sr); i++) { + if (suppressR[i] > r_sq) { + supId[k++] = i; + } + } + + while (validCount > 0) { + float[] tempp, temps; + int rows_tpp, cols_tpp, rows_tps, cols_tps; + temp[0] = srtdPnts[supId[0] * cols_sp + 0]; + temp[1] = srtdPnts[supId[0] * cols_sp + 1]; + temp[2] = srtdPnts[supId[0] * cols_sp + 2]; + + if(iter == 0) { + interestPnts = temp; + rows_ip[0] = rows_tmp; + cols_ip[0] = cols_tmp; + } else { + interestPnts = this.ffVertcat(interestPnts, + rows_ip[0], + cols_ip[0], + temp, + rows_tmp, + cols_tmp); + rows_ip[0] = rows_ip[0] + rows_tmp; + cols_ip[0] = cols_ip[0]; + } + + iter++; + + // fDeepCopy + rows_tpp = rows_sp; + cols_tpp = cols_sp; + tempp = new float[rows_tpp * cols_tpp]; + for(i=0; i= 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]; + 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 (suppressR[supId[i]] > (t + t1)) { + suppressR[supId[i]] = t + t1; + } + } + + validCount=0; + for (i = 0; i < rows_sr; i++) { + if (suppressR[i] > r_sq) { + validCount++; + } + } + + k = 0; + rows_si = validCount; + cols_si = 1; + supId = new int[rows_si * cols_si]; + + for (i = 0; i < rows_sr*cols_sr; i++) { + if (suppressR[i] > r_sq) { + supId[k++] = i; + } + } + } + + return interestPnts; + } + + public void startTrackingLoop() { + this.m_image = null; + this.m_image_resized = null; + this.m_counter_ix = 2; + this.m_counter_iy = 2; + } + + public float[] getInterpolatePatch(float[] src, + int rows, + int cols, + float centerX, + float centerY) { + float[] dst; + int rows_d, cols_d; + 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)); + + a11 = (1-a)*(1-b); + a12=a*(1-b); + a21=(1-a)*b; + a22 = a*b; + + rows_d = 1; + cols_d = 2*this.WINSZ*2*this.WINSZ; + dst = new float[rows_d * cols_d]; + + for(i=-this.WINSZ; i<=(this.WINSZ-1); i++) { + srcIdxX = (int)(Math.floor(centerX)) + i; + dstIdxX = i+this.WINSZ; + + for(j=-this.WINSZ; j<=(this.WINSZ-1); j++) { + srcIdy = (int)(Math.floor(centerY)) + j; + dstIdy = j+this.WINSZ; + dstIndex = dstIdy * 2 * this.WINSZ + dstIdxX; +// printf("%f\t%f\t%d\t%d\n", centerX, centerY, srcIdxX, srcIdy); + dst[dstIndex] = src[srcIdy * cols + srcIdxX]*a11 + + src[(srcIdy+1)* cols + srcIdxX]*a12 + + src[srcIdy * cols + (srcIdxX+1)]*a21 + + src[(srcIdy+1) * cols+ (srcIdxX+1)]*a22; + } + } + + return dst; + } + + public int[] calcPyrLKTrack(float[][] Ipyrs, + int[] rows, + int[] cols, + float[] newPnt) { + float[] ip1, ip2, idxp1, idxp2, idyp1, idyp2, jp1, jp2, fPnt; + int k = 0; + + ip1 = Ipyrs[k++]; + ip2 = Ipyrs[k++]; + idxp1 = Ipyrs[k++]; + idyp1 = Ipyrs[k++]; + idxp2 = Ipyrs[k++]; + idyp2 = Ipyrs[k++]; + jp1 = this.m_image; + jp2 = this.m_image_resized; + fPnt = this.m_features; + + int idx, level, pLevel, i, winSizeSq; + int[] valid, imgDims; + int rows_v, cols_v, rows_id, cols_id; + float[] rate, iPatch, jPatch, iDxPatch, iDyPatch; + int rows_r, cols_r, rows_ip, cols_ip, rows_jp, cols_jp; + int rows_idxp, cols_idxp, rows_idyp, cols_idyp; + float x, y, dX, dY, c_xx, c_yy, c_xy, tr; + int imgSize_1, /*max_iter, */imgSize_2; + float mX, mY, dIt, eX, eY, c_det; + int nFeatures = this.m_cols_f; + + rows_id = 4; + cols_id = 1; + imgDims = new int[rows_id * cols_id]; + + imgDims[0] = rows[0]; + imgDims[1] = cols[0]; + imgDims[2] = rows[1]; + imgDims[3] = cols[1]; + + pLevel = 2; + rows_r = 1; + cols_r = 6; + rate = new float[rows_r * cols_r]; + + rate[0] = (float)1; + rate[1] = (float)0.5; + rate[2] = (float)0.25; + rate[3] = (float)0.125; + rate[4] = (float)0.0625; + rate[5] = (float)0.03125; + + winSizeSq = 4*this.WINSZ*this.WINSZ; + rows_ip = 1; + cols_ip = winSizeSq; + iPatch = new float[rows_ip * cols_ip]; + rows_jp = 1; + cols_jp = winSizeSq; + jPatch = new float[rows_jp * cols_jp]; + rows_idxp = 1; + cols_idxp = winSizeSq; + iDxPatch = new float[rows_idxp * cols_idxp]; + rows_idyp = 1; + cols_idyp = winSizeSq; + iDyPatch = new float[rows_idyp * cols_idyp]; + + rows_v = 1; + cols_v = nFeatures; + valid = new int[rows_v * cols_v]; + + for(i=0; i=0; level--) { + x = x+x; + y = y+y; + dX = dX + dX; + dY = dY + dY; + imgSize_1 = imgDims[level*2]; + imgSize_2 = imgDims[level*2+1]; + + c_xx = (float)0; + c_xy = (float)0; + c_yy = (float)0; + + if( (x-(float)this.WINSZ)<(float)0 || (y-(float)this.WINSZ)<(float)0 + || (y+(float)this.WINSZ)>=(float)imgSize_1 + || (x+(float)this.WINSZ)>=(float)imgSize_2 ) { + valid[i] = 0; + break; + } + + if(level ==0) { + iPatch = getInterpolatePatch(ip1, rows[0], cols[0], x, y); + iDxPatch = getInterpolatePatch(idxp1, rows[2], cols[2], x, y); + iDyPatch = getInterpolatePatch(idyp1, rows[3], cols[3], x, y); + } + if(level ==1) { + iPatch = getInterpolatePatch(ip2, rows[1], cols[1], x, y); + iDxPatch = getInterpolatePatch(idxp2, rows[4], cols[4], x, y); + iDyPatch = getInterpolatePatch(idyp2, rows[5], cols[5], x, y); + } + rows_ip = rows_idxp = rows_idyp = 1; + cols_ip = cols_idxp = cols_idyp = 2*this.WINSZ*2*this.WINSZ; + + for(idx=0; idx=(float)imgSize_1 + || (x+dX+(float)this.WINSZ)>=(float)imgSize_2) { + valid[i] = 0; + break; + } + +// printf("x and dx = %d\t%d\t%f\t%f\t%f\t%f\n", i, level, x, dX, y, dY); + if(level == 0) { + jPatch = getInterpolatePatch(jp1, + this.m_rows, + this.m_cols, + x+dX, + y+dY); + } + if(level == 1) { + jPatch = getInterpolatePatch(jp2, + this.m_rows_r, + this.m_cols_r, + x+dX, + y+dY); + } + rows_jp = 1; + cols_jp = 2*this.WINSZ*2*this.WINSZ; + + eX = 0; + eY = 0; + for(idx=0; idx 0 ) { + int[] findInd; + int rows_f, cols_f; + rows_f = rows_s * cols_s; + cols_f = 1; + findInd = new int[rows_f * cols_f]; + + k = 0; + m = 0; + numFind = 0; + for(i=0; i 0) { + newpoints[k++] = np_temp[i*cols_np+m]; + } + } + } + } + + // features_ = fDeepCopy(newpoints_); + this.m_rows_f = rows_n; + this.m_cols_f = cols_n; + features = this.m_features = new float[newpoints.length]; + for(k = 0; k < newpoints.length; k++) { + features[k] = newpoints[k]; + } + } + + public void printImage() { + // result validation + for(int i=0; i