Ask Your Question
0

Direct access to pixel by oclMat.

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

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 ++){

    omat.data[y * omat.step + x * omat.oclchannels() + 0] = (uchar)255; //* memory access error(0xC0000005)

    omat.data[y * omat.step + x * omat.oclchannels() + 1] = (uchar)0;

    omat.data[y * omat.step + x * omat.oclchannels() + 2] = (uchar)0;

}

}

omat.download(dst);


Memory access error is occured in the about source code. I studied oclMat data structure according to the following (http://docs.opencv.org/modules/ocl/doc/data_structures.html), 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
1

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

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

Comments

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

ken83 gravatar imageken83 ( 2014-03-02 00:57:38 -0600 )edit

Question Tools

Stats

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

Seen: 436 times

Last updated: Mar 02 '14