-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
54 lines (37 loc) · 1.25 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
48
49
50
51
52
53
54
#include "detect-lines.h"
//#include "known-good.h"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/ximgproc.hpp"
#include "opencv2/xfeatures2d.hpp"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <fstream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
// Declare the output variables
//Mat dst, cdst, cdstP;
//![load]
const char* default_file = "../data/sudoku.png";
const char* filename = argc >= 2 ? argv[1] : default_file;
const char* outPath = argc >= 3 ? argv[2] : ".";
Mat src = imread(filename);// , IMREAD_GRAYSCALE);
auto lam = [outPath](std::string name, cv::InputArray img) {
std::replace(name.begin(), name.end(), ' ', '_');
imwrite(outPath + ('/' + name) + ".jpg", img);
};
auto lines = imaging::calculating(filename, lam);
Scalar color = Scalar(0, 255, 0);
int radius = 2;
int thickness = -1;
for (auto& line : lines) {
circle(src, Point(std::get<0>(line), std::get<1>(line)), radius, color, thickness);
circle(src, Point(std::get<2>(line), std::get<3>(line)), radius, color, thickness);
}
imshow("Reduced Lines", src);
waitKey();
}