Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

StereoRectifyUncalibrated "cannot solve under-determined linear system"

Hi all

I'm using cv2.stereoRectifyUncalibrated to try and calculate the appropriate rectification transformation between two sets of artificial correspondences:

    import cv2
    import cv2.cv as cv
    import numpy as np

    pts1 = [[423, 191],  # top_l
            [840, 217],  # top_r
            [422, 352],  # bot_l
            [838, 377],  # bot_r
            [325, 437],  # front_l
            [744, 464],  # front_r
            [288, 344],  # wide_l
            [974, 388]]  # wide_r

    pts2 = [[423, 192],  # top_l
            [841, 166],  # top_r
            [422, 358],  # bottom_l
            [839, 330],  # bottom_r
            [518, 440],  # front_l
            [934, 417],  # front_r
            [287, 363],  # wide_l
            [973, 320]]  # wide_r

    pts1 = np.array(pts1, dtype='f4')
    pts2 = np.array(pts2, dtype='f4')

    f, mask = cv2.findFundamentalMat(pts1, pts2, cv2.cv.CV_FM_8POINT)

    pts1_r = pts1.reshape((pts1.shape[0] * 2, 1))
    pts2_r = pts2.reshape((pts2.shape[0] * 2, 1))

    ret, H1, H2 = cv2.stereoRectifyUncalibrated(pts1_r, pts2_r, f, (1280, 720))

    print ret

I've included the data initialisation just to illustrate the array structure. You'll see I've avoided the assertion error mentioned in this discussion using reshape.

However, I now get the following error:

OpenCV Error: Bad argument (The function can not solve under-determined linear systems) in solve, file /tmp/opencv20150527-4924-hjrvz/opencv-2.4.11/modules/core/src/lapack.cpp, line 1350

Out of context, the offending snippet looks like this:

int m = src.rows, m_ = m, n = src.cols, nb = _src2.cols;
...
if( m < n )
    CV_Error(CV_StsBadArg, "The function can not solve under-determined linear systems" );

Where m and n are the number of rows and columns in 'inputArray' - supplied to cv::solve by cvsolve, and created somewhere in StereoRectifyUncalibrated.

My question is simply: what is going on here? I'm struggling to see how my artificial data could be responsible for the system being solved to be under-determined.

StereoRectifyUncalibrated "cannot solve under-determined linear system"

Hi all

I'm using cv2.stereoRectifyUncalibrated to try and calculate the appropriate rectification transformation between two sets of artificial correspondences:

    import cv2
    import cv2.cv as cv
    import numpy as np

    pts1 = [[423, 191],  # top_l
            [840, 217],  # top_r
            [422, 352],  # bot_l
            [838, 377],  # bot_r
            [325, 437],  # front_l
            [744, 464],  # front_r
            [288, 344],  # wide_l
            [974, 388]]  # wide_r

    pts2 = [[423, 192],  # top_l
            [841, 166],  # top_r
            [422, 358],  # bottom_l
            [839, 330],  # bottom_r
            [518, 440],  # front_l
            [934, 417],  # front_r
            [287, 363],  # wide_l
            [973, 320]]  # wide_r

    pts1 = np.array(pts1, dtype='f4')
    pts2 = np.array(pts2, dtype='f4')

    f, mask = cv2.findFundamentalMat(pts1, pts2, cv2.cv.CV_FM_8POINT)

    pts1_r = pts1.reshape((pts1.shape[0] * 2, 1))
    pts2_r = pts2.reshape((pts2.shape[0] * 2, 1))

    ret, H1, H2 = cv2.stereoRectifyUncalibrated(pts1_r, pts2_r, f, (1280, 720))

    print ret

I've included the data initialisation just to illustrate the array structure. You'll see I've avoided the assertion error mentioned in this discussion using reshape.

However, I now get the following error:

OpenCV Error: Bad argument (The function can not solve under-determined linear systems) in solve, file /tmp/opencv20150527-4924-hjrvz/opencv-2.4.11/modules/core/src/lapack.cpp, line 1350

Out of context, the offending snippet looks like this:

int m = src.rows, m_ = m, n = src.cols, nb = _src2.cols;
...
if( m < n )
    CV_Error(CV_StsBadArg, "The function can not solve under-determined linear systems" );

Where m and n are the number of rows and columns in 'inputArray' - supplied to cv::solve by cvsolve, and created somewhere in StereoRectifyUncalibrated.

My question is simply: what is going on here? I'm struggling to see how my artificial data could be responsible for the system being solved to be under-determined.