c++ - 在 HoughLines 之前要采取什么预处理步骤
问题描述
我写了一个程序
- 从这组线段中,计算交点(不包含在代码中)
- 从交点,从交点画一个四边形,水平/垂直线的顶点(称为v1和v2,离交点最远)和一个顶点基于交点在v1和之间的线上的反射计算v2
但是,它并没有像我认为的那样工作。我认为问题在于矩形的内部边框没有被填充。我应该使用形态,例如扩张然后侵蚀。在尝试检测与霍夫变换的交集之前,我已经没有办法预处理两个“提示”图像
需要大家帮忙!
提前致谢
下面是我生成以下代码的代码片段
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;
}
解决方案
推荐阅读
- python - 匹配查询不返回任何内容
- python - PYTHON_INSTALL_LAYOUT 在 AWS 中做了什么?
- django - TypeError:Cart 类型的对象不是 JSON 可序列化的
- vba - 如何将复制的图片粘贴到占位符中?
- asp.net-core - .Net Core API UnauthorizedResult 401 状态?
- python - 如何移动这个pygame程序的图片?
- html - 哪个属性会使溢出包装停止工作?
- python - 获取 SSLError:抓取链接列表时出现 HTTPSConnectionPool
- laravel - 如何在laravel上将函数getClientOriginalExtension()修复为null
- javascript - D3 & React - 在不使用 xlink:href 的情况下创建图像散点图