Ask Your Question
0

OpenCV2.4.9 - OpenCL - oclMat

asked 2015-01-09 14:18:17 -0600

shalor gravatar image

updated 2015-01-11 06:45:18 -0600

I am currently trying to make a program in c++ using OpenCV library. In order to accelerate my code I am trying to use OpenCV builtin ocl. In my code I'm trying to use oclMat and I need to take a specific cell's value. Ive tried addressing a specific cell like that:

oclMat ocl_image(image); //initializing the oclMat with image
ocl_image.row(i).col(j) //address the specific (i,j) cell in col_image

My problem now is that I couldn't find a way of convert the value I have (oclMat Header) to 'float'. What I did for now is

ocl_image.row(i).col(j).download(temp) //temp is of type cv::Mat

And the code takes too much time to run, Is there an other way of addressing a specific cell without the need to convert between cv::ocl::oclMat and cv::Mat types?

Thank you.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2015-01-09 15:15:28 -0600

updated 2015-01-09 15:33:55 -0600

Just guess (never tried this): it is worth do use ROI(1x1px), copy it to a new 1x1 oclMat and download this small matrix. Accoring to docs if you try download a part of oclMat then all matrix is transferred: "Data transfer between Mat and oclMat: ROI is a feature of OpenCV, which allow users process a sub rectangle of a matrix. When a CPU matrix which has ROI will be transfered to GPU, the whole matrix will be transfered and set ROI as CPU’s. In a word, we always transfer the whole matrix despite whether it has ROI or not." -- row(i).col(j) is a kind of ROI and this is your case.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-01-09 14:18:17 -0600

Seen: 693 times

Last updated: Jan 09 '15