zoukankan      html  css  js  c++  java
  • opencv就这么简单, 就这么任性

    #include <opencv2/opencv.hpp>
    #include <opencv2/imgproc/imgproc.hpp>
    #include <opencv2/highgui/highgui.hpp>

    using namespace cv;

    #if 0
    //腐蚀
    int main() {
        Mat srcImage = imread("C:\pics\index.jpg");
        imshow("srcpic", srcImage);
        Mat element = getStructuringElement(MORPH_RECT, Size(15, 15));
        Mat dstImage;
        erode(srcImage, dstImage, element);
        imshow("dstpic", dstImage);
        waitKey(0);

        return 0;
    }

    #endif

    #if 0
    int main() {
        Mat srcImage = imread("C:\pics\index.jpg");
        imshow("均值滤波[原图]", srcImage);

        Mat dstImage;
        blur(srcImage, dstImage, Size(7, 7));
        imshow("均值滤波[效果图]", dstImage);

        waitKey(0);


    }



    int main() {
        Mat srcImage = imread("C:\pics\index.jpg");
        imshow("均值滤波[原图]", srcImage);

        Mat edge,grayImage;
        cvtColor(srcImage, grayImage, CV_BGR2GRAY);

        blur(grayImage, edge, Size(3, 3));

        Canny(edge, edge, 3, 9, 3);
        imshow("均值滤波[效果图1]", edge);

        Canny(edge, edge, 5, 9, 3);
        imshow("均值滤波[效果图2]", edge);

        waitKey(0);


    }

    #endif

    int main() {
        VideoCapture capture(1);
        Mat edges;
        while (1) {
            Mat frame;
            capture >> frame;

            cvtColor(frame, edges, COLOR_BGR2GRAY);
            blur(edges, edges, Size(7, 7));
            Canny(edges, edges, 0, 30, 3);
            imshow("canny后的视频", edges);
            if (waitKey(30) >= 0) break;
        
        }

        return 0;
    }

  • 相关阅读:
    10. Regular Expression Matching
    9. Palindrome Number (考虑负数的情况)
    8. String to Integer (整数的溢出)
    7. Reverse Integer (整数的溢出)
    LeetCode Minimum Size Subarray Sum
    LeetCode Course Schedule II
    Linux 文件缓存 (一)
    LeetCode Tries Prefix Tree
    Linux : lsof 命令
    LeetCode Binary Tree Right Side View
  • 原文地址:https://www.cnblogs.com/Montauk/p/7486146.html
Copyright © 2011-2022 走看看