OpenCV drawContours() function

cuimannuo 注册会员
2023-02-27 20:38

the reference answer GPT ᴼ ᴾ ᴱ ᴺ ᴬ ᴵ < br / > according to provide you the code, you can see the first and the second drawContours function of the second parameter is the vector type, The second argument to the third drawContours function is of type Mat. This is because drawContours function has two uses:

  1. is used to draw contours. The second parameter is a vector, indicating the contours to be drawn. There can be multiple contours.
  2. is used to fill the inside of the contour line. The second parameter is Mat, indicating the area surrounded by the contour line to be drawn. Only a single contour line can be drawn.

In your code, the first and second drawContours functions use the first usage, and the third drawContours uses the second usage. Therefore, in the third drawContours function, if the argument type is vector, there will be an error because it can only accept arguments of type Mat.

As for why only part of the points are displayed after casting hull to Mat type, it may be because hull itself is not a contour, but a vector composed of points on the contour. Therefore, casting it to Mat may only show a portion of the points.

It is recommended that you review the scenarios in your code where you use the drawContours function to make sure that the argument types are correct and that the methods you use are correct.

csddjj1199 注册会员
2023-02-27 20:38

It's not a matter of Mat not Mat, you can try replacing line 39 with the following three lines:

vector > hullvec;
drawContours(soleColor, hullvec, -1, Scalar(0, 0, 255),2);

About the Author

Question Info

Publish Time
2023-02-27 20:38
Update Time
2023-02-27 20:38

Related Question



Opencv cuda编译错误,如何解决?(语言-c++)

OpenCV cornerSubPix异常

Is there any way to index functions so that I can use them inside a summation in sympy