因为要标定相机,所以小编写了个自动拍照并按顺序保存图片到指定文件夹的程序

#include\"stdafx.h\"
#include <opencv2/highgui/highgui.hpp>  
#include <opencv2/imgproc/imgproc.hpp>  
#include <opencv2/core/core.hpp>  

using namespace cv;
 
int main()
{
VideoCapture cap(0);
    Mat  ;
    char key;
    char filename[200];
    int i = 8;
         while (true)
         {
             string filename = \"/home/shangbinbin/opencv_linux_test/test1/\" +to_string(i)+\".jpg\";
             char key = waitKey(100);
             cap >>  ;
             imshow(\" \",  )
                     switch (key)
                     {
                     case\'p\':
                         i++;
                         imwrite(filename,  );
                         imshow(\"photo\",  );
                         waitKey(500);
                         destroyWindow(\"photo\");
                         break;
                     default:
                         break;
                     }
         }
   waitKey(0);
   return 0;
}

收藏 打印