• 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;
    }

  • 相关阅读:
    单例模式
    leetcode:Minimum Subarray
    leetcode:Minimum Path Sum
    内存分配以及优化
    完整性检查
    类型定义之可选的一些笔记
    CSS|CSS module
    TS 操作符
    React|虚拟 Dom、render函数、shouldComponentUpdate
    React|常用相关框架
  • 原文地址:https://www.cnblogs.com/Montauk/p/7486146.html
Copyright © 2020-2023  润新知