-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
93 lines (58 loc) · 1.6 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//self made header files
#include "Sudoku.h"
//the trainig image
const string trainImg = "train6.png";
//the sudoku img to be solved
const string SudokuImg = "SudokuPaper2.jpg";
//set explicitly to true when you want to generate the training data for OCR
bool GenrateOCRData = false;
//set explicitly to true when you want to Train the KNN algorithm
//set this to true only when you have generated the data and copied it in the right folder
bool TrainAndTest = false;
//load the sudoku from a sudoku image in the computer
bool loadSudokuImg = true;
//grab sudoku from the camerafeed
bool captureSudokuFromCamera = false;
int main()
{
OCR recognizeDigits;
if (GenrateOCRData == true){
//generate the OCR data
recognizeDigits.genData(trainImg);
}
if (TrainAndTest == true){
///recognize the digits
//recognizeDigits.Train();
}
Sudoku sudoku;
if (loadSudokuImg == true){
//get the sudoku image to be solved
sudoku.getSudoku(SudokuImg);
//process the loaded sudoku
sudoku.processSudoku(loadSudokuImg);
sudoku.sendDigitsToOCR();
sudoku.printInputSudoku();
bool isSolved = sudoku.Solve();
if (isSolved == true){
sudoku.printSolvedSudoku();
sudoku.overlayResult();
}
else {
cout << "The provided Sudoku can't be Solved!!!!\n";
system("PAUSE");
}
}
else if (captureSudokuFromCamera == true){
VideoCapture cap;
cap.open(0);
if (!cap.isOpened()){
cout << "couldnt open the webcam\nExiting the program........";
return 0;
}
while (1){
sudoku.captureSudoku(cap);
sudoku.processSudoku(loadSudokuImg);
}
}
return 0;
}