c++ - opencv undistortPoints returning NaN ios -


i have been working opencv, , cannot seem undistortpoints work. matrix returns has nothing nan values.

    //newkeypoints std::vector<cv::keypoint>, , it's values valid     cv::mat src = cv::mat(1,newkeypoints.size(),cv_32fc2);      int = 0;     (std::vector<cv::keypoint>::iterator = newkeypoints.begin(); != newkeypoints.end(); it++){         src.at<cv::vec2f>(0,i)[0] = (*it).pt.x;         src.at<cv::vec2f>(0,i)[1] = (*it).pt.y;         i++;     }      cv::mat norm = cv::mat(1,newkeypoints.size(),cv_32fc2);      //note: fx, fy, cx, cy... k3 global constants declared when initialized     cv::mat cameramatrix = cv::mat(3, 3, cv_32f);     cameramatrix.at<double>(0,0) = fx; //double fx = 354.65      cameramatrix.at<double>(1,0) = 0;     cameramatrix.at<double>(2,0) = 0;     cameramatrix.at<double>(0,1) = 0;     cameramatrix.at<double>(1,1) = fy; //double fy = 355.66     cameramatrix.at<double>(2,1) = 0;     cameramatrix.at<double>(0,2) = cx; //double cx = 143.2     cameramatrix.at<double>(1,2) = cy; //double cy = 173.6     cameramatrix.at<double>(2,2) = 1;      cv::mat distco = cv::mat(1, 5, cv_32f);     distco.at<double>(0,0) = k1; //double k1 = .005     distco.at<double>(0,1) = k2; //double k2 = .002     distco.at<double>(0,2) = p1; //double p1 = -.009     distco.at<double>(0,3) = p2; //double p2 = -.008     distco.at<double>(0,4) = k3; //double k3 = -.03      cv::undistortpoints(src, norm, cameramatrix, distco);      (int p = 0; p<newkeypoints.size(); p++){        printf("%f, %f \n",norm.at<vec2f>(0,p)[0], norm.at<vec2f>(0,p)[1]);     } 

the value printed "nan, nan". tried using norm std::vector, returned same thing. values of src, cameramatrix, , distco remain unchanged after method called (i tested printing out values), confident giving undistortpoints correct information. using cv::mat incorrectly, using poor form, or bug opencv. insight on here appreciated.

isaac

if want matrix store double precision values need declare

cv::mat your_matrix(rows,cols,cv_64fc1); 

you haven't done both cameramatrix , distco matrices. trying access 32 bit elements of these arrays 64 bit accessor.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -