Ask Your Question
0

vector parameter crashes in goodFeaturesToTrack when using 64bit libraries(window 7, Visual studio 10)

asked 2014-06-03 01:15:09 -0500

Hello,

Here is my question :

I just tried to run optical flow example code, but the program crashed in goodFeaturesToTrack function, so I figured out that the source code runs well when using OpenCV libraries for 32-bit, but crashes when using OpenCV libraries for 64-bit in the same computer(64-bit CPU).

more specifically,

At this line in the goodFeaturesToTrack function crashes.

Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F);

My own source code is this

int main(){
    IplImage *img = cvLoadImage(".\\samples\\image.jpg");
    if (!img) {
        printf("Error: Couldn't open the image file.\n");
        return 1;
    }
    Mat image(img);
    Mat gray;
    cvtColor(image, gray, CV_BGR2GRAY);

    Mat cvCorner=image.clone();
    vector<Point2f> corners;

    goodFeaturesToTrack(gray, corners, 500, 0.1, 10, Mat(), 3, false, 3);
    cout<<corners.size()<<endl;
    if (!corners.empty()){
        size_t sizeOfCorners = corners.size();
        for(int i=0; i < sizeOfCorners ; i++){
            circle(cvCorner, corners[i], 5, Scalar(0, 255, 0));
        }
    }
    imshow("cvCorner", cvCorner);

    waitKey(0);
    return 0;
}

Thus, I tried many thing to figure out, I doubted OutputArray which is wrapper class for emitting "corners",

so I made my own code in OpenCV project by replacing "OutputArray _corners" with "vector<point2f> &_corners" as a parameter in "goodFeaturesToTrack", and add this code below at the end of the function insted of " Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F);" which is crashed.

for ( int gsindex = 0; gsindex < (int)corners.size(); gsindex++ )
{
    _corners.push_back(corners.at(gsindex));
}

My own code ran well when I put the code into my project, but still crashes when I use my own source code in OpenCV libraries by putting the code into OpenCV project building it(i.e. I added my source code into OpenCV project, build it, and used new lib, dll files)

I thought the parameter in goodFeaturesToTrack was not the problem, so I tried to run the same source code with 32-bit libraries, and It ran well.

I think I should conclude that there is some problem in 64-bit libraries because I can run the source code using original OpenCV libraries(using original goodFeaturesToTrack function) with 32-bit things, and cannot with 64-bit things.

Is there anyone who ran the function, goodFeaturesToTrack, using 64-bit libraries in the same way I did?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-07-28 09:01:18 -0500

Alejandro Silvestri gravatar image

Hi, I'm trying goodFeaturesToTrack in Ubuntu & opencv 64 bits, it works ok. I use vector<point2f> corners like you. The main difference, I'm not using last 4 parameters (Mat(), 3, false, 3), I leave them to default values, because unlike you I don't need them.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2014-06-03 01:15:09 -0500

Seen: 481 times

Last updated: Jul 28 '14