- opencv matcher bad alloc incorrect library dependancies?
- #include <opencv2/imgproc/imgproc.hpp>
- #include <opencv2/core/core.hpp>
- #include <opencv2/highgui/highgui.hpp>
- #include <opencv2/features2d/features2d.hpp>
- #include <opencv2/calib3d/calib3d.hpp>
- #include <opencv2/objdetect/objdetect.hpp>
- #include <vector>
- #include<iostream>
- int main()
- {
- cv::Ptr<IplImage> img = cvLoadImage("img.jpg",1);
- cv::Ptr<IplImage> img1 = cvLoadImage("img1.jpg",1);
- cv::Mat image(img,false);
- cv::Mat image1(img1,false);
- cv::resize(image,image,cv::Size(image.cols/5,image.rows/7));
- cv::resize(image1,image1,cv::Size(image1.cols/5,image1.rows/7));
- cv::waitKey(0);
- std::vector<cv::KeyPoint> keypoints;
- std::vector<cv::KeyPoint> keypoints1;
- cv::SurfFeatureDetector surf(20000);
- surf.detect(image,keypoints);
- surf.detect(image1,keypoints1);
- cv::drawKeypoints(image,keypoints,image,cv::Scalar(0,0,255),cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
- cv::drawKeypoints(image1,keypoints1,image1,cv::Scalar(0,0,255),cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
- cv::imshow("1",image);
- cv::imshow("2",image1);
- cv::waitKey(0);
- cv::SurfDescriptorExtractor surfDesc;
- cv::Mat descriptors;
- cv::Mat descriptors1;
- surfDesc.compute(image,keypoints,descriptors);
- surfDesc.compute(image1,keypoints1,descriptors1);
- std::cout<<sizeof(unsigned long);
- cv::BruteForceMatcher<cv::L2<float>>matcher;
- std::vector<cv::DMatch>matches;
- matcher.match( descriptors, descriptors1, matches );
- cv::Mat img_matches;
- drawMatches( image, keypoints, image1, keypoints1,matches, img_matches, cv::Scalar::all(-1), cv::Scalar::all(-1),std::vector<char>(), cv::DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
- imshow( "Matches", img_matches );
- cv::waitKey(0);
- return 0;
- }
- if (!img || !img1)
- {
- // log error and quit
- return 1;
- }
- surf.detect(image,keypoints);
- First-chance exception at 0x0038a473 in cv_test.exe: 0xC0000005: Access violation reading location 0x000000c8.
- Unhandled exception at 0x0038a473 in cv_test.exe: 0xC0000005: Access violation reading location 0x000000c8.
- opencv_core231.lib opencv_highgui231.lib opencv_flann231.lib opencv_imgproc231.lib opencv_features2d231.lib