opencv2获取计算机摄像头并显示

来源:互联网 发布:目前主流java开发框架 编辑:程序博客网 时间:2024/05/05 08:50

成功运行

#include "opencv2/highgui/highgui.hpp"

#include <iostream>
#include <vector>
#include <stdio.h>


using namespace cv;
using namespace std; 

int main (int argc, const char * argv[])
{
    cvNamedWindow("ccav", 1);
     
    CvCapture *capture = cvCaptureFromCAM(0);
     
    if (!capture)
    {
        printf("get camera error!\n");
        exit(1);
    }
     
    IplImage *frame;
    int key = 0;
     
    while (1 > key)
    {
        frame = cvQueryFrame(capture);
         
        cvShowImage("ccav", frame);
         
        key = cvWaitKey(10);
    }
 
    cvReleaseCapture(&capture);
    cvDestroyWindow("ccav");
     
    return 0;

}


其实是opencv1的东东。




0 0
原创粉丝点击