I am trying to create a bounding box around a feature in a binary image using OpenCV. I've read that if I create a CvRect object by passing a CvMat object 开发者_运维百科as an argument to cvBoundingRect(), I can obtain the bounding box I seek. My problem is how do I create the CvMat from an IplImage. The line I'd like to use is:
CvMat *imageMatrix = cvCreateMat(int rows, int cols, int type);
but clearly that doesn't accept an IplImage as an input. Is there another way of creating a CvMat from an IplImage?
I think you are searching for cvGetMat function.
cvBoundingRect
dose not take a image as parameter but a point set. It seems you should firstly generate a point set from your image and then call cvBoundingRect
.
To get CvMat
header from a IplImage
, you can do as Kamaev has answered.
精彩评论