如何在c++中调用openCV中的cvMorphologyEx?

发布于 2025-01-07 15:35:02 字数 387 浏览 2 评论 0原文

我需要在我的图像处理项目中调用 cvMorphologyEx,我使用这条线来完成它。

cvMorphologyEx(src1,dest1,NULL,NULL,CV_MOP_OPEN);

它编译得很好,但是在运行时它给了我这个错误

OpenCV 错误:错误标志(参数或结构字段)(无法识别或不支持 ed 数组类型)在未知函数中,文件 ........\ocv\opencv\src\cxcore\cxarr ay.cpp,第 2476 行

我确定问题出在第三个和第四个参数中,但文档说它们是可选的。

如果您需要更多详细信息,请告诉我。

谢谢,

再见

i need to call cvMorphologyEx in my image processing project and i do it using this line.

cvMorphologyEx(src1,dest1,NULL,NULL,CV_MOP_OPEN);

It compiles fine but while running it gives me this error

OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupport
ed array type) in unknown function, file ........\ocv\opencv\src\cxcore\cxarr
ay.cpp, line 2476

I am sure the problem is in the third and fourth arguments but the documentation says that they are optional.

If you need anymore details please tell me.

Thanks,

Bye

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青衫儰鉨ミ守葔 2025-01-14 15:35:02

您必须创建一个 IplConvKernel 并将其传递给函数,否则 cvMorphologyEx 不知道结构元素的大小和形状,因此它无法进行任何处理。

int filterSize = 5;
IplConvKernel *convKernel = cvCreateStructuringElementEx(filterSize, filterSize, (filterSize - 1) / 2, (filterSize - 1) / 2, CV_SHAPE_RECT, NULL);

cvMorphologyEx(src1, dest1, NULL, convKernel, CV_MOP_OPEN);

请注意,结构元素不是可选的!

You have to create an IplConvKernel and pass it to the function, otherwise cvMorphologyEx dose not know the size and the shape of the structuring element so it can no do any processing.

int filterSize = 5;
IplConvKernel *convKernel = cvCreateStructuringElementEx(filterSize, filterSize, (filterSize - 1) / 2, (filterSize - 1) / 2, CV_SHAPE_RECT, NULL);

cvMorphologyEx(src1, dest1, NULL, convKernel, CV_MOP_OPEN);

Take care the structuring element is not optional!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文