Ubuntu16.04下OpenCV調用筆記本攝像頭


1,新建一個test.cpp文件,插入下列代碼,保存

#include<opencv2/opencv.hpp>
#include<iostream>
 
using namespace std;
using namespace cv;
 
int main(int argc,char **argv)
{
    VideoCapture capture(0);
    namedWindow("myCamera",CV_WINDOW_AUTOSIZE);
    while(true)
    {    
        Mat frame;
        capture>>frame;
        imshow("myCamera",frame);
        waitKey(30);
    }
    return 0;
}

2,生成可執行程序test

$ g++ `pkg-config opencv --cflags` test.cpp -o test `pkg-config opencv --libs`

注意:這里是``(鍵盤Tab上面的那個鍵),而不是單引號' '

3,運行test,即可調用攝像頭

$ ./test

注意:可使用Ctrl + c 終止當前正在運行的程序


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM