#include<opencv2/opencv.hpp>
#include<opencv2/core/core.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<iostream>
using namespace cv;
using namespace std;
 
int main()
{
Mat srcImage = imread("1.jpg",0);
imshow("yuantu",srcImage);
Mat dstImage = Mat::zeros(srcImage.rows,srcImage.cols,CV_8SC3);
srcImage = srcImage > 119;
imshow("fazhitu",srcImage);
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;


findContours(srcImage,contours,hierarchy,RETR_CCOMP,CHAIN_APPROX_NONE);
int index = 0;
for(; index >= 0;index = hierarchy[index][0])
{
//drawChessboardCorners(InputOutputArray image,Size patternSize,InputArray corners,bool patternWasFound)
Scalar color(rand()&255,rand()&255,rand()&255);
drawContours(dstImage,contours,index,color,FILLED,8,hierarchy);
}
imshow("lunkuotu",srcImage);
waitKey(0);
return 0;

}

运行图如下

opencv 查找并绘制轮廓


相关文章:

  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
  • 2021-11-28
  • 2021-09-01
  • 2021-07-19
  • 2022-12-23
  • 2021-12-06
猜你喜欢
  • 2021-08-01
  • 2021-09-25
  • 2021-12-23
  • 2022-12-23
  • 2021-07-08
  • 2022-12-23
相关资源
相似解决方案