struct CvMat

Matrix elements are stored row by row. Element (i, j) (i - 0-based row index, j - 0-based column index) of a matrix can be retrieved or modified using CV_MAT_ELEM macro:

uchar pixval = CV_MAT_ELEM(grayimg, uchar, i, j)
CV_MAT_ELEM(cameraMatrix, float, 0, 2) = image.width*0.5f;

To access multiple-channel matrices, you can use CV_MAT_ELEM(matrix, type, i, j*nchannels + channel_idx).

Deprecated CvMat is now obsolete; consider using Mat instead.

#include <types_c.h>

struct CvMat
{
    // fields

    int cols;
    union CvMat::@54 data;
    double* db;
    float* fl;
    int hdr_refcount;
    int height;
    int* i;
    uchar* ptr;
    int* refcount;
    int rows;
    short* s;
    int step;
    int type;
    int width;

    // construction

    CvMat();
    CvMat(const CvMat& m);
    CvMat(const cv::Mat& m);
};