opencv中connectedComponentsWithStats用法
前言
opencv中新增了connectedComonentWithStats函数,可以帮助我们直接找到一张图片的连通区域,不用再自己写连通函数了
函数示例:
int cv::connectedComponentsWithStats ( InputArray image,
OutputArray labels, //输入图像,8位单通道
OutputArray stats,
OutputArray centroids,
int connectivity = 8,
int ltype = CV_32S
)
使用步骤
代码如下(示例):
#include <opencv2/opencv.hpp>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace cv;
using namespace std;
//八连通、计算质心坐标
int main(in