English 中文(简体)
使用 gpu 特性描述符转换的开立cv 特征描述符的问题
原标题:Problems with opencv feature descriptors converted from gpu feature descriptors

在将一个 GPU 特征描述矩阵转换为带有开口的 CPU 特征描述矩阵时,我遇到了一些问题,使用:

void downloadDescriptors(const GpuMat& descriptorsGPU, vector<float>& descriptors);

您可以看到, 此方法将持有描述符的 GpuMat 转换为持有该指示符的浮标矢量。 问题是, 当我访问此矢量的某些元素时, 返回的值与 < code> 0 到 < code> 255 的预期间隔相当不同。 我做了以下测试程序, 以比较通过 < code > SURF_ GPU 和 < code > SURF 获取的提取时间和描述时间 :

clock_t start;
clock_t end;

SURF_GPU surfGPU;
SURF surf;

Mat img1 = imread("Ipo_SP_01.jpg", CV_LOAD_IMAGE_GRAYSCALE);
Mat outimageGPU;
Mat outimageCPU;
GpuMat imgGPU;
imgGPU.upload(img1);

vector<KeyPoint> keyp_A;
vector<KeyPoint> keyp_B;
GpuMat keypGPU;

vector<float> descriptorsConverted;
Mat descriptorsCPU;
GpuMat descriptorsGPU;

start = (clock() * 1000)/CLOCKS_PER_SEC;
surfGPU(imgGPU, GpuMat(), keypGPU, descriptorsGPU);
end = (clock() * 1000)/CLOCKS_PER_SEC;
cout << "GPU time: " << end - start << endl;
surfGPU.downloadKeypoints(keypGPU, keyp_A);
surfGPU.downloadDescriptors(descriptorsGPU, descriptorsConverted);
cout << "GPU Keypoints = " << keyp_A.size() << endl;

start = (clock() * 1000)/CLOCKS_PER_SEC;
surf(img1, Mat(), keyp_B, descriptorsCPU);
end = (clock() * 1000)/CLOCKS_PER_SEC;
cout << "CPU time: " << end - start << endl;
cout << "CPU Keypoints = " << keyp_B.size() << endl;

drawKeypoints(img1, keyp_A, outimageGPU, Scalar(255, 255, 255), DrawMatchesFlags::DEFAULT);
imwrite("GPU.jpg", outimageGPU);
drawKeypoints(img1, keyp_B, outimageCPU, Scalar(255, 255, 255), DrawMatchesFlags::DEFAULT);
imwrite("CPU.jpg", outimageCPU);

return 0;

检查 descritors 元素的元素 翻转 ,我期望在 0 255 之间得到数值,就像我访问 descritors CPU 元素时得到的数值一样。 相反,我得到了以下数值:

-0.000621859
0.000627841
-0.000503146
0.000543773
-8.69408e-05
0.000110254
0.000265697
0.000941789
0.0595061
0.0619723

我怀疑这个问题与 download Descritors 返回的类型有关,尽管它会返回浮控矢量。

问题回答

我对描述符得出类似的结果, 并出现一些初始匹配问题 。 我发现当描述符下载到 < code>std:: victor< float> f_ descriptionors 时, 说明符的长度会因描述符大小( 即64 或 128) 的不同而不同, 因此我能够使用以下方法 :

std::vector<float> f_descriptors;
std::vector<cv::KeyPoint> keypoints;
surfGPU( imgGPU, cv::gpu::GpuMat(), keypoints, f_descriptors  );
descriptorsCPU = cv::Mat( (int)f_descriptors.size()/surfGPU.descriptorSize(), surfGPU.descriptorSize(), CV_32F, f_descriptors[0] );

我发现从标语GPU上传到标语GPU CPU也做同样的事情,

std::vector<cv::KeyPoint> keypoints;
cv::gpu::GpuMat descriptorsGPU
surfGPU( imgGPU, cv::gpu::GpuMat(), keypoints, descriptorsGPU  );
descriptorsGPU.download( descriptorsCPU );




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签