如何找到opencv c ++中最大的轮廓 [英] how to find the largest contour in opencv c++

查看:1173
本文介绍了如何找到opencv c ++中最大的轮廓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提取图片中的主要物件。所以我应用grabcut算法的图像。

I want to extract the main object in images. So I applied grabcut algorithm for the image. From that I want to take the largest contour in the result image resulted from the grabcut algorithm.

推荐答案

只需使用 findContours 函数查找具有 GC_FGD 值的所有轮廓。在这之后使用 contourArea 和通过所有轮廓的简单迭代,找到最大的正方形轮廓。

Just use findContours function to find all contours with GC_FGD value. After this use contourArea and simple iteration through all contours to find contour with the biggest square.

这篇关于如何找到opencv c ++中最大的轮廓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆