src/Pipeline.cpp
void Pipeline::filterContours(std::vector<std::vector<cv::Point> > &inputContours, double minArea, double minPerimeter, double minWidth, double maxWidth, double minHeight, double maxHeight, double solidity[], double maxVertexCount, double minVertexCount, double minRatio, double maxRatio, std::vector<std::vector<cv::Point> > &output) {
		std::vector<cv::Point> hull;
		output.clear();
		for (std::vector<cv::Point> contour: inputContours) {
			cv::Rect bb = boundingRect(contour);
			if (bb.width < minWidth || bb.width > maxWidth) continue;
			if (bb.height < minHeight || bb.height > maxHeight) continue;
			double area = cv::contourArea(contour);
			if (area < minArea) continue;
			if (arcLength(contour, true) < minPerimeter) continue;
			cv::convexHull(cv::Mat(contour, true), hull);
			double solid = 100 * area / cv::contourArea(hull);
			if (solid < solidity[0] || solid > solidity[1]) continue;
			if (contour.size() < minVertexCount || contour.size() > maxVertexCount)	continue;
			double ratio = bb.width / bb.height;
			if (ratio < minRatio || ratio > maxRatio) continue;
			output.push_back(contour);
		}
	}
/**
	 * Filters through contours.
	 * @param inputContours is the input vector of contours.
	 * @param minArea is the minimum area of a contour that will be kept.
	 * @param minPerimeter is the minimum perimeter of a contour that will be kept.
	 * @param minWidth minimum width of a contour.
	 * @param maxWidth maximum width.
	 * @param minHeight minimum height.
	 * @param maxHeight  maximimum height.
	 * @param solidity the minimum and maximum solidity of a contour.
	 * @param minVertexCount minimum vertex Count of the contours.
	 * @param maxVertexCount maximum vertex Count.
	 * @param minRatio minimum ratio of width to height.
	 * @param maxRatio maximum ratio of width to height.
	 * @param output vector of filtered contours.
	 */
Filters through contours.
@param inputContours is the input vector of contours.
@param minArea is the minimum area of a contour that will be kept.
@param minPerimeter is the minimum perimeter of a contour that will be kept.
@param minWidth minimum width of a contour.
@param maxWidth maximum width.
@param minHeight minimum height.
@param maxHeight  maximimum height.
@param solidity the minimum and maximum solidity of a contour.
@param minVertexCount minimum vertex Count of the contours.
@param maxVertexCount maximum vertex Count.
@param minRatio minimum ratio of width to height.
@param maxRatio maximum ratio of width to height.
@param output vector of filtered contours.
Filters through contours . @param inputContours is the input vector of contours . @param minArea is the minimum area of a contour that will be kept . @param minPerimeter is the minimum perimeter of a contour that will be kept . @param minWidth minimum width of a contour . @param maxWidth maximum width . @param minHeight minimum height . @param maxHeight maximimum height . @param solidity the minimum and maximum solidity of a contour . @param minVertexCount minimum vertex Count of the contours . @param maxVertexCount maximum vertex Count . @param minRatio minimum ratio of width to height . @param maxRatio maximum ratio of width to height . @param output vector of filtered contours .
void Pipeline::filterContours(std::vector<std::vector<cv::Point> > &inputContours, double minArea, double minPerimeter, double minWidth, double maxWidth, double minHeight, double maxHeight, double solidity[], double maxVertexCount, double minVertexCount, double minRatio, double maxRatio, std::vector<std::vector<cv::Point> > &output) {
		std::vector<cv::Point> hull;
		output.clear();
		for (std::vector<cv::Point> contour: inputContours) {
			cv::Rect bb = boundingRect(contour);
			if (bb.width < minWidth || bb.width > maxWidth) continue;
			if (bb.height < minHeight || bb.height > maxHeight) continue;
			double area = cv::contourArea(contour);
			if (area < minArea) continue;
			if (arcLength(contour, true) < minPerimeter) continue;
			cv::convexHull(cv::Mat(contour, true), hull);
			double solid = 100 * area / cv::contourArea(hull);
			if (solid < solidity[0] || solid > solidity[1]) continue;
			if (contour.size() < minVertexCount || contour.size() > maxVertexCount)	continue;
			double ratio = bb.width / bb.height;
			if (ratio < minRatio || ratio > maxRatio) continue;
			output.push_back(contour);
		}
	}
void Pipeline :: filterContours ( std :: vector < std :: vector < cv :: Point > > & inputContours , double minArea , double minPerimeter , double minWidth , double maxWidth , double minHeight , double maxHeight , double solidity [ ] , double maxVertexCount , double minVertexCount , double minRatio , double maxRatio , std :: vector < std :: vector < cv :: Point > > & output ) { std :: vector < cv :: Point > hull ; output . clear ( ) ; for ( std :: vector < cv :: Point > contour : inputContours ) { cv :: Rect bb = boundingRect ( contour ) ; if ( bb . width < minWidth || bb . width > maxWidth ) continue ; if ( bb . height < minHeight || bb . height > maxHeight ) continue ; double area = cv :: contourArea ( contour ) ; if ( area < minArea ) continue ; if ( arcLength ( contour , true ) < minPerimeter ) continue ; cv :: convexHull ( cv :: Mat ( contour , true ) , hull ) ; double solid = 100 * area / cv :: contourArea ( hull ) ; if ( solid < solidity [ 0 ] || solid > solidity [ 1 ] ) continue ; if ( contour . size ( ) < minVertexCount || contour . size ( ) > maxVertexCount ) continue ; double ratio = bb . width / bb . height ; if ( ratio < minRatio || ratio > maxRatio ) continue ; output . push_back ( contour ) ; } }
Filters through contours.
Filters through contours .