Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Can't use of cvCalibrateCamera2().

$
0
0
I'm trying to use of cvCalibrateCamera2() but i always have cv::Exception at memory location 0x0090F42C error. I have Visual Studio 2012 and OpenCV 2.4.6. When i install OpenCV 3.0.0, Visual Studio don't know cvCalibrateCamera2(). The code is here. #include #include #include #include void help(){ printf("\n\n" " Calling convention:\n" " ch11_ex11_1 board_w board_h number_of_boards skip_frames\n" "\n" " WHERE:\n" " board_w, board_h -- are the number of corners along the row and columns respectively\n" " number_of_boards -- are the number of chessboard views to collect before calibration\n" " skip_frames -- are the number of frames to skip before trying to collect another\n" " good chessboard. This allows you time to move the chessboard. \n" " Move it to many different locations and angles so that calibration \n" " space will be well covered. \n" "\n" " Hit ‘p’ to pause/unpause, ESC to quit\n" "\n"); } int n_boards = 0; //Will be set by input list int board_dt = 90; //Wait 90 frames per chessboard view int board_w; int board_h; int main(int argc, char* argv[]) { argc = 5; CvCapture* capture;// = cvCreateCameraCapture( 0 ); // assert( capture ); if(argc != 5){ printf("\nERROR: Wrong number of input parameters"); help(); return -1; } // board_w = atoi(argv[1]); // board_h = atoi(argv[2]); // n_boards = atoi(argv[3]); // board_dt = atoi(argv[4]); int board_n = board_w * board_h; CvSize board_sz = cvSize( board_w, board_h ); capture = cvCreateCameraCapture( 0 ); if(!capture) { printf("\nCouldn't open the camera\n"); help(); return -1;} cvNamedWindow( "Calibration" ); cvNamedWindow( "Raw Video"); //ALLOCATE STORAGE CvMat* image_points = cvCreateMat(n_boards*board_n,2,CV_32FC1); CvMat* object_points = cvCreateMat(n_boards*board_n,3,CV_32FC1); CvMat* point_counts = cvCreateMat(n_boards,1,CV_32SC1); CvMat* intrinsic_matrix = cvCreateMat(3,3,CV_32FC1); CvMat* distortion_coeffs = cvCreateMat(4,1,CV_32FC1); CvPoint2D32f* corners = new CvPoint2D32f[ board_n ]; int corner_count; int successes = 0; int step, frame = 0; IplImage *image = cvQueryFrame( capture ); IplImage *gray_image = cvCreateImage(cvGetSize(image),8,1);//subpixel // CAPTURE CORNER VIEWS LOOP UNTIL WE’VE GOT n_boards // SUCCESSFUL CAPTURES (ALL CORNERS ON THE BOARD ARE FOUND) // help(); while(successes < n_boards) { //Skip every board_dt frames to allow user to move chessboard if((frame++ % board_dt) == 0) { //Find chessboard corners: int found = cvFindChessboardCorners( image, board_sz, corners, &corner_count, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS ); //Get Subpixel accuracy on those corners cvCvtColor(image, gray_image, CV_BGR2GRAY); cvFindCornerSubPix(gray_image, corners, corner_count, cvSize(11,11),cvSize(-1,-1), cvTermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1 )); //Draw it cvDrawChessboardCorners(image, board_sz, corners, corner_count, found); // cvShowImage( "Calibration", image ); // If we got a good board, add it to our data if( corner_count == board_n ) { cvShowImage( "Calibration", image ); //show in color if we did collect the image step = successes*board_n; for( int i=step, j=0; j

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>