Ask Your Question

Athanase's profile - activity

2013-12-23 07:05:24 -0600 commented question mat.hpp error: call to member function 'ptr' is ambiguous

Any ideas ?

2013-12-09 03:05:04 -0600 commented question mat.hpp error: call to member function 'ptr' is ambiguous

Nobody ????????????

2013-12-06 05:14:18 -0600 commented question mat.hpp error: call to member function 'ptr' is ambiguous

Yes still the same !

2013-12-06 05:00:54 -0600 received badge  Student (source)
2013-12-06 04:49:16 -0600 asked a question mat.hpp error: call to member function 'ptr' is ambiguous

Hi there, I have an error when I compile my program that uses OpenCV just by including #include <opencv2/core/core.hpp>, which is:

In file included from /usr/local/include/opencv2/core/core.hpp:4826:
/usr/local/include/opencv2/core/mat.hpp:2212:37: error: call to member function 'ptr' is ambiguous
{ return *(_Tp*)((SparseMat*)this)->ptr(i0, true, hashval); }
            ~~~~~~~~~~~~~~~~~~~~^~~
/usr/local/include/opencv2/core/core.hpp:3507:12: note: candidate function
    uchar* ptr(int i0, bool createMissing, size_t* hashval=0);
       ^
/usr/local/include/opencv2/core/core.hpp:3509:12: note: candidate function
    uchar* ptr(int i0, int i1, bool createMissing, size_t* hashval=0);
       ^
/usr/local/include/opencv2/core/core.hpp:3513:12: note: candidate function not viable: no known    conversion from 'int' to 'const int *' for 1st argument; take the address of the argument with &
    uchar* ptr(const int* idx, bool createMissing, size_t* hashval=0);
       ^
/usr/local/include/opencv2/core/core.hpp:3511:12: note: candidate function not viable: requires at least 4 arguments, but 3 were provided
uchar* ptr(int i0, int i1, int i2, bool createMissing, size_t* hashval=0);
       ^

I configured and compiled OpenCV 2.4.7 with the following option: cmake -DCMAKE_C_FLAGS=-m64 -DCMAKE_CXX_FLAGS="-m64 -Wno-c++11-narrowing -std=c++11" -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_BUILD_TYPE=Debug ...

I use Linux (ubuntu 13.04) and I use clang 3.2-1.

Thanks for the answers !

2013-06-23 10:27:13 -0600 answered a question Assertion while trying to calibrate stereo system

std::vector should be passed instead of CLVector.

2013-06-22 07:19:30 -0600 commented question Assertion while trying to calibrate stereo system

Hahahahahah. At first I was like "this is not a really useful answer." But I was wrong ! I should learn to be more respectful about the answers people give. There is the reason: CLVector is a vector class that derives from std::vector without any additional functionality for now. I don't know why but this function accept the std::vector but not the homemade wrapper (I need to look deeper in the code why). So thank you very much for this useful answer.

2013-06-21 12:05:52 -0600 commented question Assertion while trying to calibrate stereo system

I already know that it comes from stereoCalibrate.

2013-06-21 10:02:24 -0600 received badge  Editor (source)
2013-06-21 09:53:35 -0600 asked a question Assertion while trying to calibrate stereo system

Hi all, I haven't touch OpenCV for a while so I am a bit rusty. I am trying to calibrate a stereo system using some code from an OpenCV2.4 example.

Here is the relevant code:

if( imagePoints1_[0].size() < nbrOfSample_ )
{
    int found1 {0}, found2 {0};  // Stores the result of the function to find corners
    cv::Size cvBoardSize {squareW_, squareH_};  // Size of the board in square

    cv::Mat imgMat1( origin1_ );
    cv::Mat imgMat2( origin2_ );
    cv::Mat cimg1;
    cv::Mat cimg2;

    cv::cvtColor( imgMat1, cimg1, CV_BGR2GRAY );
    cv::cvtColor( imgMat2, cimg2, CV_BGR2GRAY );

    found1 = cv::findChessboardCorners( cimg1, cvBoardSize, corners1_,
                                        CV_CALIB_CB_ADAPTIVE_THRESH |
                                        CV_CALIB_CB_NORMALIZE_IMAGE );

    found2 = cv::findChessboardCorners( cimg2, cvBoardSize, corners2_,
                                        CV_CALIB_CB_ADAPTIVE_THRESH |
                                        CV_CALIB_CB_NORMALIZE_IMAGE );
    if( found1 && found2 )
    {
        cv::cornerSubPix( cimg1, corners1_, cvSize(11, 11), cvSize(-1, -1),
                          cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,
                                         30, 0.01) );

        cv::cornerSubPix( cimg2, corners2_, cvSize(11, 11), cvSize(-1, -1),
                          cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,
                                         30, 0.01) );

        cv::drawChessboardCorners( imgMat1, cvBoardSize, corners1_, found1 );
        cv::drawChessboardCorners( imgMat2, cvBoardSize, corners2_, found2 );

        if( takeSample_ )   // The user asked to take a sample
        {
            // The number of corners found in correct
            if( true/*(nbrCornersL == nbrOfSquare_) && (nbrCornersR == nbrOfSquare_)*/ )
            {
                imagePoints1_[0].push_back( corners1_ );
                imagePoints1_[1].push_back( corners2_ );

                cout << "Sample acquired (" << imagePoints1_[0].size() << "/" <<
                          nbrOfSample_ << ")" << endl;
            }
            // else
            //    CL_PRINT( "Bad sample, start again ..." );
            takeSample_ = false;
        }
    }
    cv::imshow( "Calibration image1", imgMat1 );
    cv::imshow( "Calibration image2", imgMat2 );
}
else
{
    CLVector<CLVector<cv::Point3f>> objectPoints;

    imagePoints1_[0].resize( nbrOfSample_ );
    imagePoints1_[1].resize( nbrOfSample_ );
    objectPoints.resize( nbrOfSample_ );
    cv::Size imageSize {width_, height_};

    for( int i = 0; i < nbrOfSample_; i++ )
    {
        for( int j = 0; j < squareH_; j++ )
            for( int k = 0; k < squareW_; k++ )
                objectPoints[i].push_back( cv::Point3f(j*squareSize_, k*squareSize_, 0) );
    }

    std << imagePoints1_[0].size() << endl;
    std <<  imagePoints1_[0].front().size() << endl;
    std <<  imagePoints1_[1].size() << endl;
    std <<  imagePoints1_[1].front().size() << endl;
    std <<  objectPoints.size() << endl;
    std <<  objectPoints.front().size() << endl;

    std << "Running stereo calibration ..." << endl;

    cv::Mat cameraMatrix[2], distCoeffs[2];
    cameraMatrix[0] = cv::Mat::eye( 3, 3, CV_64F );
    cameraMatrix[1] = cv::Mat::eye( 3, 3, CV_64F );
    cv::Mat R, T, E, F;

    double rms = cv::stereoCalibrate( objectPoints,
                                      imagePoints1_[0], imagePoints1_[1],
                                      cameraMatrix[0], distCoeffs[0],
                                      cameraMatrix[1], distCoeffs[1],
                                      imageSize, R, T, E, F,
                                      cv::TermCriteria(
                                          CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,
                                          100, 1e-5),
                                      CV_CALIB_FIX_ASPECT_RATIO +
                                      CV_CALIB_ZERO_TANGENT_DIST +
                                      CV_CALIB_SAME_FOCAL_LENGTH +
                                      CV_CALIB_RATIONAL_MODEL +
                                      CV_CALIB_FIX_K3 + CV_CALIB_FIX_K4 +
                                      CV_CALIB_FIX_K5 );

}

This method is called in a loop that grabs the images. So if I don't have enough samples (20) It keeps going, otherwise I go through the calibration process.

Knowing that the important members are:

int width_;
int height_;
const int squareW_;
const int squareH_;
const float squareSize_;
const int nbrOfSample_;
IplImage* origin1_;
IplImage* origin2_;
CLVector<cv::Point2f> corners1_;
CLVector<cv::Point2f> corners2_;
CLVector<CLVector<cv::Point2f>> imagePoints1_[2];

The program crashes and says:

OpenCV Error: Assertion failed (i < 0) in getMat, file /build/buildd/opencv-2.4.2+dfsg/modules/core/src/matrix.cpp, line 957
terminate called after throwing an instance of 'cv::Exception'
what():  /build/buildd/opencv-2.4.2+dfsg/modules/core/src/matrix.cpp:957: error: (-215) i < 0 in function getMat

This is still work in progress, so I apologize if there is ... (more)