Also, something to note, please verify that in the interpolator it is Row/Col vs Col/Row......
For instance, I wanted to verify that the interpolator was going to work for me as you had above and populated it with my OpenCV data and then afterwards I pulled it out of the interpolator into a new image I could display it to verify correctness.
In order for me to obtain correct values per pixel, I had to have the grid be addressed using (Cols, Rows) in a snippet below. This works but it is not obvious why by default it seems to be using Column Major even though the default should be RowMajor...... something to verify with your own implementation.
const int cols = imSDF.cols;
const int rows = imSDF.rows;
Eigen::ArrayXXd img_data = Eigen::ArrayXXd(rows,cols);
for (int j = 0; j < rows; j++) {
for (int i = 0; i < cols; i++)
{
float sdf = imSDF.at<float>(cv::Point(i,j));
img_data(j, i) = (double)sdf;
}
}
Grid theGrid(img_data.data(), 0, img_data.cols(), 0, img_data.rows());
theInterpolator = new Interpolator(theGrid);
// pulling data per pixel out here to test:
cv::Mat imTest = cv::Mat::zeros(cv::Size(cols,rows), CV_32F);
for (int j = 0; j < rows; j++) {
for (int i = 0; i < cols; i++)
{
ceres::Jet<double, 4> r_jet, c_jet,ff;
r_jet.a = (double)j;
r_jet.v[0] = 1.0;
r_jet.v[1] = 1.1;
r_jet.v[2] = 1.2;
r_jet.v[3] = 1.3;
c_jet.a = (double)i;
c_jet.v[0] = 2.0;
c_jet.v[1] = 2.1;
c_jet.v[2] = 2.2;
c_jet.v[3] = 2.3;
theInterpolator->Evaluate(c_jet,r_jet, &ff);
imTest.at<float>(cv::Point(i, j)) = (float)ff.a;
}
}
cv::imshow("test", imTest);