学习笔记 opencv(opencv视频基础操作-播放视频并处理图像)

 学习笔记 opencv(opencv视频基础操作-播放视频并处理图像)

 

 代码:

#include<opencv2/opencv.hpp>

using namespace cv;
int main()
{
    //读取视频
    VideoCapture capture(0);//当capture(0)里面参数为0时则是调用摄像头
    Mat edges;
    Mat test1;
    
    //循环实现每一帧
    while (1)
    {
        Mat frame; //定义一个Mat变量,用于存储每一帧的图像
        capture >> frame; //读取当前帧
        imshow("处理前的视频",frame);//显示处理前的当前帧

        cvtColor(frame, test1, CV_BGR2HLS);//
        imshow("读取处理后视频1", test1);

        cvtColor(frame, edges, CV_BGR2GRAY);//转化BGR彩色图为灰度图
        blur(edges, edges, Size(7, 7));//使用3x3内核来降噪(2x3+1=7)进行模糊
        Canny(edges, edges, 0, 30, 3);//进行canny边缘检测
        imshow("读取处理后视频2",edges); //显示处理后的当前帧
        if (waitKey(30) >= 0)//延时30ms
        {
            break;
        }
    }
    return 0;
}

相关文章:

  • 2022-12-23
  • 2021-12-15
  • 2021-12-15
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2021-11-27
猜你喜欢
  • 2021-12-04
  • 2021-07-31
  • 2021-11-08
  • 2021-12-15
  • 2021-05-01
  • 2022-12-23
  • 2021-04-05
相关资源
相似解决方案