-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
47 lines (36 loc) · 1.13 KB
/
main.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
#include "GNG.h" // also includes "Image.h"
#include <string>
#include <iostream>
int main(int argc, char const *argv[])
{
if( argc != 3)
{
std::cout <<"GNG: Image path and output directory arguments are required\n";
return -1;
}
/* Set files */
const std::string imgpath = argv[1];
const std::string filename = imgpath.substr(imgpath.find_last_of("/\\") + 1);
const std::string outdir = argv[2];
/* Apply sobel */
cv::Mat img = cv::imread(imgpath);
cv::Mat imgSobel;
std::cout << "\nApplying sobel mask to image: " << outdir << "/sobel-" << filename;
Image::sobel(img, imgSobel);
cv::imwrite(outdir + "/sobel-" + filename, imgSobel);
/* Train GNG with image with sobel mask */
GNGTraits traits; // using default traits
/* Example custom traits:
traits.eb = 0.005;
traits.en = 0.003;
traits.maxAge = 20;
traits.lambda = 10;
traits.alpha = 0.01;
traits.beta = 0.02;
*/
std::cout << "\nBeggining training\n";
GNG gng(traits, outdir + "/sobel-" + filename, outdir);
gng.train(); // maxIterations, lineThick, exportMP4, int fps
std::cout << "\nTraining ended";
return 0;
}