openCv Posit 関数でカメラの焦点距離を使用するたびに、すべての値に対して NaN を取得しますが、より高い値を使用すると、このエラーは発生しません (ただし、その数値は正しくありません)。モデルとしてピラミッドがあります。1 つの平面に 3 点、上の中央に 1 点。誰でもこれを処理する方法を知っていますか? またはいくつかの良いリンク?
int depth = -18;
//create the model points
std::vector<CvPoint3D32f> modelPoints;
modelPoints.push_back(cvPoint3D32f( 0.0f, 0.0f, 0.0f)); //(the first must be 0,0,0) middle center diod
modelPoints.push_back(cvPoint3D32f(-18.0f, -30.0f, depth)); //bottom left diode
modelPoints.push_back(cvPoint3D32f( 18.0f, -30.0f, depth)); //bottom right diode
modelPoints.push_back(cvPoint3D32f( 0.0f, 30.0f, depth)); //top center diode
system("cls");
//create the image points
std::vector<CvPoint2D32f> srcImagePoints;
cout << "Source Image Points:" << endl;
for( size_t i = 0; i < circles.size(); i++ )
{
cout << "x: " << cvRound(circles[i][0]) << " y: " << cvRound(circles[i][1]) << endl;
//228, 278
//291, 346 (Pixel coordinates of the points on the image)
//371, 346
//228, 206
srcImagePoints.push_back( cvPoint2D32f(cvRound(circles[i][0]), cvRound(circles[i][1])) );
}
cout << endl;
//create the POSIT object with the model points
CvPOSITObject* positObject = cvCreatePOSITObject( &modelPoints[0], (int)modelPoints.size() );
//calculate the orientation
float* rotation_matrix = new float[9];
float* translation_vector = new float[3];
CvTermCriteria criteria = cvTermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 100, 1.0e-4f);
double FOCAL_LENGTH = 16; //16.0; //760.0;
cvPOSIT( positObject, &srcImagePoints[0], FOCAL_LENGTH, criteria, rotation_matrix, translation_vector );
//calculate rotation angles
double beta = atan2((double)(-rotation_matrix[2]), (double)(sqrt(pow(rotation_matrix[0], 2) + pow(rotation_matrix[3], 2))));
double alpha = atan2((rotation_matrix[3]/cos(beta)),(rotation_matrix[0]/cos(beta)));
double gamma = atan2((rotation_matrix[7]/cos(beta)),(rotation_matrix[8]/cos(beta)));