Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Direct access to pixel by oclMat.

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.