当前位置: 首页>>代码示例>>C++>>正文


C++ ImageProcessor::contourDetection方法代码示例

本文整理汇总了C++中ImageProcessor::contourDetection方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageProcessor::contourDetection方法的具体用法?C++ ImageProcessor::contourDetection怎么用?C++ ImageProcessor::contourDetection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageProcessor的用法示例。


在下文中一共展示了ImageProcessor::contourDetection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testRemoveRedundantContours

/*
 * tests removeRedundantContours() function
 */
void testRemoveRedundantContours(){
	//test removing redundant contours with an image that should not have any contours after processing
	cv::Mat img = cv::imread("images/horizontal-lines.jpg", CV_LOAD_IMAGE_COLOR);
 	assert(!img.empty());

 	//process for lines and contours
	cv::vector<cv::Vec4i> lines = imageProcessor.lineDetection(img);
	assert(!lines.empty());
 	cv::vector< cv::vector<cv::Point> > contours;
	cv::vector<cv::Vec4i> hierarchy;
	imageProcessor.contourDetection(img, contours, hierarchy);

	cv::vector< cv::vector<cv::Point> > valid_contours = imageProcessor.removeRedundantContours(contours, lines);

	assert((int)valid_contours.size() == 0);

	//empty vectors for 2nd test
	lines.clear();
	contours.clear();
	hierarchy.clear();
	valid_contours.clear();

	//test removing redundant contours with an image that will have valid contours after processing the image
	img = cv::imread("images/two2.png", CV_LOAD_IMAGE_COLOR);
 	assert(!img.empty());

 	//process for lines and contours
	lines = imageProcessor.lineDetection(img);
	assert(!lines.empty());
	imageProcessor.contourDetection(img, contours, hierarchy);

	valid_contours = imageProcessor.removeRedundantContours(contours, lines);

	assert((int)valid_contours.size() == 48);

	printf("removeRedundantContours() test passed.\n");
}
开发者ID:J-Fid,项目名称:Senior-Design-I,代码行数:40,代码来源:imageProcUnitTests.cpp

示例2: testContourDetection

/*
 * tests the contourDetection() function
*/
void testContourDetection(){
	cv::Mat img = cv::imread("images/two2.png", CV_LOAD_IMAGE_COLOR);
	assert(!img.empty());

	cv::vector<cv::Vec4i> lines = imageProcessor.lineDetection(img);

	cv::vector< cv::vector<cv::Point> > contours;
	cv::vector<cv::Vec4i> hierarchy;
	imageProcessor.contourDetection(img, contours, hierarchy);

	assert(!contours.empty());
	assert(!hierarchy.empty());
	assert((int)contours.size() == 53);

	printf("contourDetection() test passed.\n");
}
开发者ID:J-Fid,项目名称:Senior-Design-I,代码行数:19,代码来源:imageProcUnitTests.cpp


注:本文中的ImageProcessor::contourDetection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。