Pregunta

I used CPU version as follows.

vector<float> descriptors;
cv::HOGDescriptor hog(cv::Size(24,32),cv::Size(12,12),cv::Size(4,4),cv::Size(6,6),6);
hog.compute(img, descriptors,cv::Size(8,8), cv::Size(0,0));

My questions is how can get the 'descriptors' using GPU?

I tried the following code. (doesn't work)

cv::gpu::GpuMat gpu_value, gpu_descriptors;
cv::gpu::HOGDescriptor hog_gpu(Size(24,32),Size(12,12),Size(4,4),Size(6,6),6);
gpu_value.upload(img);
hog_gpu.getDescriptors(gpu_value,cv::Size(8,8),gpu_descriptors);

how can I get the 'descriptors' from 'gpu_descriptors'?

Any one can help me to solve this? Many thanks!

¿Fue útil?

Solución

You can download gpu_descriptors to CPU memory using gpu::GpuMat memeber function download(), as follows:

Mat cpu_descriptors; 
gpu_descriptors.download(cpu_descriptors);

However, the descriptors may be stored differently on the GPU than on CPU, that is cpu_descriptors may not be exactly the same as descriptors computed in your code above. But you can give it a try.

Edit There doesn't seem to be a method to download descriptors to CPU memory in vector<float> format for gpu::HOGDescriptor. As a side note, I know that you can download descriptors for gpu::SURF_GPU feature detector, using it's member function

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

which is exactly what you want. But, unfortunately, for some reason this function doesn't exist for cv::gpu::HOGDescriptor. You can attempt to figure out how the data is stored in vector<float> type of descriptors and then try to convert from Mat to vector<float> format.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top