I am trying to fill out a opencv matrix with some values, but I keep getting segfaults. The code is following:
Mat mask_gx(in_window_size, in_window_size, image.type());
for(int i = 0; i <= in_window_size; i++)
{
for(int j = 0; j <= in_window_size; j++)
{
double gx = (-i/in_sigma) * pow(M_E, ((pow(i, 2)* pow(j, 2))/pow(in_sigma, 2))/(-2));
mask_gx.at<double>(j, i) = gx;
}
}
The problem is in the last line. I have tested it with:
mask_gx.at<int>(j, i) = 1;
and I still get the segfault.
Does anyone have any ideas what seems to be the problem with this code?
If
in_window_sizeis the amount of values in each dimension, then it should be<and not<=in thefor-loop comparisons, I believe.