The code:
unsigned char data[20][20] =
{{50, 50....},
....
....};
Mat speed(20, 20, data);
When I try to access contents in speed.data
, it says:
Exception thrown at 0x003D2094 in speed tracking.exe: 0xC0000005: Access violation reading location 0x32323233.
For example, std::cout << img.data[0][1];
.
In another file mat.h
, the definition of Mat
is:
// two-dimensional matrix, type of data is unsigned char
class Mat {
public:
Mat(size_t rows_, size_t cols_, void* data_ = nullptr)
: rows(rows_), cols(cols_), data((unsigned char**)data_) {}
Mat() : rows(0), cols(0), data(nullptr) {}
bool empty() const; // return true if data == nullptr
size_t rows, cols; // the size of the matrix
unsigned char** data; // the contents of the matrix
};
So why can't I access contents in speed.data
?