zoukankan      html  css  js  c++  java
  • Opencv混合高斯模型前景分离

    #include "stdio.h"
    #include "string.h"
    #include "iostream"
    
    #include "opencv/cv.h"
    #include "opencv/cxcore.h"
    #include "opencv/cvaux.h"
    #include "opencv/highgui.h"
    #include "opencv/ml.h"
    #include "opencv2/core/core.hpp"
    #include "opencv2/highgui/highgui.hpp"
    #include "opencv2/imgproc/imgproc.hpp"
    #include "opencv2/video/video.hpp"
    #include "opencv2/videostab/videostab.hpp"
    #include "opencv2/stitching/stitcher.hpp"
    
    #include "opencv2/contrib/contrib.hpp"
    #include "opencv2/objdetect/objdetect.hpp"
    
    
    #pragma comment(lib,"opencv_calib3d2410d.lib")
    #pragma comment(lib,"opencv_contrib2410d.lib")
    #pragma comment(lib,"opencv_core2410d.lib")
    #pragma comment(lib,"opencv_features2d2410d.lib")
    #pragma comment(lib,"opencv_highgui2410d.lib")
    #pragma comment(lib,"opencv_imgproc2410d.lib")
    #pragma comment(lib,"opencv_objdetect2410d.lib")
    #pragma comment(lib,"opencv_video2410d.lib")
    #pragma comment(lib,"opencv_flann2410d.lib")
    #pragma comment(lib,"opencv_gpu2410d.lib")
    #pragma comment(lib,"opencv_legacy2410d.lib")
    #pragma comment(lib,"opencv_ml2410d.lib")
    #pragma comment(lib,"opencv_nonfree2410d.lib")
    #pragma comment(lib,"opencv_ocl2410d.lib")
    #pragma comment(lib,"opencv_photo2410d.lib")
    #pragma comment(lib,"opencv_stitching2410d.lib")
    #pragma comment(lib,"opencv_superres2410d.lib")
    #pragma comment(lib,"opencv_ts2410d.lib")
    #pragma comment(lib,"opencv_stitching2410d.lib")
    using namespace cv;
    using namespace std;
    
    int main()
    {
        VideoCapture capture(0);
        if (!capture.isOpened())
        {
            cout << "读取视频失败" << endl;
            return -1;
        }
    
        Mat frame;
        Mat foreground;
        //使用默认参数调用混合高斯模型
        BackgroundSubtractorMOG mog;
        bool stop(false);
        Sleep(3000);
        while (!stop)
        {
            if (!capture.read(frame))
            {
                cout << "从视频中读取图像失败或者读完整个视频" << endl;
                return -2;
            }
            cv::flip(frame,frame,1);
            cvtColor(frame, frame, CV_RGB2GRAY);
            imshow("输入视频", frame);
            //参数为,输入图像、输出图像、学习速率
            mog(frame, foreground, 0.1);
            imshow("前景", foreground);
    
            //按ESC键退出,按其他键会停止在当前帧
            if (waitKey(33) > 0)
            {
                destroyAllWindows();
                break;
            }
        }
        waitKey(0);
        return 0;
    }
  • 相关阅读:
    SSL证书安装指引
    腾讯云中ssL证书的配置安装
    微信小程序:微信登陆(ThinkPHP作后台)
    TPshop学习(8)微信支付
    LNMP安装Let’s Encrypt 免费SSL证书方法:自动安装与手动配置Nginx
    ruby文档
    tesseract-ocr图片识别开源工具
    Python读写文件
    百度贴吧的网络爬虫(v0.4)源码及解析
    中文分词库
  • 原文地址:https://www.cnblogs.com/mypsq/p/5089135.html
Copyright © 2011-2022 走看看