Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
71 lines (59 loc) · 1.88 KB
/
Copy pathmain.cpp
File metadata and controls
71 lines (59 loc) · 1.88 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// main.cpp
// Add Filters
//
// Created by Vivian Zhu on 11/17/18.
// Copyright © 2018 Vivian Zhu. All rights reserved.
//
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <tuple>
#include "OpenFilter.hpp"
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
Mat img_rgb; // image taken in from the user
img_rgb = imread("/Users/vivianzhu/Desktop/testpic.png", 1);
const string filename = "/Users/vivianzhu/Desktop/HSV.txt";
Rect button; // HELP
Filter myFilter;
if (!myFilter.readHSV(filename)) // if there is no file/file is empty
{
// configures the min and max threshold values for each h, s, v value
myFilter.config(img_rgb);
int key = 'i';
int newKey;
// view each h, s, v value by typing "h", "s", or "v" respectively
// view the edge detected image by typing "i"
// when finished setting up values, type "q" to quit
do
{
newKey = waitKey(100);
if(newKey == 'h')
key = newKey;
else if(newKey == 's')
key = newKey;
else if(newKey == 'v')
key = newKey;
else if(newKey == 'i')
key = 0;
Mat res = myFilter.edgeDetect(&img_rgb);
if(key == 'h')
res = *myFilter.getH();
else if (key == 's')
res = *myFilter.getS();
else if (key == 'v')
res = *myFilter.getV();
resize(res, res, Size(res.cols/3, res.rows/3));
imshow("Test", res);
}while(newKey != 'q');
myFilter.writeHSV(filename);
destroyWindow("Test");
}
return 0;
}