由BackgroundSubtractorMOG输出的蒙版上的凸壳

问题描述:

我使用BackgroundsubtractorMOG()来基本上提取一个蒙版以分离出前景。然后我使用掩模上的convexHull()来定位移动物体的位置。由BackgroundSubtractorMOG输出的蒙版上的凸壳

但我得到以下错误:

openCV Error: Assertion failed (nelems >= 0 && (depth == CV_32F || depth == CV_32S)) in convexHull, file /home/ameya/OpenCV2.4.2/modules/imgproc/src/contours.cpp, line 1947 
terminate called after throwing an instance of 'cv::Exception' 
    what(): /home/ameya/OpenCV2.4.2/modules/imgproc/src/contours.cpp:1947: error: (-215) nelems >= 0 && (depth == CV_32F || depth == CV_32S) in function convexHull 

我已经检查了没有。元素以及类型铸造掩模矩阵。但错误仍然存​​在。 有没有人遇到过类似的问题。我正在使用OpenCV 2.4.2

+0

这要么是错误的号码传递给函数或错误的类型(不32F浮动或32S元素signed int),因为错误会显示它 – Georges 2016-11-26 10:18:55

你在那里调用你的面具图像凸面吗?

它应该适用于point2d(或index)向量,例如。从findContours()

+0

我正在使用Point2f向量的点。我提供了带有mask的白色像素索引的convexHull()函数。 – Ameya005 2013-02-14 05:13:01

+0

哦,对不起,那会是一个太简单的例子;) – berak 2013-02-14 18:05:40

使用这种格式,这将有助于(通知类型转换到Mat):

convexhull(Mat(inputarray),hull,0,0)