2012-05-23 2 views
4

GPU 기능 설명 변환 이 메소드는 디스크립터를 담고있는 GpuMat을 그것을 담고있는 float의 벡터로 변환한다. 문제는이 벡터의 일부 요소에 액세스 할 때 반환되는 값이 예상 간격 인 0에서 255과 상당히 다른 것입니다. 내가 SURF_GPUSURF을 통해 얻은 추출 및 설명의 시간을 비교하기 위해 다음과 같은 테스트 프로그램했습니다 : descriptorsConverted의 요소를 확인문제는 내가 openvc와 CPU 기능 설명 매트릭스에 GPU 기능 설명 행렬의 변환에 약간의 문제가 사용하고

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; 

를, 내가 얻을처럼 0255 사이의 값을 얻을 것으로 예상 때 descriptorsCPU의 요소에 액세스하십시오.

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

나는 그것이 부동 소수점 벡터를 반환 분명에도 불구하고,이 문제가 downloadDescriptors에 의해 반환되는 유형과 관련된 것으로 의심되는 대신, 나는 값이 좋아 얻었다.

+0

내 생각 엔 값이 부동의 0과 1 사이의 정규화 있다는 것이다 : 나는 descriptorsCPU에 descriptorsGPU에서 업로드하는 것도 같은 일을 아마 안전한 것으로 나타났습니다. 255로 곱셈을 시도하고 (비교하기 위해) 반올림 했습니까? –

+0

나는 실제로했다. 값은 여전히 ​​이상합니다. 주로 음수와 양수가 있기 때문입니다. 또한 255로 곱해질 때의 대부분의 값은 여전히 ​​0과 1 사이이며 0으로 반올림합니다. –

+0

음수 값은 모두 0으로 반올림 되었습니까? 다른 값들에 대해서는, 플로트 버전 (255로 스케일)이 CPU 버전보다 훨씬 더 0임을 알았습니까? 나는 SURF 서술자에 많은 영 (zero)을 갖는 것이 정상적이라고 생각한다. –

답변

1

설명자에 대해 비슷한 결과를 얻었으며 일치하는 데 초기 문제가있었습니다. 또한,

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]); 

: 나는 기술자가 std::vector<float> f_descriptors에 다운로드 할 때 벡터의 길이가 기술자의 크기로 나누어 것을 발견했습니다 (즉, 중 64, 128) 그래서 나는 다음과 같은 사용 할 수 있었다 (- 반올림 수 있습니다 오류 발생)

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