Ask Your Question

Silex's profile - activity

2018-10-13 17:36:46 -0500 received badge  Notable Question (source)
2018-01-07 09:03:07 -0500 received badge  Notable Question (source)
2017-01-11 09:13:49 -0500 received badge  Popular Question (source)
2016-03-18 17:28:22 -0500 received badge  Popular Question (source)
2012-10-15 03:32:40 -0500 received badge  Supporter (source)
2012-10-15 03:32:08 -0500 commented answer How to calculate the distance from the camera origin to any of the corners? (square chessboard calibration)

Thank you for your answer! If not a chessboard what would you use? I would like to care about the angle because the robot can stand anywhere in the room.

2012-10-09 09:55:40 -0500 asked a question solvePNP() - Assertion failed

Hello!

I am trying to get the pose of the camera with the help of solvePNP().

After running my program I get the following errors:

OpenCV Error: Assertion failed (0 <= i && i < (int)vv.size()) in getMat, file /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/OpenCV-2.4.2/modules/core/src/matrix.cpp, line 971
libc++abi.dylib: terminate called throwing an exception

I tried to search how to solve these errors, but I couldn't resolve it unfortunately!

Here is my code, all comment/help is much appreciated:

enum Pattern { NOT_EXISTING, CHESSBOARD, CIRCLES_GRID, ASYMMETRIC_CIRCLES_GRID };

void calcBoardCornerPositions(Size boardSize, float squareSize, vector<Point3f>& corners,
                          Pattern patternType)
{
    corners.clear();

switch(patternType)
{
case CHESSBOARD:
case CIRCLES_GRID:
    for( int i = 0; i < boardSize.height; ++i )
        for( int j = 0; j < boardSize.width; ++j )
            corners.push_back(Point3f(float( j*squareSize ), float( i*squareSize ), 0));
    break;

case ASYMMETRIC_CIRCLES_GRID:
    for( int i = 0; i < boardSize.height; i++ )
        for( int j = 0; j < boardSize.width; j++ )
            corners.push_back(Point3f(float((2*j + i % 2)*squareSize), float(i*squareSize), 0));
    break;
}

}

int main(int argc, char* argv[])
{
    float squareSize = 50.f;

Pattern calibrationPattern = CHESSBOARD;

vector<Point2f> boardCorners;
vector<vector<Point2f> > imagePoints;
vector<vector<Point3f> > boardPoints(1);

Size boardSize;
boardSize.width = 9;
boardSize.height = 6;

vector<Mat> intrinsics, distortion;
string filename = "out_camera_xml.xml";
FileStorage fs(filename, FileStorage::READ);
fs["camera_matrix"] >> intrinsics;
fs["distortion_coefficients"] >> distortion;
fs.release();

vector<Mat> rvec, tvec;
Mat img = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE); // at kell adnom egy kepet

bool found = findChessboardCorners(img, boardSize, boardCorners, CV_CALIB_CB_ADAPTIVE_THRESH);

calcBoardCornerPositions(boardSize, squareSize, boardPoints[0], calibrationPattern);
boardPoints.resize(imagePoints.size(),boardPoints[0]);

solvePnP(boardPoints, boardCorners, intrinsics, distortion, rvec, tvec);

for(int i=0; i<rvec.size(); i++) {
        cout << rvec[i] << endl;
}

return 0;

}

2012-10-09 01:44:27 -0500 received badge  Student (source)
2012-10-05 08:22:26 -0500 asked a question How to calculate the distance from the camera origin to any of the corners? (square chessboard calibration)

Hello!

I am kind of new to OpenCV and I was trying out the tutorials in the OpenCV tutorial sections - by the way really good tutorials, thx for the authors.

The reason I started to trying out the tutorials, so I can get a little familiar with OpenCV. I have a project going on with a humanoid robot where I want to use OpenCV and try out some cool things.

I already calibrated the robots camera thx to the OpenCV tutorials. I read both the calibration tutorials to get as much info about it as I can. At the end of this one there is a question (the same question what my topic has).

Is there an answer to it somewhere, or is there somebody who could answer it?

I would really appreciate it, because than I could use the chessboard for calibrating, image detecting, and for distance measurements!

I realize I can't do everything with a help of a chessboard, but for starter, and as a beginner it would help me a lot!

Parameters I have:

  • The robots camera resolution
  • The size of the chessboard (including the distance between the squares)
  • The robots height