簡單寫個接圖的範例
imread
就是讀圖片
#include <iostream>
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace cv;
int main()
{
Mat frame;
string imagePath = ".//pattern.png";
frame = imread(imagePath, IMREAD_COLOR);
string imgname;
int f = 1;
int ch;
while (1)
{
if (frame.empty()) break;
imshow("Camera", frame);
int WK = waitKey(10);
if (WK == 'q')
{
break;
}
else if (WK == 'a')
{
imgname = to_string(f++) + ".jpg";
imwrite(imgname, frame);
}
}
destroyAllWindows();
std::cout << "Finished writing" << endl;
std::cin.get();
return 0;
}