-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (45 loc) · 1.22 KB
/
main.cpp
File metadata and controls
49 lines (45 loc) · 1.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
#include <iostream>
#include <unistd.h>
#include "slic.h"
#include <opencv2/imgcodecs.hpp>
void usage()
{
std::cout << "Usage: SLIC_Superpixel -i inputFile -o outputFile" << std::endl;
}
int main(int argc, char *argv[])
{
extern char *optarg;
extern int optopt;
std::string inputFile, outputFile;
bool errorOpt = false;
int c;
while ((c = getopt(argc, argv, ":i:o:")) != -1) {
switch (c) {
case 'i':
inputFile = optarg;
break;
case 'o':
outputFile = optarg;
break;
case ':':
std::cout << "Option -" << (char)optopt << " requires filename." << std::endl;
errorOpt = true;
break;
case '?':
std::cout << "Unrecognized option: -" << (char)optopt << std::endl;
errorOpt = true;
break;
}
}
if (errorOpt || argc < 5) {
usage();
return -1;
}
cv::Mat inputMatrix = cv::imread(inputFile);
const int numberOfSupperpixels = 400;
const int compactness = 20;
const double treshold = 30.0;
superpixel::SLIC slic;
slic.getSupperpixels(inputMatrix, numberOfSupperpixels, compactness, treshold);
return 0;
}