Segmentation fault during MapperGradAffine.calculate() [closed]

asked 2017-01-27 11:27:08 -0600

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;
            }
        }
    }
}
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-07 00:12:59.510764

Comments

I think it is better to try to convert img image in double before changing source code

LBerger gravatar imageLBerger ( 2017-01-27 11:43:49 -0600 )edit

Thanks, tried that - that helped solve it - atleast that segmentation fault

poohmaan gravatar imagepoohmaan ( 2017-01-27 11:51:54 -0600 )edit

May be some check are missing in function body. You can post an issue

LBerger gravatar imageLBerger ( 2017-01-27 11:58:31 -0600 )edit