- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
以下代码应该在 Visual Studio 2010 上使用 OpenCV2.3
中的 SURF 执行特征检测。图像“sample.jpg”是一本书和视频的彩色图像 (RGB)捕获将包括几本不同的书。没有编译错误,但在 CTRL F5 上,控制台显示 Native' 已退出,代码为 -1073741811 (0xc000000d)
。这很奇怪,因为其他程序运行良好。我通过使用显示图像的简单代码删除此功能检测代码来测试它,并且似乎工作正常。只有当我运行这段代码时,它才会抛出这个错误。我在附加依赖项下包含了以下库:
opencv_core230d.lib
opencv_highgui230d.lib
opencv_ml230d.lib
opencv_legacy230d.lib
opencv_imgproc230d.lib
opencv_features2d230d.lib
opencv_calib3d230d.lib
opencv_flann230d.lib
我是否需要为 SURF 添加一个库或其他东西,因为这是我第一次使用 Surf。请帮忙。
int main()
{
Mat object = imread( "C:\\OpenCV2.3\\sample.jpg");
if( !object.data )
{
std::cout<< "Error reading object " << std::endl;
return -1;
}
//Detect the keypoints using SURF Detector
int minHessian = 500;
SurfFeatureDetector detector( minHessian );
std::vector<KeyPoint> kp_object;
detector.detect( object, kp_object );
//Calculate descriptors (feature vectors)
SurfDescriptorExtractor extractor;
Mat des_object;
extractor.compute( object, kp_object, des_object );
FlannBasedMatcher matcher;
VideoCapture cap(0);
if( !cap.isOpened() ) return -1;
namedWindow("Good Matches");
std::vector<Point2f> obj_corners(4);
//Get the corners from the object
obj_corners[0] = cvPoint(0,0);
obj_corners[1] = cvPoint( object.cols, 0 );
obj_corners[2] = cvPoint( object.cols, object.rows );
obj_corners[3] = cvPoint( 0, object.rows );
char key = 'a';
int framecount = 0;
while (key != 27)
{
Mat frame;
cap >> frame;
if (framecount < 5)
{
framecount++;
continue;
}
Mat des_image, img_matches;
std::vector<KeyPoint> kp_image;
std::vector<vector<DMatch > > matches;
std::vector<DMatch > good_matches;
std::vector<Point2f> obj;
std::vector<Point2f> scene;
std::vector<Point2f> scene_corners(4);
Mat H;
Mat image;
cvtColor(frame, image, CV_RGB2GRAY);
detector.detect( image, kp_image );
extractor.compute( image, kp_image, des_image );
matcher.knnMatch(des_object, des_image, matches, 2);
for(int i = 0; i < min(des_image.rows-1,(int) matches.size()); i++) //THIS LOOP IS SENSITIVE TO SEGFAULTS
{
if((matches[i][0].distance < 0.6*(matches[i][3].distance)) && ((int) matches[i].size()<=2 && (int) matches[i].size()>0))
{
good_matches.push_back(matches[i][0]);
}
}
//Draw only "good" matches
drawMatches( object, kp_object, image, kp_image, good_matches, img_matches, Scalar::all(-1), Scalar::all(-1), vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
if (good_matches.size() >= 4)
{
for( int i = 0; i < good_matches.size(); i++ )
{
//Get the keypoints from the good matches
obj.push_back( kp_object[ good_matches[i].queryIdx ].pt );
scene.push_back( kp_image[ good_matches[i].trainIdx ].pt );
}
H = findHomography( obj, scene, CV_RANSAC );
perspectiveTransform( obj_corners, scene_corners, H);
//Draw lines between the corners (the mapped object in the scene image )
line( img_matches, scene_corners[0] + Point2f( object.cols, 0), scene_corners[1] + Point2f( object.cols, 0), Scalar(0, 255, 0), 4 );
line( img_matches, scene_corners[1] + Point2f( object.cols, 0), scene_corners[2] + Point2f( object.cols, 0), Scalar( 0, 255, 0), 4 );
line( img_matches, scene_corners[2] + Point2f( object.cols, 0), scene_corners[3] + Point2f( object.cols, 0), Scalar( 0, 255, 0), 4 );
line( img_matches, scene_corners[3] + Point2f( object.cols, 0), scene_corners[0] + Point2f( object.cols, 0), Scalar( 0, 255, 0), 4 );
}
//Show detected matches
imshow( "Good Matches", img_matches );
key = waitKey(1);
}
return 0;
}
最佳答案
我相信 SURF 检测器不适用于彩色图像。您将需要使用
以灰度加载它们Mat object = imread( "C:\\OpenCV2.3\\sample.jpg",CV_LOAD_IMAGE_GRAYSCALE);
关于visual-studio-2010 - 使用 SURF 时出现运行时错误 Visual Studio 和 OpenCV 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14613162/
OpenCV SURF function is not implemented 可能重复 我的错误代码是: error LNK2019: unresolved external symbol "pub
我在 http://opencv.willowgarage.com/documentation/python/feature_detection.html 阅读了 OpenCV SURF 手册“Ext
我正在使用 SURF 测试一些对象检测和 SIFT . SURF 声称比 SIFT 更快、更稳健,但我在测试中发现这不是真的。中等图像 (600*400) 的 SIFT 与 SURF 的速度相同,并且
我正在尝试像全景 View 一样在 Android 中拼接图像。我正在尝试使用冲浪描述符来拼接图像。我使用的是 2.4.0 版本的 openCv,因为较高版本不包含用于冲浪描述符的非自由文件夹。我有还
我正在尝试编写一个 matlab 代码来回答以下问题: Using functions linspace,meshgrid,surf and dot operations, plot the surf
在SURF技术中,更确切地说,在特征描述阶段,作者已经声明(如果我理解正确的话),描述将在20倍sigma的区域内执行。 Sigma代表检测到关键点的规模。 Sigma = 0.4 x L,其中L =
我正在尝试编写一个 matlab 代码来回答以下问题: Using functions linspace,meshgrid,surf and dot operations, plot the surf
我使用以下简单的代码从图像中提取 SURF 描述符: Ptr descriptor = DescriptorExtractor::create("SURF"); descriptor->com
我正在使用 Opencv C++ 进行人脸识别应用。为此,我使用 SURF 作为描述符,使用 FlannMatcher 来匹配点。我的代码如下, FlannBasedMatcher matcher;
有什么方法可以将 OPENCV SURF 中的关键点数量限制为 100 个?获取到的关键点会按照强度排序吗?如何获取描述符的强度?我正在使用 cpp 程序在 LINUX 系统中处理 OPENCV。 问
我有 2 个图像,在相机中有一点点方向,我想从 opencv 中找到方向,我从 2 个图像中获取冲浪关键点,我的问题是如何比较这 2 个关键点以找到方向。 最佳答案 您需要应用匹配器(例如 cv Fl
我正在尝试使用 OpenCV 和 SURF 方法实现交通标志识别器。我的问题是我得到随机结果(有时非常准确,有时显然是错误的)而且我无法理解为什么。这是我实现比较的方式: 首先我检测图像上的轮廓 然后
我正在尝试了解 SURF 特征检测的工作原理。我想我已经取得了一些进步。我想知道我离真正发生的事情有多远。 您已经存储的模板图像和真实世界图像根据“关键点”或一些重要特征进行比较在两张图片中。 相同点
任何人熟悉此错误?我实时测试了一个冲浪描述符。我想使用此功能来识别不同种类的鱼。有时程序可以,但有时会出错。编译成功。编译后显示此错误。 #include #include #include #
我在理解 SURF 和 SIFT 算法时遇到了一些概念问题 All about SURF .据我了解,SURF 发现高斯的拉普拉斯算子,而 SIFT 对高斯的差异进行运算。然后它围绕它构造一个 64
我有一个矩阵 Z,我想使用 surf 命令绘制它。我可以使用 surf 命令很好地绘制它,但我希望 Z 的一部分不显示在图中。我假设我需要做的是使用符号 surf(X,Y,Z) 其中 X 和 Y 是定
我想检测实时视频源中的 SURF 特征点,但是,我似乎找不到任何关于如何实现这一点的教程。 我能够在静止图像上检测到它们: int minHessian = 400; cv::Surf
我能够编译代码,但是当我运行它时,我收到了这个错误。 我在 Win 7 中使用 VS 2010 和 opencv 248。 感谢任何帮助。 最佳答案 遇到同样的问题。 SURF 开发人员说,为了使用库
最近,我在做机器人项目;我的机器人可以通过颜色检测物体,但我发现对于不同的物体来说还不够好。因此,我希望机器人实时浏览图像以找到将使用其模板定义的目标对象。 不幸的是,我不知道如何将模板的关键点与其图
在我的代码中,我根据最近的邻居距离比过滤好的图像,如下所示: for(int i = 0; i 0)) { good_matches.push_back(mat
我是一名优秀的程序员,十分优秀!