Using the open CV's remap function with different types of source images has given me some interesting results.
The following types work as expected: CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1, CV_64FC1.
The two types that are giving me an error are: CV_8SC1, CV_32SC1.
The interesting part is that CV_16SC1 is working while CV_8SC1 is not.
Does anyone have any insights as why this is happening?
This is my code that I use:
cv::Mat remapX, remapY;
remapX.create(output_cv_mat.rows, output_cv_mat.cols, CV_32FC1);
remapY.create(output_cv_mat.rows, output_cv_mat.cols, CV_32FC1);
for(int x = 0; x < remapX.cols; x++) //Column iteration
{
for(int y = 0; y < remapX.rows; y++) //Row iteration
{
remapX.at<float>(y, x) = (float)(x);
remapY.at<float>(y, x) = (float)(remapX.rows - y);
}
}
cv::remap(source_cv_mat, output_cv_mat, remapX, remapY, cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar(0, 0, 0));
The code uses source cv::Mat (the one who's types I am trying out) and output cv::Mat. I create the maps X and Y, use them in for loops and then finish with remap function.
The error I receive with these two types is:
terminate called after throwing an instance of 'cv::Exception' what(): OpenCV(4.0.1-dev) /home/aljaz/opencv_build/opencv/modules/imgproc/src/imgwarp.cpp:1805: error: (-215:Assertion failed) ifunc != 0 in function 'remap'