iplimage 到 mat 32 位转换错误
我想将 iplimage 转换为 cv::mat (不是 CvMat)。使用此代码,值主题将溢出...
IplImage mhi32f = cvCreateImage(cvSize(draw_rect.width,draw_rect.height), IPL_DEPTH_32F, 1);
cv::Mat mhi32_mat(mhi32f);
mhi32_mat.convertTo(mhi32_mat,CV_32FC1);
有什么建议吗?
I want to convert an iplimage to a cv::mat (not CvMat). With this code the values themes to be overflowed...
IplImage mhi32f = cvCreateImage(cvSize(draw_rect.width,draw_rect.height), IPL_DEPTH_32F, 1);
cv::Mat mhi32_mat(mhi32f);
mhi32_mat.convertTo(mhi32_mat,CV_32FC1);
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如这里所解释的,你只需要这样做
as explained here, you just have to do that
首先,
IplImage mhi32f = ...
应该是IplImage* mhi32f = ...
,但我认为这是您的拼写错误。您的示例很好,只是您不需要
convertTo
调用。如果要将IplImage
数据复制到Mat
对象,只需将true
作为第二个参数传递给构造函数,如下所示 这里。这是一个示例,显示类型已经是
CV_32FC1
:希望有帮助。
First off,
IplImage mhi32f = ...
should beIplImage* mhi32f = ...
, but I'll assume that was a typo on your part.Your example is fine except that you don't need the
convertTo
call. If you want to copy theIplImage
data to theMat
object simply passtrue
as the second argument to the constructor as shown here.Here is an example showing that the type is already
CV_32FC1
:Hope that helps.