【发布时间】:2015-04-24 18:40:56
【问题描述】:
根据 matchShapes 文档,输入可以是灰度图像或轮廓。但是当我尝试两张灰度图像时,我得到了一个断言失败的错误。经过进一步探索,我从here 发现 Mat 对象必须是一维向量,并且类型为 CV_32FC2 或 CV_32SC2。
使用this 答案,我将图像转换为 CV_32FC2 后的浮点矢量数组。我仍然收到断言错误。
谁能告诉我如何使用 matchShapes 函数比较两张灰度图像?
更新
错误信息
OpenCV Error: Assertion failed (contour1.checkVector(2) >= 0 && contour2.checkVector(2) >= 0 && (contour1.depth() == CV_32F || contour1.depth() == CV_32S) && contour1.depth() == contour2.depth()) in matchShapes, file /home/tonystark/Opencv/modules/imgproc/src/contours.cpp, line 1936
terminate called after throwing an instance of 'cv::Exception'
what(): /home/tonystark/Opencv/modules/imgproc/src/contours.cpp:1936: error: (-215) contour1.checkVector(2) >= 0 && contour2.checkVector(2) >= 0 && (contour1.depth() == CV_32F || contour1.depth() == CV_32S) && contour1.depth() == contour2.depth() in function matchShapes
我用的时候
pkg-config --modversion opencv
它表示版本为 2.4.9
【问题讨论】:
-
你用的是什么版本的opencv?断言错误信息是什么?
-
请查看编辑。 @alrikai