string file_path = "D:/MEC/Data/test_rect_data/";
string save_val_path = "../data/val/";

for (int idx = 0; idx < 1000; idx++) {
file_name = to_string(rand() % 8630) + "_" + to_string(rand() % 550);
file_path.append(file_name + ".jpg");

if (_access(file_path.c_str(), 0) != -1) {
cout << file_path << "          num: " << idx << endl;
// 중복된 사진 거르기
if (find(img_list.begin(), img_list.end(), file_path) != img_list.end()) {
if (idx > -1) {
idx -= 1;
}
//file_path = "../data/val_image/";
save_val_path = "../data/val/";
file_path = "D:/MEC/Data/test_rect_data/";
continue;
}
img_list.push_back(file_path);
img_name_list.push_back(file_name);
val_img = imread(file_path);
save_val_path = "../data/val/" + file_name + ".jpg";
imwrite(save_val_path, val_img);

save_val_path = "../data/val/";
//file_path = "../data/val_image/";
file_path = "D:/MEC/Data/test_rect_data/";
}
else {
save_val_path = "../data/val/";
file_path = "D:/MEC/Data/test_rect_data/";
if (idx > -1) {
idx -= 1;
}
continue;
}

'Language > C++' 카테고리의 다른 글

C++ 시간 재기  (0) 2022.03.14
Mat 형식 Binary file로 저장 및 Binary file 불러오기  (0) 2022.02.22
opencv vector to Mat  (0) 2021.12.23
Image to Base64, Base64 to Image  (0) 2021.11.18
C++ 폴더 존재유무 및 생성  (0) 2021.10.08

+ Recent posts