Ask Your Question

Revision history [back]

Eventually I changed the conversion to use pointers:

Convert mat to buffer:

unsigned char buffer[height * width];

uchar* p;
for (i = 0; i < height; ++i) {
    p = myMat.ptr<uchar>(i);
    for (j = 0; j < width; ++j) {
        buffer[i * width + j] = p[j];
    }
}