Library/opencv

groupRectangles

퓨림노 2012. 11. 23. 13:33

OpenCV :groupRectangles()



OpenCV version : 2.4.3


#include "" 부분은 태그를 방해하므로~ 


#include <iostream>

#include <opencv2\core\core.hpp>

#include <opencv2\highgui\highgui.hpp>

#include <opencv2\opencv.hpp>


using namespace std;

using namespace cv;



함수원형


CV_EXPORTS void groupRectangles(CV_OUT CV_IN_OUT vector& rectList, int groupThreshold, double eps=0.2);
CV_EXPORTS_W void groupRectangles(CV_OUT CV_IN_OUT vector& rectList, CV_OUT vector& weights, int groupThreshold, double eps=0.2);
CV_EXPORTS void groupRectangles( vector& rectList, int groupThreshold, double eps, vector* weights, vector* levelWeights );
CV_EXPORTS void groupRectangles(vector& rectList, vector& rejectLevels,
                                vector& levelWeights, int groupThreshold, double eps=0.2);
CV_EXPORTS void groupRectangles_meanshift(vector& rectList, vector& foundWeights, vector& foundScales,
										  double detectThreshold = 0.0, Size winDetSize = Size(64, 128));



int main()
{
	std::vector vecList;
	cv::Rect rect1(2,2,2,2);
	//cv::Rect rect2(2,2,2,2);
	cv::Rect rect3(30,30,30,30);
	//cv::Rect rect4(2,2,2,2);
	vecList.push_back(rect1);
	//vecList.push_back(rect2);
	vecList.push_back(rect3);
	//vecList.push_back(rect4);
	cv::groupRectangles( vecList, 2);
	return 0;
}


Rect 를 이용하여 간단한 사용방법이다. 


결과화면

 결과는 간단히 사각형을 검출 후 추출하였을 때이다. 

 사각형 검출은 따로 포스팅을 한다. 






결과화면과 같이 사각형을 1번씩 검출하게 된다. 

GroupRectangles 함수를 사용하지 않게 되면 사각형을 여러번 찾게되는 문제가 생기니 계산하지말고 간단히 있는 함수를 사용하자.