2014년 10월 24일 금요일

영상 평행 이동 2

영상 사이즈가 커지다 보니 http://ttagu.blogspot.kr/2014/10/blog-post_22.html  와 같이 하면 시간이 많이 걸렸다. 영상 좌표마다 if문이 들어가기도 하고, 병렬처리도 안되 있기 때문인데, 병렬 처리를 해주려다, opencv에 있는 함수를 최대한 이용해보았다.

hconcat은 mat 두개를 좌우로 연결하는 함수이다. opencv core.h에 있는데 document에 설명은 찾을 수 없었다.

[-] Collapse
bool Trans4way(const Mat matSrc, int nStep, Mat& matLeft, Mat& matRight, Mat& matUp, Mat& matDown)
{
    int nWidth = matSrc.cols;
    int nHeight = matSrc.rows;

    matLeft = Mat(matSrc,Rect(nStep,0,nWidth-nStep,nHeight));
    matRight = Mat(matSrc,Rect(0,0,nWidth-nStep,nHeight));
    matUp = Mat(matSrc,Rect(0,nStep,nWidth,nHeight-nStep));
    matDown = Mat(matSrc,Rect(0,0,nWidth,nHeight-nStep));

    Mat row = Mat::zeros(Size(nWidth,nStep),CV_8UC1);
    Mat col = Mat::zeros(Size(nStep,nHeight),CV_8UC1);

    hconcat(matLeft,col,matLeft);
    hconcat(col,matRight,matRight);
    vconcat(matUp,row,matUp);
    vconcat(row,matDown,matDown);

    return true;
}

댓글 없음:

댓글 쓰기