Ask Your Question

Error: fundamental matrix size overgrowing to 3x9

asked 2016-02-24 02:55:59 -0500

rookie gravatar image

updated 2016-02-24 03:08:26 -0500

I am trying to find the fundamental matrix by manually identifying 7 corresponding points in two images and using the findFundamentalMatrix function. However on printing the matrix, it turns out to be 3x9. Seems to be a bug in my code but I cant figure it out.

void mouseEventOne(int event, int x, int y, int, void* param){
 //select points in first image. store in one.

void mouseEventTwo(int event, int x, int y, int, void* param) {
//select points in second image. store in two.
  set flag after 7 points

int main(int argc, char** argv) {

setMouseCallback("ImageOne", mouseEventOne, (void *) &ptOne);
setMouseCallback("ImageTwo", mouseEventTwo, (void *) &ptTwo);

for(;;) {

    if(one.size() == 7 && two.size() == 7 && flag){
        F = findFundamentalMat(one, two, CV_FM_7POINT);
        flag = false;

    imshow("ImageOne", imageOne);
    imshow("ImageTwo", imageTwo);

    char s = (char)waitKey(30);
        case 'q':
            return 0;

Example of F that I get:

[-1.551177784481965e-05, 2.023178297273342e-05, 0.0005375762557272776;
 -1.135972383318399e-05, 3.375254552474079e-05, -0.003613682804598734;
 0.008327856564262326, -0.01695104159607208, 1;
 4.431840798641267e-07, -1.055708293644028e-06, -2.507080893426536e-05;
 4.638855327440553e-06, 4.121047291061634e-06, -0.003793250696015148;
 -0.001440166620559569, -0.000516116119040233, 1;
 -2.981211382612034e-06, 3.513201920256684e-06, 9.568949524556974e-05;
 1.205098346864506e-06, 1.048082229878526e-05, -0.003754710242238103;
 0.0006563331661128546, -0.004043525616809762, 1]
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2016-02-24 03:35:05 -0500

Eduardo gravatar image

If you look at the documentation of cv::findFundamentalMat, you have the following explanation:

The function calculates the fundamental matrix using one of four methods listed above and returns the found fundamental matrix. Normally just one matrix is found. But in case of the 7-point algorithm, the function may return up to 3 solutions ( 9×3 matrix that stores all 3 matrices sequentially).

edit flag offensive delete link more


Oh yes, it does say so. My bad - should've gone through the documentation. Thanks!

rookie gravatar imagerookie ( 2016-02-24 03:54:28 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-02-24 02:55:59 -0500

Seen: 59 times

Last updated: Feb 24 '16