从 IplImage 创建 CvMat 对象
我正在尝试使用 OpenCV 在二值图像中的某个特征周围创建一个边界框。我读过,如果我通过将 CvMat 对象作为参数传递给 cvBoundingRect() 来创建 CvRect 对象,我可以获得我寻求的边界框。我的问题是如何从 IplImage 创建 CvMat。我想使用的行是:
CvMat *imageMatrix = cvCreateMat(int rows, int cols, int type);
但显然它不接受 IplImage 作为输入。是否有另一种从 IplImage 创建 CvMat 的方法?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您正在寻找 cvGetMat 函数。
I think you are searching for cvGetMat function.
cvBoundingRect
不将图像作为参数,而是将点集作为参数。看来您应该首先从图像生成一个点集,然后调用cvBoundingRect
。要从
IplImage
获取CvMat
标头,您可以按照 Kamaev 的回答进行操作。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 callcvBoundingRect
.To get
CvMat
header from aIplImage
, you can do as Kamaev has answered.