zoukankan      html  css  js  c++  java
  • 寻找最小矩形边框--OpenCv

    好久没有写博客了 

    今天写一下比较常用的寻找矩形边框

            ////////////////////////////寻找最矩形边框//////////////////////////////////////////////////////////
            vector<vector<Point>>contours;
            vector<Vec4i>hierarchy;
            findContours(g_grayImage, contours, hierarchy, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);
            RotatedRect box;
            double area = 0;
            for (int i = 0; i < contours.size(); i++)
            {
    
                if (contourArea(contours[i]) > area)
                {
                    box = minAreaRect(contours[i]);
                    area = contourArea(contours[i]);
                }
            }
            Point2f vertex[4];
            box.points(vertex);
            for (int i = 0; i < 4; i++)
            {
                line(g_grayImage, vertex[i], vertex[(i + 1) % 4], Scalar(100, 200, 211), 2, LINE_AA);
            }
            imshow("框选", g_grayImage);
  • 相关阅读:
    从头学Android之Android布局管理:LinerLayout线性布局
    Android onTouch事件传递机制
    android开源项目和框架
    <hdu
    <hdu
    <poj
    <poj
    <hdu
    <hdu
    <hdu
  • 原文地址:https://www.cnblogs.com/Loving-Q/p/12061490.html
Copyright © 2011-2022 走看看