1

I am trying to implement this answer, but I am getting always error. Please help.

My code:

cv::Point corners[1][6];

for (unsigned long j = startIndex; j < startIndex+6; j++) {
  int x = shape.part(j).x(); 
  int y = shape.part(j).y();

  corners[0][j-startIndex] = Point(x, y);
}
const Point* corner_list[1] = {corners[0]};

cv::Mat mask(image.rows, image.cols, CV_8UC2);
cv::fillPoly(mask, corner_list, 6, 1, cv::Scalar(255), 8);
cv::Mat result(image.size(), image.type(), cv::Scalar(0,0,0));
image.copyTo(result, mask);

Here is my error:

jni/jni_detections/jni_face_det.cpp:121:5: error: no matching function for call to 'fillPoly'
    cv::fillPoly( mask, corner_list, num_points, num_polygons, cv::Scalar( 255, 255, 255 ),  line_type);
    ^~~~~~~~~~~~ 
/home/feli/Development/android/test/dlib/dlib-android/third_party/opencv/jni/include/opencv2/imgproc.hpp:3987:17: note: 
      candidate function not viable: no known conversion from 'int' to 'const int *' for 3rd argument; take the address of
      the argument with & CV_EXPORTS void fillPoly(Mat& img, const Point** pts,
                                          ^ 
/home/feli/Development/android/test/dlib/dlib-android/third_party/opencv/jni/include/opencv2/imgproc.hpp:4005:19: note: 
      candidate function not viable: no known conversion from 'const Point *[1]' to 'const cv::_InputArray' for 2nd argument 
CV_EXPORTS_W void fillPoly(InputOutputArray img, InputArrayOfArrays pts,
                  ^

My OpenCV version is 3.1.0

bendaf
  • 2,981
  • 5
  • 27
  • 62

2 Answers2

1

I needed to pass the numPoints parameter's pointer like this:

int num_points = 6;
cv::fillPoly(mask, corner_list, &num_points, 1, cv::Scalar(255), 8);

Thanks @Tim Sweet

bendaf
  • 2,981
  • 5
  • 27
  • 62
0

Looks like you need to change

cv::Scalar(255)

to

cv::Scalar(255,255,255)
Easton Bornemeier
  • 1,918
  • 8
  • 22
  • Typo in your answer. It should `cv::Scalar(255,255,255)` instead of `cv:Scalar(255,255,255)` – eshirima Aug 01 '17 at 15:27
  • 2
    This sort of thing wouldn't cause a compilation error the OP is getting. Besides that, `mask` is currently (for some unknown reason) a 2 channel image, so this isn't really much more correct. – Dan Mašek Aug 01 '17 at 16:11
  • I had to do this also, but not that one caused the build error – bendaf Aug 02 '17 at 07:32