2013-02-13 51 views
1

我使用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

回答

0

你在那裏調用你的面具圖像凸面嗎?

它應該適用於point2d(或index)向量,例如。從findContours()

+0

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

+0

哦,對不起,那會是一個太簡單的例子;) – berak 2013-02-14 18:05:40

2

使用這種格式,這將有助於(通知類型轉換到Mat):

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