-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
78 lines (67 loc) · 2.22 KB
/
Copy pathmain.cpp
File metadata and controls
78 lines (67 loc) · 2.22 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <iostream>
#include <opencv2/opencv.hpp>
#include <filesystem>
#include "src/mozaic.h"
#include <chrono>
using namespace std;
using namespace cv;
namespace fs = std::filesystem;
int main() {
images img;
segments seg;
vector<Mat> bestTilesMean, bestTilesHist;
int noSegments;
fs::path tilesPath("C:\\FACULTATE\\3.2\\PI\\PROIECT\\Mozaic\\images\\tiles");
if (!fs::exists(tilesPath)) {
fs::create_directory(tilesPath);
generateTiles();
std::cout << "Folder doesnt exist. I created it and generated the tiles." << std::endl;
}
else if(fs::is_empty(tilesPath)){
generateTiles();
cout << "I generated the tiles" << endl;
}
else{
cout << "Tiles folder already contains tiles" << endl;
}
try{
img = loadImages("leaf");
noSegments = processOriginal(img.source);
}
catch(runtime_error& e){
//prindem eroare pentru numele incorect al imaginii mari
cerr << e.what() << endl;
return 0;
}
try{
seg = imageSegmentation(img.source, noSegments);
}
catch(runtime_error& e){
//prindem eroarea de dimensiune
cerr << e.what() << endl;
return 0;
}
try{
auto start = chrono::high_resolution_clock::now();
bestTilesMean = findBestMatches(seg, img.tiles, 1);
auto end = chrono::high_resolution_clock::now();
double duration = chrono::duration_cast<chrono::seconds>(end - start).count();
printf("\n Duration for means method: %lf seconds\n",duration);
start = chrono::high_resolution_clock::now();
bestTilesHist = findBestMatches(seg, img.tiles, 2);
end = chrono::high_resolution_clock::now();
duration = chrono::duration_cast<chrono::seconds>(end - start).count();
printf("\n Duration for histograms method: %lf seconds\n",duration);
}
catch(runtime_error& e){
//prindem eroarea pentru optiune invalida
cerr << e.what() << endl;
return 0;
}
Mat result1 = composeMosaic(img.source, seg, bestTilesMean);
Mat result2 = composeMosaic(img.source, seg, bestTilesHist);
imshow("Result1", result1);
imshow("Result2", result2);
waitKey(0);
return 0;
}