cvCalibrateCamera2 - problem

cvCalibrateCamera2 - problem

i've got a severe problem with cvcalibrate2...

maybe one of you can help me...

i've got a correspondence list where coordinates of my 3D calibration
rig are assigned to 2d image coordinates...

when i call cvcalibrate2 i receive an Bas argument exception...
it says that for non-planar calibration rigs i had to specify an
initial intrinsic matrix... that's funny because I specified it (as
you can see in the code...)

Can anybody imagine what I'm doing wrong ?

#include 
#include 
#include 
#include 
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
using namespace std;
void main (void) {
ifstream infile;
infile.open ("correspondence_list1_mikeda.txt", ifstream::in);
int x,y,z,n1,n2,n3,u,v;
vector modelPointArrX;
vector modelPointArrY;
vector modelPointArrZ;
vector imagePointArrX;
vector imagePointArrY;
while (!infile.eof()) {
infile >> x;
infile >> y;
infile >> z;
infile >> u;
infile >> v;
infile >> n1;
infile >> n2;
infile >> n3;
modelPointArrX.push_back(x);
modelPointArrY.push_back(y);
modelPointArrZ.push_back(z);
imagePointArrX.push_back(u);
imagePointArrY.push_back(v);
}
infile.close();
CvMat* pModelPoints = cvCreateMat(modelPointArrX.size(), 3, CV_64FC1);
CvMat* pImagePoints = cvCreateMat(imagePointArrX.size(), 2, CV_64FC1);
CvMat* pPointCounts = cvCreateMat(1, 1, CV_32SC1);
CvMat* pIntrinsicMat = cvCreateMat(3, 3, CV_64FC1);
CvMat* pDistortionCoeffs = cvCreateMat(4, 1, CV_64FC1);
CvMat* rotation_vectors = cvCreateMat(1, 3, CV_64FC1);
CvMat* translation_vectors = cvCreateMat(1, 3, CV_64FC1);
CvSize size = cvSize(1536,512);
pPointCounts->data.i[0] = modelPointArrX.size();
cvmSet(pIntrinsicMat, 0, 0, 8.0); cvmSet(pIntrinsicMat, 0, 1,
0.0); cvmSet(pIntrinsicMat, 0, 2, 768.0);
cvmSet(pIntrinsicMat, 1, 0, 0.0); cvmSet(pIntrinsicMat, 1, 1,
8.0); cvmSet(pIntrinsicMat, 1, 2, 256.0);
cvmSet(pIntrinsicMat, 2, 0, 0.0); cvmSet(pIntrinsicMat, 2, 1,
0.0); cvmSet(pIntrinsicMat, 2, 2, 1.0);
for(int i = 0; i < modelPointArrX.size(); i++) {
cvmSet(pModelPoint
s, i, 0, modelPointArrX[i]);
cvmSet(pModelPoints, i, 1, modelPointArrY[i]);
cvmSet(pModelPoints, i, 2, modelPointArrZ[i]);
}
for(int i = 0; i < modelPointArrX.size(); i++) {
cvmSet(pImagePoints, i, 0, imagePointArrX[i]);
cvmSet(pImagePoints, i, 1, imagePointArrY[i]);
}
cvCalibrateCamera2(pModelPoints, pImagePoints, pPointCounts, size,
pIntrinsicMat, pDistortionCoeffs, rotation_vectors,
translation_vectors, 0);
//cvCalibrateCamera2(pModelPoints, pImagePoints, pPointCounts, size,
pIntrinsicMat, pDistortionCoeffs, rotation_vectors,
translation_vectors, CV_CALIB_USE_INTRINSIC_GUESS);
cout << "FocalLength_X : " << cvmGet(pIntrinsicMat, 0, 0) << endl;
cout << "FocalLength_Y : " << cvmGet(pIntrinsicMat, 1, 1) << endl;
cout << "PrincipalPoint_X : " << cvmGet(pIntrinsicMat, 0, 2) << endl;
cout << "PrincipalPoint_Y : " << cvmGet(pIntrinsicMat, 1, 2) << endl;
cout << "Radial Distortion 1 : " << cvmGet(pDistortionCoeffs, 0, 0)
<< endl;
cout << "Radial Distortion 2 : " << cvmGet(pDistortionCoeffs, 1, 0)
<< endl;
cout << "Tangential Distortion 1 : " << cvmGet(pDistortionCoeffs, 2,
0) << endl;
cout << "Tangential Distortion 2 : " << cvmGet(pDistortionCoeffs, 3,
0) << endl;
string inputFileName = "testimage.bmp" ;
string resultFileName = "testimage_undistorted.bmp" ;
// Open the source image
IplImage* pSourceImage = cvLoadImage(inputFileName.c_str(), -1);
if(pSourceImage == 0)
return ;
// Create destination image
IplImage* pDestinationImage = cvCloneImage(pSourceImage);
// Undistort image
cvUndistort2(pSourceImage, pDestinationImage, pIntrinsicMat,
pDistortionCoeffs);
cvSaveImage(resultFileName.c_str(), pDestinationImage);
cvReleaseImage(&pDestinationImage);
cvReleaseImage(&pSourceImage);
cvReleaseMat(&pDistortionCoeffs);
cvReleaseMat(&pIntrinsicMat);
cvReleaseMat(&pPointCounts);
cvReleaseMat(&pImagePoints);
cvReleaseMat(&pModelPoints);
_getch();
}
1 contribution / 0 nouveau(x)
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.