1バッチ読み取りグロブ
glob関数はopencv4.xバージョンで提供されており、Directoryクラスは以前のバージョンで使用できます。
int main() {
//批量读取
string src_path = "E:\\Toky\\VsProject\\ColoNavigation\\ColoNavi_Opencv\\ColoNavi_Opencv\\data\\";
vector<cv::String> file_vec;
glob(src_path + "*.jpg", file_vec, false);
int i = 1; //图片递增命名
for (string file_name : file_vec)
{
cout << file_name << endl;
//你自己的处理操作
result = reconstruction(mask, image);
//写入文件夹下
imwrite(src_path+"after_remove_hilight\\"+ to_string(i)+".jpg", result);
showImge("result", result);
i++;
}
2バッチ書き込みimwrite
ここでのto_string は、画像を保存するときにバッチ書き込み用に整数を文字列に変換することに注意してください
imwrite(src_path+"after_remove_hilight\\"+ to_string(i)+".jpg", result);
参照元: