Ich spiele mit cv :: Mat herum und denke, dass mein Code sich wirklich merkwürdig verhält, obwohl ich der Syntax folge, die in here beschrieben wird.Warum werden die Matrizen nicht korrekt initialisiert/gedruckt?
Code:
std::cout << "parameter for matrices: " << "x = " << X << " y = " << Y << " psi = " << Psi << std::endl;
double dataRot[] = { cos(Psi), -sin(Psi), sin(Psi), cos(Psi) };
double dataTrans[] = { X, Y };
cv::Mat matRot(2, 2, CV_32FC1, dataRot);
cv::Mat matTrans(2, 1, CV_32FC1, dataTrans);
std::cout << "matRot = " << matRot.at<double>(0,0) << "," << matRot.at<double>(0,1) << ";" << matRot.at<double>(1,0) << "," << matRot.at<double>(1,1) << std::endl;
std::cout << "matRot = " << matRot << std::endl;
std::cout << "matTrans = " << matTrans.at<double>(0,0) << "," << matTrans.at<double>(0,1) << std::endl;
std::cout << "matTrans = " << matTrans << std::endl;
matOut = matRot*matIn + matTrans*cv::Mat::ones(1, matIn.cols, CV_32FC1);
Ausgang:
parameter for matrices: x = 20.5 y = 20 psi = 0
matRot = 1,-0;-0,0
matRot = [0, 1.875;
0, -0]
matTrans = 20.5,20
matTrans = [0; 2.8203125]
Warum ist die Identitätsmatrix nicht korrekt initialisiert? Und warum liefert die zweite Art, eine Matrix zu drucken, falsche Ergebnisse? Jede Hilfe wird geschätzt.
Ist kein CV_32FC1 ein Floating-Point-Format (nicht doppelt)? – Thomas
Ich würde vermuten, dass die "32" 32 Bits bedeutet. Was in der Praxis bedeuten würde "float", nicht "double". OpenCV ist keine sehr typsichere Bibliothek. –