opencv基础

来源:互联网 发布:怎么盗用淘宝视频 编辑:程序博客网 时间:2024/05/22 02:27

显示图片

#include<opencv2/opencv.hpp>#include<highgui.h>using namespace cv;using namespace std;int main(){    Mat mat;    mat=imread("D:\\test.jpg");    if(mat.empty())    {        cout<<"读取失败!";        return -1;    }    imshow("image",mat);    waitKey(0);    return 0;}

显示视频

#include<opencv2/opencv.hpp>#include<highgui.h>using namespace cv;using namespace std;int main(){    VideoCapture cap(0);    Mat frame;    while(1)    {        cap>>frame;        imshow("videoTest",frame);        char esc=(char)waitKey(33);        if(27==esc)            break;    }    return 0; }
原创粉丝点击