Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Mat Template Pointer is NULL

I'm trying to allocate space for a Mat object and access the data via a pointer. I discovered that my pointer was NULL. I'm confused because reserve() should allocate rows yet the ptr is still NULL.

The only thing I've found that works is pushing a value on Mat. Unfortunately that means I've got one extra value in the array. Is there a way I can get a valid pointer without pushing data?

Mat_<int>B;
B.reserve(10);   // I tried this but I still got NULL
int *pB = B.ptr<int>(0);  // pB = NULL
pB = (int *)B.data;

B.push_back(4);  
pB = B.ptr<int>(0);  // pB != NULL

Mat Template Pointer is NULL

I'm trying to allocate space for a Mat object and access the data via a pointer. I discovered that my pointer was NULL. I'm confused because reserve() should allocate rows yet the ptr is still NULL.

The only thing I've found that works is pushing a value on Mat. Unfortunately that means I've got one extra value in the array. Is there a way I can get a valid pointer without pushing data?

Mat_<int>B;
B.reserve(10);   // This should allocate space so I tried this but I still got NULL
should get a NULL ptr right?
int *pB = B.ptr<int>(0);  // here pB = NULL
NULL. Arg.
pB = (int *)B.data;
*)B.data;         // here pB = NULL. Arg.

B.push_back(4);  
pB = B.ptr<int>(0);  // pB != NULL