-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoffline.cpp
47 lines (42 loc) · 1.22 KB
/
offline.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 "effects.h"
#include "kmeans.h"
#include "timing.h"
#include <opencv2/opencv.hpp>
/**
* offline.cpp
* Process single image into comicbook image.
*/
int main(int argc, char** argv)
{
if (argc < 2) {
std::cerr << "usage: <data-file> [k] [iterations] " << std::endl;
std::exit(EXIT_FAILURE);
}
int k = 8, iterations = 100;
if (argc > 2) {
k = std::atoi(argv[2]);
}
if (argc > 3) {
iterations = std::atoi(argv[3]);
}
Mat image = imread(argv[1]);
resize(image, image, Size(640, 480));
START_TIMING();
try {
// Generate effects sequentially
Mat canny_overlay = Effects::canny(image);
Mat means = kmeans(image, Mat(), k, iterations);
Mat posterized = Effects::posterize(image, means);
Mat halftone_overlay = Effects::halftone(image);
// Combine effects
Mat combined = Effects::overlay(canny_overlay, halftone_overlay, posterized);
// Write result to file
imwrite("post.jpg", combined);
} catch (Exception& e) {
std::cout << e.what() << std::endl;
} catch (...) {
std::cout << "Caught unexpected exception!" << std::endl;
}
STOP_TIMING("Frame Time")
return 0;
}