在询问这里并尝试SURF和SIFT之后,它们都没有足够高效地产生足够快的兴趣点来跟踪来自摄像机的流.
例如,SURF需要大约3秒的时间来生成图像的兴趣点,这对于跟踪来自网络摄像头的视频来说太慢了,而且在手机上使用它时情况会更糟.
我只需要一个跟踪某个区域,它的比例,倾斜等的算法.我可以在此基础上构建.
谢谢
我正在用C++制作一个程序,它使用2个图像来检测SURF特征,用bruteforcematcher计算匹配并绘制它.
这是代码
#include <cstdio>
#include <string>
#include <vector>
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv2/features2d/features2d.hpp"
using namespace cv;
using namespace std;
int main(int argc, char **argv){
if (argc <3) {
cout << "Usage: " << argv[0] << " imageLocation1 imageLocation2" << endl;
return -1;
}
Mat source1 = imread(argv[1],CV_LOAD_IMAGE_GRAYSCALE);
Mat source2 = imread(argv[2],CV_LOAD_IMAGE_GRAYSCALE);
if(source1.empty() || source2.empty()){
printf("Can't load all the images!");
return -1;
}
//Initialise the Wrapping Class for Surf()
SurfFeatureDetector detector(400);
//detect : first param: Image, second param: vector (output) …Run Code Online (Sandbox Code Playgroud) 我在C#(OpenSurf)中使用SURF算法从图像中获取兴趣点列表.这些兴趣点中的每一个都包含描述符的向量,x坐标(int),y坐标(int),缩放(浮点)和方向(浮点).
现在,我想比较一个图像的兴趣点和数据库中的图像列表,这些图像列表中还有一个兴趣点列表,以找到最相似的图像.即:[图像(IP)] COMPARETO [图像列表(IP)].=>最佳匹配.在个体基础上比较图像产生不令人满意的结果.
在搜索stackoverflow或其他站点时,我发现的最佳解决方案是构建FLANN索引,同时跟踪兴趣点的来源.但在实施之前,我有一些令我困惑的问题:
1)当基于其SURF兴趣点匹配图像时,我发现的算法通过将它们的距离(x1,y1-> x2,y2)相互比较并找到具有最低总距离的图像来进行匹配.比较兴趣点时是否从未使用描述符或方向?
2)如果使用描述符,我将如何比较它们?我无法弄清楚如何使用索引树比较64点(1图像)的X矢量和64点(几个图像)的Y矢量.
我真的很感激一些帮助.我搜索到的所有地方或我找到的API,只支持将一张图片匹配到另一张图片,但不能将一张图片有效地匹配到图片列表.
我正在尝试使用OpenCV从图像中提取SURF描述符.我正在使用OpenCV 2.4和Python 2.7,但我很难找到任何提供有关如何使用这些功能的信息的文档.我已经能够使用以下代码来提取功能,但我找不到任何合理的方法来提取描述符:
import cv2
img = cv2.imread("im1.jpg")
img2 = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
surf = cv2.FeatureDetector_create('SURF')
detector = cv2.GridAdaptedFeatureDetector(surf, 50) # max number of features
fs = detector.detect(img2)
Run Code Online (Sandbox Code Playgroud)
我尝试提取描述符的代码是:
import cv2
img = cv2.imread("im3.jpg")
sd = cv2.FeatureDetector_create("SURF")
surf = cv2.DescriptorExtractor_create("SURF")
keypoints = []
fs = surf.compute(img, keypoints) # returns empty result
sd.detect(img) # segmentation faults
Run Code Online (Sandbox Code Playgroud)
有没有人有任何样本代码可以做这种事情,或指向任何提供样本的文档的指针?
我试图使用带有ORB描述符的FLANN,但opencv崩溃了这个简单的代码:
vector<vector<KeyPoint> > dbKeypoints;
vector<Mat> dbDescriptors;
vector<Mat> objects;
/*
load Descriptors from images (with OrbDescriptorExtractor())
*/
FlannBasedMatcher matcher;
matcher.add(dbDescriptors);
matcher.train() //> Crash!
Run Code Online (Sandbox Code Playgroud)
如果我使用SurfDescriptorExtractor()它效果很好.
我怎么解决这个问题?
OpenCV说:
OpenCV Error: Unsupported format or combination of formats (type=0
) in unknown function, file D:\Value\Personal\Parthenope\OpenCV\modules\flann\sr
c\miniflann.cpp, line 299
Run Code Online (Sandbox Code Playgroud) 我正在使用SURF描述符进行图像匹配.我打算将给定的图像与图像数据库进行匹配.
import cv2
import numpy as np
surf = cv2.xfeatures2d.SURF_create(400)
img1 = cv2.imread('box.png',0)
img2 = cv2.imread('box_in_scene.png',0)
kp1,des1 = surf.detectAndCompute(img1,None)
kp2,des2 = surf.detectAndCompute(img2,None)
bf = cv2.BFMatcher(cv2.NORM_L1,crossCheck=True)
#I am planning to add more descriptors
bf.add(des1)
bf.train()
#This is my test descriptor
bf.match(des2)
Run Code Online (Sandbox Code Playgroud)
问题bf.match在于我收到以下错误:
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /build/opencv/src/opencv-3.1.0/modules/core/src/stat.cpp, line 3749
Traceback (most recent call last):
File "image_match4.py", line 16, in <module>
bf.match(des2) …Run Code Online (Sandbox Code Playgroud) [m2_array, ~ , ~] = F_readBin('amb.bin');
amb = m2_array(:,:,lat);
surfc(light,'LineWidth',0.001);
ylim([1 24]); xlim([1 size(light,2)]); title(['@ ',num2str(lat),'°N']);
xticks([0:50:size(m2_array,2)]);
labels=cellstr(num2str((day_start:50:day_end)')); xticklabels(labels);
xlabel('Season days'); ylabel('Daytime{[hours]}');zlabel('surface light
[\mumol m^2 s^-^1]')
colormap winter;
Run Code Online (Sandbox Code Playgroud)
但是,我能找到的所有解决方案,例如yyaxis似乎只适用于2D图.是否有冲浪,网状,冲浪地块的工作?
我已经使用此链接在ubuntu上安装了OpenCV ,我正在尝试使用SURF描述符.我知道他们将这些类型的描述符的位置更改为非自由模块,因此我们需要包含它,这是这样的:#include "opencv2/nonfree/features2d.hpp".问题是我在编译时遇到这个错误:opencv2/nonfree/features2d.hpp no such file or directory.
知道怎么解决吗?
编辑: openCV的其他部分工作正常.我包括以下库,一切都很好看:
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/legacy/legacy.hpp"
Run Code Online (Sandbox Code Playgroud)
我检查了我的OpenCV目录中的inlcude文件夹,并且存在nonfree文件夹.此外,它是我在QTCreator(我正在使用的环境)中无法访问的唯一库,因为我试图包含在Inlcude文件夹中找到的所有其他库,但它们看起来很好.
EDITED2:
您可以看到我make VERBOSE=1在此链接上运行时看到的内容的屏幕截图
所以不确定在哪里看?实际上,我没有在../usr/include/opencv2/中找到nonfree文件夹
谢谢.
当我尝试运行示例find_obj.cpp或任何OpenCV SURF程序时,我在执行代码时在命令提示符中收到以下错误.该项目的构建没有错误和警告.我正在使用VS2011 beta,OpenCV 2.4和windows7.
错误信息:
OpenCV Error: The function/feature is not implemented < OpenCV was built without SURF support> in unknown function,file ..\..\..\src\opencv\modules\legacy\src\features2d.cpp, line 77
Run Code Online (Sandbox Code Playgroud)
我尝试在调试模式下使用Cmake然后再使用VS2011再次构建OpenCV 2.4,然后在IDE中添加了lib路径,但仍然没有结果.
我该如何解决这个问题?
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/legacy/legacy.hpp>
#include <opencv2/legacy/compat.hpp>
#include <opencv2/flann/flann.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/nonfree/nonfree.hpp>
using namespace std;
using namespace cv;
int main()
{
cv::initModule_nonfree();//THIS LINE IS IMPORTANT
IplImage *image1 = cvLoadImage("C:\\SURF\\1.jpg");
IplImage *image2 = cvLoadImage("C:\\SURF\\2.jpg");
CvMemStorage* memoryBlock = cvCreateMemStorage();
CvSeq* image1KeyPoints;
CvSeq* image1Descriptors;
CvSeq* …Run Code Online (Sandbox Code Playgroud) 我是emgu的新手,想要从哪里开始.
我已经看过形状检测,但它太复杂了我需要的东西..我想..而且我的例子不起作用.我收到此错误:
无论如何,这就是我想要做的:在图像B中找到图像A.图像A是一个简单的正方形,总是具有相同的灰色1像素边框并且总是相同的尺寸(我相信)但内部颜色可能是黑色或大约7种其他颜色之一(只有纯色).当我按下按钮时,我需要在图像b中找到图像A的坐标.见下图.
图B
和
图片A