Ask Your Question
0

Surf feature Run-time error

asked 2013-07-02 12:01:30 -0500

FLY gravatar image

updated 2013-07-02 15:48:45 -0500

I am doing code for feature extraction using SURF , but it give me run-time error in it , i don't think so it's error in program but here it is

#pragma comment (lib , "opencv_core244d.lib")
#pragma comment (lib ,"opencv_highgui244d.lib")
#pragma comment(lib , "opencv_imgproc244d.lib") 
#pragma comment(lib ,"opencv_video244d.lib")
#pragma comment(lib ,"opencv_features2d244d.lib")
#pragma comment(lib ,"opencv_nonfree244d.lib")
using namespace cv ;


int main(int argc, char *argv[])
{
    initModule_nonfree();
    Mat image1, outImg1, image2, outImg2;


    vector<KeyPoint> keypoints1, keypoints2;


    image1 = imread("1.jpg",0);
    image2 = imread("2.jpg",0);

    SurfFeatureDetector surf(2500);
    surf.detect(image1, keypoints1);
    surf.detect(image2, keypoints2);
    drawKeypoints(image1, keypoints1, outImg1, Scalar(255,255,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
    drawKeypoints(image2, keypoints2, outImg2, Scalar(255,255,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);

    namedWindow("SURF detector img1");
    imshow("SURF detector img1", outImg1);

    namedWindow("SURF detector img2");
    imshow("SURF detector img2", outImg2);

    SurfDescriptorExtractor surfDesc;
    Mat descriptors1, descriptors2;
    surfDesc.compute(image1, keypoints1, descriptors1);
    surfDesc.compute(image2, keypoints2, descriptors2);

    cv::waitKey();
    return 0;
}

Error: It give me the option of Continue or Break and also the following Dos screen appears image description

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-07-02 13:53:47 -0500

berak gravatar image

[answer to updated code]

tried your code, and the answer is simple: it just did not find one (or both) of your images.

(amazing, that it made it past the detection stage like this)

so, whenever you load external resources, check them, please !

image1 = imread("1.jpg",0);
if ( image1.empty() )
{ 
    cerr << "bad image : " << "1.jpg" << " !" <<  endl;
    return 1;
}
// same for image2, ofc.

if you use a path like "1.jpg", that assumes, the image is in the same folder, where your program starts (the debug folder ?)

using an absolute path like "c:/lala/lalalala/1.jpg" avoids that situation

edit flag offensive delete link more
1

answered 2013-07-02 12:20:09 -0500

berak gravatar image

that's a funny way, specifying link-libs via #pragma, ;)

  1. you're missing opencv_features2d244d.lib ( and for SURF, probably opencv_nonfree244d.lib, too )
  2. please also include #include "opencv2/features2d/nonfree.hpp" and add cv::initModule_nonfree(); as first line in main, SIFT ans SURF are non-free.
  3. you need 2 #pragma blocks, one for debug, another for release (you can't run a debug build with release dlls, and vice versa)

#ifdef DEBUG
 #pragma comment (lib , "opencv_core244d.lib")
 #pragma comment (lib ,"opencv_highgui244d.lib")
 //... more libs
#else
 // same libs, but without "d" at the end:
 #pragma comment (lib , "opencv_core244.lib")
 #pragma comment (lib ,"opencv_highgui244.lib")
 //... more libs
#endif
edit flag offensive delete link more

Comments

I did it on my own, thats why i deleted my question , but don't know why i didn't disappear , but still i am getting runtime error

FLY gravatar imageFLY ( 2013-07-02 13:26:35 -0500 )edit

i undelete my question and edit with runtime error , +1 for help

FLY gravatar imageFLY ( 2013-07-02 13:34:46 -0500 )edit

if you delete it, noone can help you anymore ;)

berak gravatar imageberak ( 2013-07-02 13:38:34 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-07-02 12:01:30 -0500

Seen: 265 times

Last updated: Jul 02 '13