参考并修改:

http://blog.csdn.net/guduruyu/article/details/69220296


#include "stdafx.h"

#include "opencv2/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"  


using namespace cv;
using namespace std;
int main()
{
Mat image_gray = imread("../mk.jpg", IMREAD_GRAYSCALE);
Mat image_binary;


threshold(image_gray, image_binary, 100, 255,THRESH_BINARY);
vector< vector<Point> > contours;
findContours(
image_binary,
contours,
noArray(),
RETR_LIST,
CHAIN_APPROX_SIMPLE
);
image_binary = Scalar::all(0);
drawContours(image_binary, contours, -1, Scalar::all(255));


imshow("gray image", image_gray);
imshow("Contours", image_binary);


waitKey(0);
 
return 0;

}

OpenCV3 图像轮廓



相关文章:

  • 2022-12-23
  • 2021-04-04
  • 2021-06-23
  • 2021-12-05
  • 2021-12-25
  • 2021-12-24
  • 2022-02-04
  • 2021-08-18
猜你喜欢
  • 2021-08-09
  • 2021-07-11
  • 2021-04-08
  • 2021-05-09
  • 2022-12-23
相关资源
相似解决方案