Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Convert from GpuMat to Mat

I have a little piece of code that try to convert a Mat to GpuMat and reverse. When I try to upload the Mat in GpuMat with "upload" function, it breaks. If I go next step in the debug the size of GpuMat is written, same as Mat but it doesn't upload the pixel data. Here is the code:

Mat initFrame;
Mat initconv;
Mat threshold;
imageCircle.copyTo(initFrame);
cvtColor(initFrame,initconv,CV_BGR2HSV);

gpu::GpuMat myFrame;
gpu::GpuMat myFrameLab;

myFrame.upload(initconv);

myFrame.download(threshold);
//gpu::cvtColor(myFrame,myFrameLab,CV_BGR2YCrCb);
imshow("INPUT",threshold);

I read that I will need Opencv built with GPU support. Here I don't know what to do. I saw somewhere that in OpenCV directories it exist /gpu/built/... I have 2.4.9 and 3.1 versions but I don't find in Opencv directory the /gpu/build/...