我已经编写了一个程序
但是,它没有按我认为的那样工作。我认为问题在于矩形的内部边界未填充。我应该使用形态学,例如扩张然后侵蚀。在尝试检测与Hough变换的交集之前,我已经没有足够的想法来对这两个“线索”图像进行预处理
需要大家的帮助!
提前致谢
下面是我的代码段,用于生成以下内容
int FindBoxes(cv::Mat& colorMap,cv::Mat& edgeMap)
{
cv::Mat frame;
// colorMap is a coloured filtered map while edgeMap is an edge filter Map. frame will be the colour i want
cv::bitwise_and(colorMap, edgeMap, frame);
// A trial method by using findContour to get the interior line filled up
std::vector<std::vector<cv::Point> > contours;
std::vector<cv::Vec4i> hierarchy;
cv::findContours(frame, contours, hierarchy, CV_RETR_EXTERNAL,
cv::CHAIN_APPROX_SIMPLE);
cv::Mat Map = cv::Mat::zeros(cueMap1.size(), CV_8U);
cv::drawContours(Map, contours, -1, cv::Scalar(255, 255, 255), CV_FILLED);
// thin the line to collapse it into one single line for Hough Detection
cv::Mat thin;
thinning(Map, Map);
cv::GaussianBlur(Map, Map, cv::Size(5,5),1.0,1.0);
std::vector<cv::Vec4i> lines;
cv::HoughLinesP(Map, lines,1, CV_PI/90, 2, 30, 0);
return 0;
}