diff --git a/examples/contours.js b/examples/contours.js index 43bb0ac..dcbf48a 100755 --- a/examples/contours.js +++ b/examples/contours.js @@ -25,13 +25,16 @@ cv.readImage('./files/stuff.png', function(err, im) { im_canny.dilate(nIters); contours = im_canny.findContours(); + const lineType = 8; + const maxLevel = 0; + const thickness = 1; for(i = 0; i < contours.size(); i++) { if(contours.area(i) > maxArea) { var moments = contours.moments(i); var cgx = Math.round(moments.m10 / moments.m00); var cgy = Math.round(moments.m01 / moments.m00); - big.drawContour(contours, i, GREEN); + big.drawContour(contours, i, GREEN, thickness, lineType, maxLevel, [0, 0]); big.line([cgx - 5, cgy], [cgx + 5, cgy], RED); big.line([cgx, cgy - 5], [cgx, cgy + 5], RED); } diff --git a/src/Matrix.cc b/src/Matrix.cc index faff68d..170c913 100755 --- a/src/Matrix.cc +++ b/src/Matrix.cc @@ -1486,7 +1486,16 @@ NAN_METHOD(Matrix::DrawContour) { } int thickness = info.Length() < 4 ? 1 : info[3]->NumberValue(); - cv::drawContours(self->mat, cont->contours, pos, color, thickness); + int lineType = info.Length() < 5 ? 8 : info[4]->NumberValue(); + int maxLevel = info.Length() < 6 ? 0 : info[5]->NumberValue(); + + cv::Point offset; + if (info.Length() == 6) { + Local _offset = Local::Cast(info[5]); + offset = cv::Point(_offset->Get(0)->ToNumber()->Value(), _offset->Get(1)->ToNumber()->Value()); + } + + cv::drawContours(self->mat, cont->contours, pos, color, thickness, lineType, cont->hierarchy, maxLevel, offset); return; }