Segmentation fault during MapperGradAffine.calculate() [closed]
The following is a snippet of code from opencv/opencv_contrib/module/reg/src/mapper.cpp. If img.type() in the create member is CV_8U, then the Mat created cannot contain any double value which causes a segmentation fault. Am I right here and if so what can I do to change it?
void Mapper::grid(const Mat& img, Mat& grid_r, Mat& grid_c) const
{
// Matrices with reference frame coordinates
grid_r.create(img.size(), img.type());
grid_c.create(img.size(), img.type());
if(img.channels() == 1) {
for(int r_i = 0; r_i < img.rows; ++r_i) {
for(int c_i = 0; c_i < img.cols; ++c_i) {
grid_r.at<double>(r_i, c_i) = r_i;
grid_c.at<double>(r_i, c_i) = c_i;
}
}
} else {
Vec3d ones(1., 1., 1.);
for(int r_i = 0; r_i < img.rows; ++r_i) {
for(int c_i = 0; c_i < img.cols; ++c_i) {
grid_r.at<Vec3d>(r_i, c_i) = r_i*ones;
grid_c.at<Vec3d>(r_i, c_i) = c_i*ones;
}
}
}
}
I think it is better to try to convert img image in double before changing source code
Thanks, tried that - that helped solve it - atleast that segmentation fault
May be some check are missing in function body. You can post an issue