-2

我想在像背景减法,findcontour,drawcontour这样的操作之后找到在对象上绘制的轮廓点。我的物体在移动,所以我的轮廓也不合适。我想找到在对象上绘制的轮廓上的最大和最小点。谁能告诉我怎么找?我的对象是移动的汽车,相机视图位于顶部。

4

1 回答 1

0
vector<vector<Point>> allContours;
vector<Vec4i> hierarchy;
Mat _temp = image.clone();
findContours(_temp, allContours, RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);

allContours 是轮廓的向量。您可以访问每个轮廓的点。

==================================================== ===========================

所有 contous 点都将通过以下代码绘制。 原来的 绘制轮廓 绘制轮廓点

    vector<vector<Point>> allContours;
    vector<Vec4i> hierarchy;
    Mat _temp = imageGray.clone();
    Mat ptDraw = Mat::zeros(image.rows,image.cols,CV_8UC3);
    findContours(_temp, allContours, RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);

    for(int i=0;i<allContours.size();i++)
    {
        drawContours(image, allContours, i, Scalar(0,0,255), 2, 8, hierarchy, 0, Point() );

        for(int j=0;j<allContours.at(i).size();j++)
        {
            Point pt = allContours.at(i).at(j);
            circle(ptDraw,pt,1,Scalar(0,0,255),CV_FILLED);
        }
    }
于 2014-10-16T07:50:02.650 回答