Ask Your Question

Revision history [back]

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

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?