一些短代码

来源:互联网 发布:软件开发技术培训 编辑:程序博客网 时间:2024/05/19 03:42

1.读视频文件或打开摄像头

VideoCapture cap;    if (argc > 1)        cap.open(argv[1]);    else        cap.open(0);    if (!cap.isOpened())    {        std::cerr << "Cannot read video. Try moving video file to sample directory." << std::endl;        return -1;    }

2.Convert OpenCV Mat type to IplImage * type. OpenCV Mat 类型转化为IplImage*指针类型

Mat srcImg;                         // Mat type variable .IplImage *resIplPtr = NULL;         // Initialize by NULL.srcImg = imread(imagePath);         // read image;         resIplPtr = &(IplImage(srcImg));    // Mat to IplImage Pointer resIplPtr = NULL;                   // set as NULL.
0 0
原创粉丝点击