void IPMapper::remap(Mat input, Mat* output, bool blur)
{
    if(input.cols == 320 && input.rows == 240) {
        for(int y = 0;y < outputHeight;y++) {
            for(int x = 0;x < outputWidth;x++) {
                Point toCopy = mappingMatrix(y,x);
                if(toCopy.x >= 0 && toCopy.y >= 0 && toCopy.y < 480 && toCopy.x < 640) {
                    output->at<uchar>(y,x) = input.at<uchar>(toCopy.y/2,toCopy.x/2);
                }
            }
        }
    } else {
        for(int y = 0;y < outputHeight;y++) {
            for(int x = 0;x < outputWidth;x++) {
                Point toCopy = mappingMatrix(y,x);
                if(toCopy.x >= 0 && toCopy.y >= 0 && toCopy.y < input.rows && toCopy.x < input.cols) {
                    output->at<uchar>(y,x) = input.at<uchar>(toCopy.y,toCopy.x);
                }
            }
        }
    }

    if(blur) GaussianBlur(*output, *output, Size(5,5),1);
}
Exemple #2
0
Mat IPMapper::remap(Mat input)
{
    Mat remappedImage(outputHeight,outputWidth,CV_8UC1,Scalar(0));
    
    for(int y = 0;y < outputHeight;y++)
    {
        for(int x = 0;x < outputWidth;x++)
        {
            Point toCopy = mappingMatrix(y,x);
            if(toCopy.x >= 0 && toCopy.y >= 0 && toCopy.y < input.rows && toCopy.x < input.cols)
            {
                remappedImage.at<uchar>(y,x) = input.at<uchar>(toCopy.y,toCopy.x);
            }
        }
    }
    GaussianBlur(remappedImage, remappedImage, Size(5,5),1);
    return remappedImage;
}