Camera Calibration Problem

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Camera Calibration Problem

Mahmoud A.Hamed
I¢m new to
OpenCV, and I was trying after I¢ve made a corner detection, I¢ve tried to make
a camera calibration using chessboard.
My code is the
code below and a strange problem appears when I try to run it, the
object_points which must be a nx3 matrix is said to be a bad argument, and obeying
to the demand of the VS,I¢ve made the distortion_coeffs to 4x1 which isn¢t
mathimatically true.
I was wondering
if any one can help me with that problem, I¢ve really spend a lot of time to
solve that but all in vain.
 
Thanks in
Advance.
 
CODE:
 
#include"stdafx.h"
#include"cv.h"
#include"highgui.h"
usingnamespace std;
////////////////////////////////////////////////////////////////////
voidmain ()
{
      IplImage *img = cvLoadImage("D:\\TestImage.jpg");
////////////////////////////object/////////////////////////////////
      CvMat *object_points = cvCreateMat(54,3,CV_32FC1);
      int p = 0;
      for (int z = 0; z < 6; z++)// to fill the object_points(X,Y,Z=0)
      {
            for (int x = 0; x < 9; x++)
            {
                  CV_MAT_ELEM(*object_points,float,p,0)
= x * 3;
                  CV_MAT_ELEM(*object_points,float,p,1)
= z * 3;
                  CV_MAT_ELEM(*object_points,float,p,2)
= 0.0f;
                  p ++;
            }
      }
////////////////////////////image
& corners/////////////////////////
      int x=0;
      CvPoint2D32f* corners= new CvPoint2D32f[ 54 ];// number of corners = 54 from the
image
      int y=cvFindChessboardCorners(img,cvSize(9,6),corners);
      cvDrawChessboardCorners(img,cvSize(9,6),corners,x,y);
      CvMat *image_points = cvCreateMat(54,2,CV_32FC1);
      for (int i = 0; i < 54; i++)// tofill the image_points with
corner points
      {
            CV_MAT_ELEM(*image_points,float,i,0)
= corners[i].x;
            CV_MAT_ELEM(*image_points,float,i,1)
= corners[i].y;
      }
/////////////////////////////count///////////////////////////////////
      CvMat *points_count = cvCreateMat(1,1,CV_32SC1);// include the size of image (width * hight)
      CV_MAT_ELEM(*points_count,float,0,0)
= img->width*img->height;
///////////////////////////Intrinsic
& distortion////////////////////
      CvMat *intrinsic_matrix = cvCreateMat(3,3,CV_32FC1);
      CvMat* distortion_coeffs = cvCreateMat(4,1,CV_32FC1);
///////////////////////////Calibration///////////////////////////////
      cvCalibrateCamera2(object_points,image_points,points_count,cvSize(img->width,img->height),intrinsic_matrix,distortion_coeffs,NULL/*Rotation mat.*/,NULL/*Translation
mat.*/,CV_CALIB_USE_INTRINSIC_GUESS);
      cvNamedWindow("hey");
      cvShowImage("hey",img);
      cvWaitKey(0);
}


     

[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 [hidden email]
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/OpenCV/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/OpenCV/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[hidden email]
    mailto:[hidden email]

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Loading...