凌云流水
凌云流水

Reputation: 21

How can I get access to the data in the gpuMat?

opencv document about gpu::orb

I want to get the keypoints of the image with gpu::orb and the type of the keypoints is a gpuMat.Then I tried to get access to the data of the gpuMat as the documents.

I tried with the code below:(keypoints is a gpumat)

cout<<keypoints.ptr<float>(3)[4]<<endl;

but I got a "Segmentation fault(core dumped)".I knew that we can't modified the data in the gpuMat.Then how can I get the data in the gpuMat?

Upvotes: 1

Views: 3164

Answers (1)

pSoLT
pSoLT

Reputation: 1052

According to OpenCV documentation cv::cuda::GpuMat is:

Base storage class for GPU memory with reference counting. Its interface matches the Mat interface with the following limitations:

  • no arbitrary dimensions support (only 2D)
  • no functions that return references to their data (because references on GPU are not valid for CPU)
  • no expression templates technique support

ptr would return the pointer to device memory. You cannot read device memory directly from host. In order to use the data in host functions like operator <<, the data needs to be copied to host memory using GpuMat::download(cv::Mat& m).

Upvotes: 3

Related Questions