opencv轮廓提取与轮廓拟合

#include 
#include 
#include 
#include 
#include 

using namespace std;
using namespace cv;

int main()
{
	// Read input binary image
	Mat image= imread("./binaryGroup.bmp",0);
	if (!image.data)
		return 0; 

	namedWindow("Binary Image");
	imshow("Binary Image",image);

	// Get the contours of the connected components
	vector> contours;
	//findContours的输入是二值图像
	findContours(image, 
		contours, // a vector of contours 
		CV_RETR_EXTERNAL, // retrieve the external contours
		CV_CHAIN_APPROX_NONE); // retrieve all pixels of each contours

	// Print contours' length轮廓的个数
	cout << "Contours: " << contours.size() << endl;
	vector>::const_iterator itContours= contours.begin();
	for ( ; itContours!=contours.end(); ++itContours) {

		cout <&

你可能感兴趣的:(c/c++)