-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (43 loc) · 1.45 KB
/
main.cpp
File metadata and controls
55 lines (43 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// ImageCropper.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include "ImageCropper.h"
#include "ImageRename.h"
#include <opencv2/opencv.hpp>
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <filesystem>
using namespace std;
using namespace cv;
Mat image;
Mat cropped_image;
string directory = ""; // Add a directory for your screenshots
int FileName = 1;
string extension = ".png";
int CroppedName = 1;
ImageCropper* imageCropper = new ImageCropper();
ImageRename* imageRename = new ImageRename();
// Make a folder (name: Final) in directory
// Select all images, rename it to 1. Then, all images will be renamed to 1 (1), 1 (2), ...
int main()
{
while (true) {
image = imageCropper->loadImages(directory,extension,image,std::to_string(FileName));
if (image.empty()) {
cerr << "Could not open or find the image!" << endl;
break;
}
cropped_image = imageCropper->cropImages(image,cropped_image);
imageCropper->saveCroppedImages(CroppedName,directory,extension,cropped_image);
CroppedName++;
FileName++;
}
string csvFilePath = directory + "Rename.csv"; // CSV file path
imageRename->loadCSV(csvFilePath,directory);
imageRename->RenameFileName(directory, extension);
return 0;
}