Opencv single camera calibration problem. [closed]

asked 2018-02-24 00:49:00 -0600

baihualinxin gravatar image

The opencv 2.4 operation I used was not a problem, and opencv 3.4 was wrong. OpenCV Error: an Assertion failed (_dst fixedType ()) in convertPointsHomogeneous, file/Volumes/build - storage/build/master_iOS - MAC/OpenCV/modules/calib3d/SRC/fundam CPP, line 1029

CvCalibrateCamera2 parameters should be wrong, but I contrast comment, type is no problem.

int cube_length=8;
IplImage *show;
int number_image=7;
int a=1;
CvSize image_size; //Size of image
CvSize board_size=cvSize(8, 6);// Cvsize: one of the basic data types of OpenCV is to construct the function, width and height of the Cvsize type, indicating the size of the matrix box and the accuracy of pixels. Similar to the CvPoint structure, but the data members are the width and height of the integer type.
int board_width=board_size.width;
int board_height=board_size.height;
int total_per_image=board_width*board_height;//The total number of corners of each graph.
CvPoint2D32f * image_points_buf = new CvPoint2D32f[total_per_image];  //An array of stored angular coordinates.
CvPoint2D32f * corners=new CvPoint2D32f[total_per_image];//The angular points group of an image.

//Mainly used to transform into matrix form.CvMat* cvCreateMat( int rows, int cols, int type );Rows rows. Cols matrix columns. Type matrix element type, single-channel image of floating-point type.
// the type can be any predefined type, and the structure of the predefined type is as follows: CV_<bit_depth> (S|U|F)C<number_of_channels>.
CvMat * image_points=cvCreateMat(number_image*total_per_image,2,CV_32FC1); //The matrix of the image coordinates of the corner point.
CvMat * object_points=cvCreateMat(number_image*total_per_image,3,CV_32FC1); //The matrix that stores the world coordinates of the angular point.
CvMat * point_counts=cvCreateMat(number_image,1,CV_32SC1); //Stores the number of recognition points for each frame.
CvMat * intrinsic_matrix=cvCreateMat(3,3,CV_32FC1);
CvMat * distortion_coeffs=cvCreateMat(5,1,CV_32FC1);
int count; //Store the actual number of points in each frame.
int found; //Identify the mark bit of the calibrated plate corner and whether the corner point can be detected.
int step;  //Store the step length,step=successes*total_per_image;
int successes=0; //The image frame number initialization of all corner points on the calibration board is successfully found.


for (int K=1; K<7; K++) {
    UIImage *image=[UIImage imageNamed:[NSString stringWithFormat:@"%d",K]];
    //    UIImage *image=[UIImage imageNamed:@"2"];

    show=[self CreateIplImageFromUIImage:(image)];
    image_size=cvGetSize(show);//Size of image

    found=cvFindChessboardCorners(show,board_size,image_points_buf,&count,
                                  CV_CALIB_CB_ADAPTIVE_THRESH|CV_CALIB_CB_FILTER_QUADS);

    if(found==0){

    }else{

        IplImage * gray_image= cvCreateImage(cvGetSize(show),8,1); //Create headers and assign data to IplImage*.
        cvCvtColor(show,gray_image,CV_BGR2GRAY); // cvCvtColor(...),It is the color space conversion function in Opencv, which can realize the conversion of RGB color to HSV,HSI and other color space, and can also be converted to grayscale image.
        //Gets the subpixel corner.
        cvFindCornerSubPix(gray_image,image_points_buf,count,cvSize(11,11),cvSize(-1,-1),
                           cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,0.1));
        cvDrawChessboardCorners(show,board_size,image_points_buf,count,found);
        if(total_per_image==count){
            step=successes*total_per_image;
            //  for(int i=step,j=0;j<total_per_image;++i,++j)
            for (int j=0;j<total_per_image;j++)
            {
                //total_per_imageIs the total number of angles in an image.
                //Opencv is used to access matrix of each element in the macro ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by berak
close date 2018-02-24 01:39:12.198990

Comments

please have a look at current tutorials

you cannot use the c-based opencv1.0 api any more

berak gravatar imageberak ( 2018-02-24 01:45:09 -0600 )edit

CvMat How to turn InputArrayOfArrays

baihualinxin gravatar imagebaihualinxin ( 2018-02-24 02:07:49 -0600 )edit

don't use any of CvMat, IplImage* etc. that''s all dead and gone.

you'll have to use cv::Mat now (and probably re-learn all of opencv's c++ api)

berak gravatar imageberak ( 2018-02-24 02:09:30 -0600 )edit
1

Calibration is a one-time process. You can save the images and use the calibration.cpp sample to calibrate your camera.

Eduardo gravatar imageEduardo ( 2018-02-24 03:39:04 -0600 )edit

opencv 3.4 It's too complicated. It's not flexible.

baihualinxin gravatar imagebaihualinxin ( 2018-02-24 03:42:52 -0600 )edit

too late to complain.

berak gravatar imageberak ( 2018-02-24 03:50:22 -0600 )edit

There is no other decision. Now, opencv 3.4 is not allowed.

baihualinxin gravatar imagebaihualinxin ( 2018-02-24 04:04:55 -0600 )edit