源代碼:
#include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/core/core.hpp> using namespace cv; //調用攝像頭 int main() { VideoCapture cap(0); Mat frame; while (1) { cap >> frame; imshow("調用攝像頭", frame); waitKey(30); } return 0; }