logo       

Camera Calibration: msg#00676

lib.opencv

Subject: Camera Calibration

I wrote the code for calibrate my camera, it seems to find the
chessboard but cvCalibrateCamera fills rotation matrix with identity
and the others with numbers not valid.
Anybody knows why?
Here's my
code, I append also my chessboard picture.
Thanks...

bool calibrate
(unsigned cam)
{
const char *name= "Grayscale image";


const int width= 5;
const int height= 6;

int npoints[]= {
width*height };

float distortion[4];
float homography[9];

float translation[3];
float rotation[9];

CvMat mat1, mat2;

static CvPoint2D32f img_point[width*height];
static
CvPoint3D32f obj_point[width*height]=
{
cvPoint3D32f(1.0,
1.0, 0.0),
cvPoint3D32f(2.0, 1.0, 0.0),
cvPoint3D32f
(3.0, 1.0, 0.0),
cvPoint3D32f(4.0, 1.0, 0.0),

cvPoint3D32f(1.0, 2.0, 0.0),
cvPoint3D32f(2.0, 2.0, 0.0),
cvPoint3D32f(3.0, 2.0, 0.0),
cvPoint3D32f(4.0, 2.0,
0.0),
cvPoint3D32f(1.0, 3.0, 0.0),
cvPoint3D32f(2.0,
3.0, 0.0),
cvPoint3D32f(3.0, 3.0, 0.0),
cvPoint3D32f
(4.0, 3.0, 0.0),
cvPoint3D32f(1.0, 4.0, 0.0),

cvPoint3D32f(2.0, 4.0, 0.0),
cvPoint3D32f(3.0, 4.0, 0.0),
cvPoint3D32f(4.0, 4.0, 0.0),
cvPoint3D32f(1.0, 5.0,
0.0),
cvPoint3D32f(2.0, 5.0, 0.0),
cvPoint3D32f(3.0,
5.0, 0.0),
cvPoint3D32f(4.0, 5.0, 0.0)
};

static
IplImage *gray= cvCreateImage(size, IPL_DEPTH_8U, 1);
static
IplImage *tmp= cvCreateImage(size, IPL_DEPTH_8U, 1);

cvCvtColor
(rgb, gray, CV_BGR2GRAY);

gray->origin= rgb->origin;


cvNamedWindow(name, 1);
cvShowImage(name, gray);

if
(cvFindChessBoardCornerGuesses(gray, tmp, 0,
cvSize(width,
height), img_point))
return false;

cvCalibrateCamera(1,
npoints, size, img_point, obj_point,
distortion, homography,
translation, rotation, 1);

cvSetIdentity(camera_mat[cam]);


mat1= cvMat(3, 3, CV_32FC1, rotation);
cvGetSubRect(camera_mat
[cam], &mat2, cvRect(0, 0, 3, 3));
cvCopy(&mat1, &mat2);


mat1= cvMat(3, 1, CV_32FC1, translation);
cvGetSubRect(camera_mat
[cam], &mat2, cvRect(3, 0, 1, 3));
cvCopy(&mat1, &mat2);


mat1= cvMat(3, 3, CV_32FC1, homography);
cvGetSubRect(camera_mat
[cam], &mat2, cvRect(0, 0, 4, 3));
cvMatMul(&mat1, &mat2, &mat2);

cvInvert(camera_mat[cam], camera_invmat[cam]);

trace
(camera_mat[cam]);
trace(camera_invmat[cam]);

return true;
}


[Non-text portions of this message have been removed]



Change settings: http://www.yahoogroups.com/mygroups, select
Get Emails (get all posts)
Daily Digest (one summary email per day)
Read on the web (read posts on the web only)Or Unsubscribe by mailing
OpenCV-unsubscribe@xxxxxxxxxxxxxxx



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise