Incase you wanted further information, I used a tutorial from here to try this method of lens correction out from here:

http://www.aishack.in/2010/07/calibrating-undistorting-with-opencv-in-c-oh-yeah/

I seem to be getting this error when trying to build the code below. (it is all self contained so if you have openCV installed and linked etc you should see the same problem)

This is the error I get:
error C2664: 'cv::drawChessboardCorners' : cannot convert parameter 3 from 'std::vector<_Ty>' to 'const cv::Mat &'

seems to be pointing to line 48 (in this post)


Still very new to all of this so hopefully someone can help.

#include "stdafx.h"
#include <cv.h>
#include <highgui.h>

using namespace cv;
int main()
{
	int numBoards = 0;
    int numCornersHor;
    int numCornersVer;

	printf("Enter number of corners along width: ");
    scanf("%d", &numCornersHor);
 
    printf("Enter number of corners along height: ");
    scanf("%d", &numCornersVer);
 
    printf("Enter number of boards: ");
    scanf("%d", &numBoards);

	 int numSquares = numCornersHor * numCornersVer;
    Size board_sz = Size(numCornersHor, numCornersVer);

	VideoCapture capture = VideoCapture(0);

	vector<vector<Point3f>> object_points;
    vector<vector<Point2f>> image_points;

	 vector<Point2f> corners;
    int successes=0;

	 Mat image;
    Mat gray_image;
    capture >> image;

	 vector<Point3f> obj;
    for(int j=0;j<numSquares;j++)
        obj.push_back(Point3f(j/numCornersHor, j%numCornersHor, 0.0f));
	 while(successes<numBoards)
    {
  cvtColor(image, gray_image, CV_BGR2GRAY);

    bool found = findChessboardCorners(image, board_sz, corners, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);
 
        if(found)
        {
            cornerSubPix(gray_image, corners, Size(11, 11), Size(-1, -1), TermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 30, 0.1));
            drawChessboardCorners(gray_image, board_sz, corners, found);
        }
	  imshow("win1", image);
        imshow("win2", gray_image);
 
        capture >> image;
 
        int key = waitKey(1);

		 if(key==27)
            return 0;
 
        if(key==' ' && found!=0)
        {
            image_points.push_back(corners);
            object_points.push_back(obj);
            printf("Snap stored!\n");
 
            successes++;
 
            if(successes>=numBoards)
                break;
        }
    }
	 Mat intrinsic = Mat(3, 3, CV_32FC1);
    Mat distCoeffs;
    vector<Mat> rvecs;
    vector<Mat> tvecs;
		 intrinsic.ptr<float>(0)[0] = 1;
    intrinsic.ptr<float>(1)[1] = 1;
	calibrateCamera(object_points, image_points, image.size(), intrinsic, distCoeffs, rvecs, tvecs);
	Mat imageUndistorted;
    while(1)
    {
        capture >> image;
        undistort(image, imageUndistorted, intrinsic, distCoeffs);
 
        imshow("win1", image);
        imshow("win2", imageUndistorted);
 
        waitKey(1);
    }
	capture.release();
		return 0;
}

That error is pretty clear from a c++ perspective, the type of the paramter you are passing is a vector but the function is expecting a matrix. For more specifics you'd have to ask the OpenCV people.

anyone with OpenCV experience care to take a crack? really would like a fresh set of eyes to know whats going wrong here!

thanks

In case you are still having trouble, I believe you need to convert the corners to a matrix format by typecasting it corners =====> Mat(corners)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.