#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; }
$ g++ `pkg-config opencv --cflags` test.cpp -o test `pkg-config opencv --libs`
注意:這裏是``(鍵盤Tab上面的那個鍵),而不是單引號' 'ios
$ ./test
注意:可以使用Ctrl + c 終止當前正在運行的程序ide