diff options
Diffstat (limited to 'glitcher/src/audioGlitcher.h')
| -rw-r--r-- | glitcher/src/audioGlitcher.h | 64 |
1 files changed, 57 insertions, 7 deletions
diff --git a/glitcher/src/audioGlitcher.h b/glitcher/src/audioGlitcher.h index caa4028..8d70411 100644 --- a/glitcher/src/audioGlitcher.h +++ b/glitcher/src/audioGlitcher.h @@ -57,12 +57,26 @@ class audioGlitcher { cv::Mat srcX(interp_x,interp_y,CV_32FC1); cv::Mat srcY(interp_x,interp_y,CV_32FC1); +<<<<<<< HEAD + //for a sanity check + //512-1 / 16-1 = 34.066666667 + //* 15= + + float* sx = (float*)srcX.data; + float* sy = (float*)srcY.data; + float* dx = (float*)dstX.data; + float* dy = (float*)dstY.data; + +======= +>>>>>>> caa1426e767efdba526c1d2df0b61aafbd6fcca7 float xFactor=(renderFBO.getWidth()-1)/(srcX.cols-1); float yFactor=(renderFBO.getHeight()-1)/(srcX.rows-1); for (int i=0;i<srcX.cols;i++){ for (int j=0;j<srcX.rows;j++){ - srcX.at<float>(j,i)=i*xFactor; - srcY.at<float>(j,i)=j*yFactor; + //srcX.at<float>(j,i)=i*xFactor; + //srcY.at<float>(j,i)=j*yFactor; + sx[j*srcX.cols+i]=i*xFactor; + sy[j*srcX.cols+i]=j*yFactor; } } @@ -78,7 +92,11 @@ class audioGlitcher { //transform the low res matrix float tX=trans_x; //-.05; //fraction of image +<<<<<<< HEAD + float tY=trans_y; //-.08; //fraction of image +======= float tY=trans_y; //-.04; //fraction of image +>>>>>>> caa1426e767efdba526c1d2df0b61aafbd6fcca7 float oX=origin_x; //fraction of image float oY=origin_y; //fraction of image float s=scale; @@ -100,8 +118,8 @@ class audioGlitcher { dstTri[i].y=srcTri[i].y+(tY*dstX.cols); //use cols for equiv coords //rotate and scale around centre //transform to centre - dstTri[i].x-=(oX*dstX.cols); - dstTri[i].y-=(oY*dstX.cols); + dstTri[i].x-=(oX*(dstX.cols)); + dstTri[i].y-=(oY*(dstX.cols)); dstTri[i].x*=s; dstTri[i].y*=s; @@ -113,8 +131,8 @@ class audioGlitcher { dstTri[i].y=dy; //transform back - dstTri[i].x+=(oX*dstX.cols); - dstTri[i].y+=(oY*dstX.cols); + dstTri[i].x+=(oX*(dstX.cols)); + dstTri[i].y+=(oY*(dstX.cols)); } cv::Mat trans_mat=getAffineTransform(srcTri,dstTri); @@ -127,10 +145,42 @@ class audioGlitcher { cv::resize(dstX,scaledstX, cv::Size(renderFBO.getWidth(),renderFBO.getHeight()), 0, 0, cv::INTER_LINEAR); cv::resize(dstY,scaledstY, cv::Size(renderFBO.getWidth(),renderFBO.getHeight()), 0, 0, cv::INTER_LINEAR); + + + + + + for (int i=0;i<srcX.cols;i++){ + for (int j=0;j<srcX.rows;j++){ + dx[i,j]=i*xFactor; + dy[i,j]=j*yFactor; + + } + } + + for (int i=0;i<scaledstX.cols;i++) { + for (int j=0;j<scaledstX.rows;j++) { + //scaledstX.at<float>(j,i)=i; + //scaledstY.at<float>(j,i)=j; + } + } + + + float* psx = (float*)scaledstX.data; + float* psy = (float*)scaledstY.data; + + cerr<<"src: <0,0> "<<sx[0]<<","<<sy[0]<<endl; + cerr<<"src: <7,5> "<<sx[5*16+7]<<","<<sy[5*16+7]<<endl; + cerr<<"src: <8,6> "<<sx[6*16+8]<<","<<sy[6*16+8]<<endl; + cerr<<"src: <15,11> "<<sx[11*16+15]<<","<<sy[11*16+15]<<endl; + cerr<<"dest: <7,5> "<<dx[5*16+7]<<","<<dy[5*16+7]<<endl; + cerr<<"dest: <8,6> "<<dx[6*16+8]<<","<<dy[6*16+8]<<endl; + cerr<<"Map at <256,192> "<<psx[192*512+256]<<","<<psy[192*512+256]<<endl; + cv::Mat buf = buffer.getCvImage(); cv::Mat dstbuf; - cv::remap(buf,dstbuf,scaledstX,scaledstY, cv::INTER_NEAREST, cv::BORDER_WRAP); //, cv::Scalar(0,0, 0) ); + cv::remap(buf,dstbuf,scaledstX,scaledstY, cv::INTER_NEAREST, cv::BORDER_REPLICATE); //, cv::Scalar(0,0, 0) ); tmp = IplImage(dstbuf); //buffer=tmp; |
