-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·137 lines (122 loc) · 3.7 KB
/
Copy pathmain.cpp
File metadata and controls
executable file
·137 lines (122 loc) · 3.7 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
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
133
134
135
136
137
//#include "Process.h"
//#include "FileProcess.h"
#include <opencv2/core.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <vector>
#include "Eigen/Eigen"
#include "Eigen/Core"
#include "Eigen/Dense"
#include <iostream>
#include "Net.h"
#include "FileProcess.h"
#include "Process.h"
using namespace Eigen;
using namespace std;
using namespace cv;
int main() {
Process pro;
Model model;
if(!model.LoadParam())return 0;
FileReader fileReader("../database");
char* fileDirect;
fileDirect = (char*)malloc(sizeof(char)*100);
char ImagePath[100];
char *letter;
letter = (char*)malloc(sizeof(char)*4);
char *name;
name = (char*)malloc(sizeof(char)*20);
char *saveImageName;
saveImageName = (char*)malloc(sizeof(char)*20);
double possibility = 1;
int count = 0;
while(fileReader.findNext(fileDirect))
{
sprintf(ImagePath, "../database/%s", fileDirect);
pro.Update(ImagePath);
// pro.Display(fileDirect,true,count++);
possibility = 1;
memset(name,'\0',20);
memset(letter,'\0',4);
memset(saveImageName,'\0',20);
possibility *= model.Fit(pro.area[0],BLOCK_HEIGHT,BLOCK_WIDTH,letter,true);
#if SAVE_POOL==1
strcat(saveImageName,letter);
strcat(saveImageName,"pool1.jpg");
imwrite(saveImageName,pool1Src);
memset(saveImageName,'\0',20);
strcat(saveImageName,letter);
strcat(saveImageName,"pool2.jpg");
imwrite(saveImageName,pool2Src);
#endif
strcat(name,letter);
memset(letter,'\0',4);
possibility *= model.Fit(pro.area[1],BLOCK_HEIGHT,BLOCK_WIDTH,letter,false);
if(strcmp(letter,"0") == 0)letter[0] = 'O';
strcat(name,letter);
for(int i = 0; i < 5; i++)
{
memset(letter,'\0',4);
possibility *= model.Fit(pro.letters[i],BLOCK_HEIGHT,BLOCK_WIDTH,letter,false);
#if SAVE_POOL==1
memset(saveImageName,'\0',20);
strcat(saveImageName,letter);
strcat(saveImageName,"pool1.jpg");
imwrite(saveImageName,pool1Src);
memset(saveImageName,'\0',20);
strcat(saveImageName,letter);
strcat(saveImageName,"pool2.jpg");
imwrite(saveImageName,pool2Src);
#endif
strcat(name,letter);
}
cout<<"NAME: "<<name<<" POSSIBILITY: "<<1 - possibility<<endl;
Mat src = imread(ImagePath);
pyrDown(src,src);
pyrDown(src,src);
while(waitKey(20) != 27)
{
imshow("src",src);
}
}
// Mat src = imread("/home/ljh/文档/FPGA/Test/1613009717927.jpg");
// Mat dst,o,al;
// pyrDown(src,dst);
// pyrDown(dst,dst);
// Mat channels[3];
// split(dst,channels);
//
// uchar lutData[256];
// for(int i = 0; i < 256; i++)
// {
// lutData[i] = (i > 170)?(255):(0);
// }
// Mat lut(1, 256, CV_8UC1, lutData);
// LUT(channels[0], lut, al);
//
// for(int i = 0 ;i < dst.rows; i++)
// {
// for( int j = 0; j < dst.cols; j++)
// {
// if(al.at<uchar>(i,j) == 255)continue;
// al.at<uchar>(i,j) = (channels[1].at<uchar>(i,j) > 120 || channels[2].at<uchar>(i,j) > 160)?(200)
// :((channels[1].at<uchar>(i,j) > 80 || channels[2].at<uchar>(i,j) > 100)?(180):(0));
// }
// }
// Mat z = Mat(dst.rows,dst.cols,CV_8UC1);
//
//
// vector<Mat> channels1;
// channels1.push_back(z);
// channels1.push_back(z);
// channels1.push_back(al);
// merge(channels1,o);
//
// while (waitKey(20) != 27)
// {
// imshow("b",channels[0]);
// imshow("g",channels[1]);
// imshow("r",channels[2]);
// imshow("o",o);
// }
}