-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plate.cpp
executable file
·51 lines (46 loc) · 1.38 KB
/
Plate.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
/*****************************************************************************
* Number Plate Recognition using SVM and Neural Networks
******************************************************************************
* by Ronnie Leon Ochieng, 26th March 2024
******************************************************************************/
#include "Plate.h"
Plate::Plate(){
}
Plate::Plate(Mat img, Rect pos){
plateImg=img;
position=pos;
}
string Plate::str(){
string result="";
//Order numbers
vector<int> orderIndex;
vector<int> xpositions;
for(int i=0; i< charsPos.size(); i++){
orderIndex.push_back(i);
xpositions.push_back(charsPos[i].x);
}
float min=xpositions[0];
int minIdx=0;
for(int i=0; i< xpositions.size(); i++){
min=xpositions[i];
minIdx=i;
for(int j=i; j<xpositions.size(); j++){
if(xpositions[j]<min){
min=xpositions[j];
minIdx=j;
}
}
int aux_i=orderIndex[i];
int aux_min=orderIndex[minIdx];
orderIndex[i]=aux_min;
orderIndex[minIdx]=aux_i;
float aux_xi=xpositions[i];
float aux_xmin=xpositions[minIdx];
xpositions[i]=aux_xmin;
xpositions[minIdx]=aux_xi;
}
for(int i=0; i<orderIndex.size(); i++){
result=result+chars[orderIndex[i]];
}
return result;
}