-
Notifications
You must be signed in to change notification settings - Fork 1
/
lines.cpp
148 lines (67 loc) · 2.59 KB
/
lines.cpp
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include "include/seam_carving.h"
using namespace cv;
using namespace std;
int main(int argc, char * argv [])
{
//cv::namedWindow("for testing");
if(argc <6) {
std::cout << "Invalid number of arguments" << std::endl;
std::cout << "Arguments are: " << std::endl;
std::cout << "1- Entry Filename " << std::endl;
std::cout << "2- Output Filename " << std::endl;
std::cout << "3- Number of columns r (int)" << std::endl;
std::cout << "4- Cubic smoothing term b (float)" << std::endl;
std::cout << "5- Gaussian sigma smoothing term (float) " << std::endl;
std::cout << "6- Optional Line Completion (int 0 or 1) " << std::endl;
std::cout << "7- Optional SeamCarving Optimization size (int 1 or bigger) " << std::endl;
std::cout << "8- Optional csv output filename " << std::endl;
//cv::waitKey(0);
return 0;
}
std::cout << string(argv[1]) << std::endl;
cv::Mat img = cv::imread(string(argv[1]), 1);
if(img.rows<2) {
std::cout << "Filename does not exist" << std::endl;
//cv::waitKey(0);
return 0;
}
//Seam Carving parameters
std::string rs(argv[3]);
std::string bs(argv[4]);
std::string sigmas(argv[5]);
std::string text_file="";
std::string::size_type sz;
bool complete_lines = false;
int optim =1;
if(argc>=7) {
std::string comp(argv[6]);
int compi = int(std::stof(comp,&sz));
if(compi >=1) complete_lines = true;
}
if(argc>=8) {
std::string optim_size(argv[7]);
int optim_sizei = int(std::stof(optim_size,&sz));
if(optim_sizei >=1) optim = optim_sizei;
}
if(argc>=9) {
std::string file(argv[8]);
text_file=file;
}
int r = int(std::stof(rs,&sz));
float b = std::stof(bs,&sz);
float sigma = std::stof(sigmas,&sz);
std::cout << "Computing seam carving with parameters: " << std::endl;
std::cout << "r " << r << std::endl;
std::cout << "b " << b << std::endl;
std::cout << "sigma " << sigma << std::endl;
Carve::SeamCarving seam(r,b,sigma,img,complete_lines, optim,text_file, true);
seam.computeMedialSeam();
seam.drawMedialSeam(img);
seam.computeCarvedSeams();
seam.drawCarvedSeam(img);
seam.writeMatches();
cv::imwrite(string(argv[2]), img);
std::cout << "Seam Carving Done!!" << std::endl;
//cv::waitKey(0);
return 0;
}