Opencv BackgroundSubtractorMOG输出的掩模上的凸包
我正在使用Opencv BackgroundSubtractorMOG输出的掩模上的凸包,opencv,convex-hull,background-subtraction,Opencv,Convex Hull,Background Subtraction,我正在使用BackgroundsubtractorMOG()基本上提取一个遮罩来分离前景。然后,我使用遮罩上的convexHull()来定位移动对象的位置 但我得到了以下错误: openCV Error: Assertion failed (nelems >= 0 && (depth == CV_32F || depth == CV_32S)) in convexHull, file /home/ameya/OpenCV2.4.2/modules/imgproc/src/c
BackgroundsubtractorMOG()
基本上提取一个遮罩来分离前景。然后,我使用遮罩上的convexHull()
来定位移动对象的位置
但我得到了以下错误:
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你在你的面具图像上调用convexhull吗
它应该与点2D(或索引)向量一起使用,例如,从findContours()使用此格式,它会有所帮助(请注意对
Mat
的类型转换):
我正在使用点的点2f向量。我正在为convexHull()函数提供掩码中白色像素的索引。哦,对不起,--那太容易了;)这可能是传递给函数的元素数目错误,也可能是错误的类型(不是32F浮点或32S带符号int),正如错误所示
convexhull(Mat(inputarray),hull,0,0)