Ask Your Question

Direct access to pixel by oclMat.

asked 2014-03-01 23:11:21 -0500

ken83 gravatar image

I have tried direct access to pixel so as to change its color by the following source code. (Underlying environment is the NVIDIA GeForce and Windows Vista 32bit.It is working fine initialization of ocl (ocl :: setDiveice ()) is.)

cv::Mat src = cv::imread("c:\temp\test.jpg");

cv::Mat dst(Size(src.cols,src.rows),CV_8UC3);

cv::ocl::oclMat omat(src);

for(int x = 0;x < omat.cols; x++){

for(int y = 0;y < omat.rows;y ++){[y * omat.step + x * omat.oclchannels() + 0] = (uchar)255; //* memory access error(0xC0000005)[y * omat.step + x * omat.oclchannels() + 1] = (uchar)0;[y * omat.step + x * omat.oclchannels() + 2] = (uchar)0;



Memory access error is occured in the about source code. I studied oclMat data structure according to the following (, but i wonder in actual way how to access oclMat data. Please suggest me.

Thank you, in favor.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2014-03-02 00:32:40 -0500

Vladislav Vinogradov gravatar image

You can't access oclMat data from CPU code. The oclMat data is located on GPU memory. You can only upload/download from/to CPU Mat or run custom OpenCL kernel.

edit flag offensive delete link more


Thank you for your quick reply. I will try create OpenCL kernel code.

ken83 gravatar imageken83 ( 2014-03-02 00:57:38 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2014-03-01 23:11:21 -0500

Seen: 342 times

Last updated: Mar 02 '14