读入
读取图片
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
int main(int argc, char** argv) {
String path = "../data/1.jpg";
Mat img;
img = imread(path);
imshow("标签名字", img);
waitKey(0); //延迟毫秒,0为等待按键
return 0;
}
读取视频 / 调用摄像头
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
int main(int argc, char** argv) {
Mat img;
//VideoCapture cap("../data/test_video_1.mp4");
VideoCapture cap(0); //读取摄像头
while(true){
cap.read(img);
imshow("img", img);
waitKey(10);
}
return 0;
}