OpenCV第一次coding

#include <iostream>

#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;

int main(){

    VideoCapture capture(0);

    Mat img;

    while (!0)
    {
        //读取下一帧
        if (!capture.read(img))
        {
            cout << "读取视频失败" << endl;
            return -1;
        }
        flip(img, img, 1);//Y轴镜像(即水平镜像)

        imshow("Origin", img);
        waitKey(33);
    }
}

业务测试代码:

#include <opencv2/opencv.hpp>


using namespace std;
using namespace cv;

#define QINGAI_API __declspec(dllimport)
#pragma comment(lib,"QingAI.lib")

int main()
{
    // 调用电脑摄像头选择此语句
    VideoCapture capture(0);

    //double rate = 25.0;//视频的帧率
    //Size videoSize(640, 480);
    //VideoWriter writer("VideoTest.avi", CV_FOURCC('M', 'J', 'P', 'G'), rate, videoSize);

    //检测是否正常打开:成功打开时,isOpened返回ture
    if (!capture.isOpened())
        cout << "fail to open!" << endl;

    //定义一个用来控制读取视频循环结束的变量
    bool stop = false;
    //承载每一帧的图像
    Mat img;

    while (!stop)
    {
        //读取下一帧
        if (!capture.read(img))
        {
            cout << "读取视频失败" << endl;
            return -1;
        }
        flip(img, img, 1);//Y轴镜像(即水平镜像)

        imshow("Origin", img);

        ////先将获取的视频帧转为RGBA格式
        //Mat rgba(img.cols, img.rows, CV_8UC4);
        //cvtColor(img, rgba, CV_BGR2RGBA, 4);

        ////调用DLL文件
        ////QingAI_Features((char*)rgba.data, rgba.cols, rgba.rows, 0);

        //QingAI_Makeup((char*)rgba.data, rgba.cols, rgba.rows, 0,  10, 50);
        //
        //QingAI_Sticker((char*)rgba.data, rgba.cols, rgba.rows, 1, 1); 

        ////显示处理后的图片
        //Mat Reimg;
        //cvtColor(rgba, Reimg, CV_RGBA2BGR, 4);
        //imshow("Processed", Reimg);

        waitKey(1);

        //writer << Reimg;

    }
}

 

posted @ 2020-04-01 14:02  老三的博客  阅读(187)  评论(0编辑  收藏  举报