cuda::DescriptorMatcher::knnMatch runs in differ
I want to use cuda::DescriptorMatcher::knnMatch to speed up my feature match.But the running time of cuda::DescriptorMatcher::knnMatch with different format input is different. First, if I construct a GpuMat which is pointed to a usr-located gpu-memory.
//for enquiry descriptors
cv::cuda::GpuMat gpuReferClusterDesc(cv::Mat ...);
//for train descriptors
float *ptrSearchClusterDesc;
cudaMalloc((void**)&ptrSearchClusterDesc, 20000*128*sizeof(float));
... // do something with ptrSearchClusterDesc
cv::cuda::GpuMat gpuSearchClusterDesc(featureNum, 128, CV_32F, ptrClusterSearchDesc);
///////////////
//this will takes 20ms.
cuda::DescriptorMatcher::knnMatch(gpuReferClusterDesc, gpuSearchClusterDesc, matches, 2)
///////////////
if I construct a GpuMat from Mat.
//for enquiry descriptors
cv::cuda::GpuMat gpuReferClusterDesc(cv::Mat ...);
//for train descriptors
float *ptrSearchClusterDesc;
cudaMalloc((void**)&ptrSearchClusterDesc, 20000*128*sizeof(float));
... // do something with ptrSearchClusterDesc
cv::cuda::GpuMat gpuSearchClusterDesc(featureNum, 128, CV_32F, ptrClusterSearchDesc);
cv::Mat matSearchClusterDesc(gpuSearchClusterDesc);
cv::cuda::GpuMat gpuMatSearchClusterDesc(matSearchClusterDesc);
///////////////
//this will only takes 2ms.
cuda::DescriptorMatcher::knnMatch(gpuReferClusterDesc, gpuMatSearchClusterDesc, matches, 2)
///////////////
I do not know why. is there anyone knows? thanks