Reputation: 439
beginner in openCV and i'm just wondering why it is that Mat data types do not require pointer initiation. You can use
Mat image
instead of
Mat* image
Upvotes: 2
Views: 80
Reputation: 96147
The first allocates the space for a Mat object (the header if you like) in exactly the same way as int a
allocates space for an int.
When you specify the size and type of the data, or load an image into it, it will allocate the memory for the actual data.
This is really an elementary C or C++ programming question, nothing to do with openCV. The Mat img
and Mat *img =new(Mat(...))` both make space for the Mat itself (just the header). In either case you can also specify the size of the data and the Mat will internally allocate memory for the image data. This is invisible to you and nothing to do with how you store the Mat.
Upvotes: 2