forked from ryanpeach/openscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unused.cpp
54 lines (46 loc) · 1.31 KB
/
unused.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
#import "tests.hpp"
void imageProcess (Mat frame, Capture* c) {
// Variable Declaration
Mat drawing, preview;
string filename,filepath;
// Create Windows
vector<Mat*> images = vector<Mat*>{&drawing, &preview};
vector<string> names = vector<string>{
"Frame: Press 'q' to exit.",
"Preview: Press 's' to save."};
WindowManager win = WindowManager(images, names);
vector<Mat> proc = c->process();
// Save processed frame to appropriate outputs
if (!proc.empty()) {
drawing = proc[0];
preview = proc[1];
} else {
cout << "No scan found." << endl;
win.close();
return;
}
// Show frame out and preview
win.update();
for (;;) {
// Save File
if (cvWaitKey(10) == 's') {
filename = std::tmpnam(NULL);
filepath = "scans/" + filename + ".jpg";
imwrite(filepath, preview);
#ifdef TEST
cout << "webCam: Saved as: " << filepath << endl;
#endif
}
// Quit
if (cvWaitKey(10) == 'q') {break;}
}
win.close();
}
void imageFile (char *filepath, Capture* c) {
Mat cap = imread(filepath);
if (!cap.empty()) {
std::cout << "!!! Failed to open file: " << filepath << std::endl;
return;
}
imageProcess(cap, c);
}