visual-c++ - 使用opencv和visual c++查找轮廓的中心

标签 visual-c++ opencv image-processing

我想在不进行大量计算的情况下找到轮廓的中心。 opencv 中是否有内置函数?

最佳答案

对于“几何中心”,获取 boundingRect()的轮廓,然后:

   cx = br.x+br.width/2; cy = br.y+br.height/2; 

对于“质心”,获取 moments()的轮廓,然后:

   cx = m.m10 / m.m00;   cy = m.m01 / m.m00;

关于visual-c++ - 使用opencv和visual c++查找轮廓的中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22399257/

相关文章:

c++ - C2712 : Cannot use __try in functions that require object unwinding

python - OpenCV Python 断言失败

python - 简单的 Docker 项目/处理并保存 JPEG - 使用卷?

matlab - 如何在matlab中将L*a*b*转换为灰度

c++ - dll 导出/初始化问题(静态变量初始化?)Visual Studio C++

c++ - _CrtSetAllocHook 从不显示文件名/行号

c++ - static_cast<std::u16string> 的 GCC 问题

c++ - 安装opencv后如何安装OpenCV_contrib模块

ios - OpenCV 3 - 如何正确提取 cv::Mat 的 ROI?

c++ - 访问 Mat 中出错的图像的像素