我正在尝试实施this答案,但我总是犯错误。请帮忙。
我的代码:
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);
这是我的错误:
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,
^
我的OpenCV版本是3.1.0
答案 0 :(得分:1)
我需要传递numPoints参数的指针,如下所示:
int num_points = 6;
cv::fillPoly(mask, corner_list, &num_points, 1, cv::Scalar(255), 8);
谢谢@Tim Sweet
答案 1 :(得分:0)
看起来你需要改变
var getVarPath = function(obj, keys){
var elements = keys.split("."),
evalStr = "",
objStr = "obj",
newObjStr = "newObj",
newObj = {};
if(elements.length > 1){
elements.forEach(function(key, index){
// first append a property accessor at the end of the eval string
evalStr = evalStr + "['" + key + "']";
// if we're at the last element, we've reached the value, so assign it
if(index === elements.length -1){
eval(newObjStr + evalStr + " = " + objStr + evalStr);
}
else {
// if we're not at the last, we're at an object level
// if the nested object doesn't exist yet, create it
if(!eval(newObjStr + evalStr)){
eval(newObjStr + evalStr + " = {};");
}
}
});
}
return newObj;
}
到
cv::Scalar(255)