从轮廓到cv::Mat
from contours to cv::Mat
我有一个基于opencv的轮廓查找程序,现在我正试图使用Harris角点检测器来获取每个已创建轮廓中的角点数量,我的问题是我必须获得轮廓的一个元素
............................
std::vector<std::vector<cv::Point>> contours;
...........................
for ( int i =0;i <contours.size(); i++){
if(!contours[i].empty()){
Harris.detect(cv::Mat(contours[i])); // here crashes the program because the dimensions don't fit ????
Harris.getCorners(approx,0.4);
std::cout <<"size n"<< approx.size()<<std::endl;
}
}
.........................
更新
我再次检查了代码,程序在Harris类的这一部分崩溃了:
void HarrisDetector::detect(const cv::Mat& image) {
// Harris computation
cv::cornerHarris(image,cornerStrength, // here crashs the program
neighbourhood,// neighborhood size
aperture, // aperture size
k); // Harris parameter
// internal threshold computation
double minStrength; // not used
cv::minMaxLoc(cornerStrength,&minStrength,&maxStrength);
//local maxima detection
cv::Mat dilated; // temporary image
cv::dilate(cornerStrength,dilated,cv::Mat());
cv::compare(cornerStrength,dilated,localMax,cv::CMP_EQ);
}
任何ideaa
您可以在cv::findContours
函数中使用method
参数进行某种近似,然后使用contours[i].size()
来获得多个角点。
相关文章:
- 将CHW格式的浮点向量转换为cv::Mat
- C++:从GPU内存(cudaMemcpy2D)获取BGR图像(cv::Mat)
- 选择基于另一个垫子的非零像素的cv::Mat的一部分?
- 将 cv::mat 转换为 QImage
- 将 cv::Mat 转换为 std::vector 的通用函数
- 在 QML VideoOutput 中将 cv::mat 显示为 QVideoFrame
- 如何将 cv::Mat & Img 复制到未签名的 char* img?opencv
- 如何将 cv::Mat 转换为 vtkImageData?
- 如何将 vtkImageData 转换为 cv::Mat?
- 如何总结所有cv::Mat元素
- Qt-工作线程崩溃时将cv::Mat转换为QImage
- 在 cv::Mat 中生成 2D 坐标网格
- 将 cv::Mat 转换为无符号的 int 像素
- OpenCV 分段错误(核心转储)在使用 cv::Mat::at 时
- 如何将多个 cv::Mat 从 c++ dll 传递到 opencvsharp Mat c#?
- OpenCV(3.4.1) 错误:断言失败(变暗 <= 2 && step[0] > 0) in cv::Mat::locateROI
- 如何在不复制数据的情况下将 cv::Mat 转换为 2d 标准::矢量
- 如何使用 (*mpORBextractorLeft)(im,cv::Mat(),mvKeys,mDescriptors)
- 从数组创建 Mat 时,'cv::Mat' 和 'int' 类型不兼容
- 如何将 cv::mat 对象从 python 模块传递到 c++ 函数并返回返回的 cv::mat 类型为对象?