Ask Your Question
0

OpenCV2.4.9 - OpenCL - oclMat

asked Jan 9 '15

shalor gravatar image

updated Jan 11 '15

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.

Preview: (hide)

1 answer

Sort by » oldest newest most voted
0

answered Jan 9 '15

updated Jan 9 '15

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.

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Jan 9 '15

Seen: 755 times

Last updated: Jan 09 '15