本文整理汇总了C++中ImageProcessor::lineDetection方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageProcessor::lineDetection方法的具体用法?C++ ImageProcessor::lineDetection怎么用?C++ ImageProcessor::lineDetection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageProcessor
的用法示例。
在下文中一共展示了ImageProcessor::lineDetection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testLineDetection
/*
* tests the lineDetection() function
*/
void testLineDetection(){
cv::Mat img = cv::imread("images/line.png", CV_LOAD_IMAGE_COLOR);
cv::vector<cv::Vec4i> line_vec = imageProcessor.lineDetection(img);
assert(!line_vec.empty());
assert(line_vec.size() <= 7);
line_vec.clear();
img = cv::imread("images/horizontal-lines.jpg", CV_LOAD_IMAGE_COLOR);
line_vec = imageProcessor.lineDetection(img);
assert(!line_vec.empty());
assert(line_vec.size() <= 13);
printf("lineDetection() test passed.\n");
}
示例2: 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");
}
示例3: 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");
}