Segmentation Fault while using MPI and OpenCV together

前端 未结 3 532
死守一世寂寞
死守一世寂寞 2021-01-27 02:51

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

3条回答
  •  遥遥无期
    2021-01-27 03:49

    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()

提交回复
热议问题