linux 下
头文件:
#include <boost/format.hpp>
boost::format fmt_others("%06d.png");//6个占位符
for (int i = 1; i < 6; i++) { // 1~10
cv::Mat img = cv::imread((fmt_others % i).str(), 0);
//百分号后面是需要的值
}
std::cout<<boost::format("%2% \n %1% \n %3%" )%"first"%"second"%"third";
将会输出
second
first
third
#include <iostream>
#include <opencv2/opencv.hpp>
#include <boost/format.hpp>
using namespace cv;
using namespace std;
int main(int argc, char *argv[])
{
VideoCapture cp(0);
Mat save_img;
boost::format save_name("hander_zeros_%06d.png");//6个占位符
cout <<(save_name % 1).str() << endl;
while (cp.isOpened()) {
cp >> save_img;
imshow("video",save_img);
char key = waitKey(5);
if(key == 27)
break;
}
cout << "Hello World!" << endl;
return 0;
}