Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

[OPENCV GPU] How can I convert GpuMat and Vector<point2f> using HostMem?

Hello,

I manage to convert from GpuMat to Vector<point2f> by following this post. Now I am trying to optimize the code. I found that to reduce the time spent on the cudaMemCpy2D I have to pin the host buffer memory. In the following image you can see how cudaMemCpy2D is using a lot of resources at every frame:

image description

In order to pin the host memory, I found the class:

cv::cuda::HostMem

However, when I do:

cv::Mat mat(1, vec.size(), CV_32FC2, (void*)&vec[0]);
cv::cuda::HostMem h_mat(mat);

and then I run the function upload/download the vec is empty.

Is anyone who can help me with this?

Thank you in advance.

[OPENCV GPU] How can I convert GpuMat and Vector<point2f> using HostMem?

Hello,

I manage to convert from GpuMat to Vector<point2f> by following this post. Now I am trying to optimize the code. I found that to reduce the time spent on the cudaMemCpy2D I have to pin the host buffer memory. In the following image you can see how cudaMemCpy2D is using a lot of resources at every frame:

image description

In order to pin the host memory, I found the class:

cv::cuda::HostMem

However, when I do:

 void download(const cuda::GpuMat& d_mat, vector<Point2f>& vec) 
{
         cv::Mat mat(1, vec.size(), CV_32FC2, (void*)&vec[0]);
 cv::cuda::HostMem h_mat(mat);
         d_mat.download(h_mat);
}

and then I run the function upload/download the vec is empty.

Is there anyone who can help me with this?

Thank you in advance.

[OPENCV GPU] How can I convert GpuMat and Vector<point2f> using HostMem?

Hello,

I manage to convert from GpuMat to Vector<point2f> by following this post. Now I am trying to optimize the code. I found found that to reduce the time spent on the cudaMemCpy2D I have to pin the host buffer memory. In the following image you can see how cudaMemCpy2D is using a lot of resources at every frame:

image description

In order to pin the host memory, I found the class:

cv::cuda::HostMem

However, when I do:

 void download(const cuda::GpuMat& d_mat, vector<Point2f>& vec) 
{
         cv::Mat mat(1, vec.size(), CV_32FC2, (void*)&vec[0]);
         cv::cuda::HostMem h_mat(mat);
         d_mat.download(h_mat);
}

and then I run the function upload/download the vec is empty.

Is there anyone who can help me with this?

Thank you in advance.

[OPENCV GPU] How can I convert GpuMat and Vector<point2f> using HostMem?

Hello,

I manage to convert from GpuMat to Vector<point2f> by following this post. Now I am trying to optimize the code. I found that to reduce the time spent on the cudaMemCpy2D I have to pin the host buffer memory. In the following image you can see how cudaMemCpy2D is using a lot of resources at every frame:

image description

In order to pin the host memory, I found the class:

cv::cuda::HostMem

However, when I do:

 void download(const cuda::GpuMat& d_mat, vector<Point2f>& vec) 
{
         cv::Mat mat(1, vec.size(), CV_32FC2, (void*)&vec[0]);
         cv::cuda::HostMem h_mat(mat);
         d_mat.download(h_mat);
}

and then I run the function upload/download the vec is empty.

full with points at 0,0:

std::vector of length 193, capacity 193 = {{x = 0, y = 0}, {x = 0, y = 0}, ... , {x = 0, y = 0}, {x = 0, y = 0}}

Is there anyone who can help me with this?

Thank you in advance.

[OPENCV GPU] How can I convert GpuMat and Vector<point2f> using HostMem?

Hello,

I manage to convert from GpuMat to Vector<point2f> by following this post. Now I am trying to optimize the code. I found that to reduce the time spent on the cudaMemCpy2D I have to pin the host buffer memory. In the following image you can see how cudaMemCpy2D is using a lot of resources at every frame:

image description

In order to pin the host memory, I found the class:

cv::cuda::HostMem

However, when I do:

 void download(const cuda::GpuMat& d_mat, vector<Point2f>& vec) 
{
         cv::Mat mat(1, vec.size(), CV_32FC2, (void*)&vec[0]);
         cv::cuda::HostMem h_mat(mat);
         d_mat.download(h_mat);
}

and then I run the function upload/download download the vec is full with points at 0,0:

std::vector of length 193, capacity 193 = {{x = 0, y = 0}, {x = 0, y = 0}, ... , {x = 0, y = 0}, {x = 0, y = 0}}

Is there anyone who can help me with this?

Thank you in advance.

[OPENCV GPU] How can I convert GpuMat and Vector<point2f> using HostMem?

Hello,

I manage to convert from GpuMat to Vector<point2f> by following this post. Now I am trying to optimize the code. I found that to reduce the time spent on the cudaMemCpy2D I have to pin the host buffer memory. In the following image you can see how cudaMemCpy2D is using a lot of resources at every frame:

image description

In order to pin the host memory, I found the class:

cv::cuda::HostMem

However, when I do:

 void download(const cuda::GpuMat& d_mat, vector<Point2f>& vec) 
{
         cv::Mat mat(1, vec.size(), CV_32FC2, (void*)&vec[0]);
         cv::cuda::HostMem h_mat(mat);
         d_mat.download(h_mat);
}

and then I run the function download and the vec is full with of points at 0,0:

std::vector of length 193, capacity 193 = {{x = 0, y = 0}, {x = 0, y = 0}, ... , {x = 0, y = 0}, {x = 0, y = 0}}

Is there anyone who can help me with this?

Thank you in advance.