This repository has been archived by the owner on Jun 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
minicli.c
132 lines (108 loc) · 3.4 KB
/
minicli.c
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include <stdio.h>
#include "neuralNetwork/neuralNet.h"
#include <stdlib.h>
#include <stdio.h>
//#include <gtk/gtk.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <unistd.h>
#include "imageTreatment/image.h"
#include "imageTreatment/matrix.h"
#include "imageTreatment/queue.h"
#include "imageTreatment/segmentation.h"
#include "imageTreatment/matrix.h"
#include "neuralNetwork/fromqueue.h"
void image() {
int val = 0;
SDL_Surface *image = NULL;
int h = 0, w = 0;
Pixel **pixels = NULL;
int **matrix = NULL;
Queue *queue;
while (val != 9) {
printf("Image treatment:\n");
printf("\t1-> set path\n");
printf("\t2-> show image\n");
printf("\t3-> run otsu & binarisation\n");
printf("\t4-> show segmentation\n");
printf("\t5-> automatic rotation\n");
printf("\t6-> run text recognotion\n");
printf("\t7-> add values to dataset using image\n");
printf("\t9-> exit\n");
printf("\n> ");
scanf("%d", &val);
switch (val) {
case 1:
printf("Path to picture: ");
char buffer[100];
scanf("%99s", buffer);
image = IMG_Load(buffer);
if (image == NULL) {
printf("Couldn't load %s: %s\n", buffer, SDL_GetError());
} else {
printf("%s successfully loaded\n", buffer);
h = image->h;
w = image->w;
pixels = InitPixelMatrix(h, w);
matrix = InitIntMatrix(h, w);
SurfaceToMatrix(pixels, image, h, w);
}
break;
case 2:
if (image != NULL) {
DisplayImage(MatrixToSurface(pixels, h, w));
}
break;
case 3:
if (image != NULL) {
GreyScale(pixels, h, w);
Median_Filter(pixels, h, w);
int threshold = Otsu(pixels, h, w);
OtsuBinarization(pixels, h, w, threshold);
BinarizeMatrix(pixels, matrix, h, w);
}
break;
case 4:
if (matrix != NULL)
queue = Segmentation(matrix, h, w);
break;
case 5:
if (image != NULL) {
}
break;
case 6:
if (queue == NULL)
break;
char* s = extractstring("test.nn", queue);
printf("String is : \"%s\"\n", s);
free(s);
break;
case 7:
if (queue == NULL)
break;
adddatatoset(queue);
}
}
FreeMatrix((void**)matrix, h);
FreeMatrix((void**)pixels, h);
}
int main() {
int val = 0;
while (val != 3) {
printf("\nExOCRists\n");
printf("\t1-> neural network\n");
printf("\t2-> image treatment\n");
printf("\t3-> exit\n");
printf("\n> ");
scanf("%d", &val);
switch (val) {
case 1:
//neuralnet();
break;
case 2:
image();
break;
}
}
return 0;
}