I am trying to learn MPI in C++. I have some knowledge of OpenCV so I tried writing a program using both MPI and OpenCV. This may sound stupid but for the purpose of learning I
Mat object is only a header structure that points to the memory that stores the image.
So you have some problems:
First, you create a Mat
object sized 640X640 and than you read from the camera into that object. But Mat
is just a header it is not a pointer to the data, The Mat object can be now of any width and height.
Second, sizeof(Mat)
does not return the amount of memory allocated to the image, only the amount of memory the Mat object itself. The amount of memory needed for the image is Mat.total()*Mat.elemSize()