1

I am using the BackgroundsubtractorMOG() to basically extract a mask to separate out the foreground. I am then using convexHull() on the mask to locate the position of a moving object.

But i am getting the following error:

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

I have checked the no. of elements as well as type-casted the mask matrix. But the error still persists. Has anyone encountered a similar problem before. I am using OpenCV 2.4.2

Nilabja
  • 4,206
  • 5
  • 27
  • 45
Ameya005
  • 31
  • 1
  • 5
  • this is either the wrong number of elements passed to the function or the wrong type (not 32F float or 32S signed int) as the error showcases it – Georges Nov 26 '16 at 10:18

2 Answers2

2

Use this format, it will help (notice typecasting to Mat):

convexhull(Mat(inputarray),hull,0,0)
Amos M. Carpenter
  • 4,848
  • 4
  • 42
  • 72
0

are you calling convexhull on your mask image there ?

it's supposed to work with point2d(or index) vectors, eg. from findContours()

berak
  • 39,159
  • 9
  • 91
  • 89
  • I am working with Point2f vector of points. I am providing the convexHull() function with the indices of white pixels in the mask. – Ameya005 Feb 14 '13 at 05:13
  • oh, sorry then, -- that would have been a too easy case ;) – berak Feb 14 '13 at 18:05