Skip to content

Commit

Permalink
修复:scoreToTextLine方法索引越界问题
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminwan committed Oct 17, 2022
1 parent d14f23c commit 5fe2bdc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
8 changes: 2 additions & 6 deletions src/AngleNet.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ AngleNet::AngleNet() {}

AngleNet::~AngleNet() {
delete session;
for (auto name : inputNames) {
free(name);
}
for (auto name : outputNames) {
free(name);
}
inputNames.clear();
outputNames.clear();
}

void AngleNet::setNumThread(int numOfThread) {
Expand Down
14 changes: 6 additions & 8 deletions src/CrnnNet.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ CrnnNet::CrnnNet() {}

CrnnNet::~CrnnNet() {
delete session;
for (auto name: inputNames) {
free(name);
}
for (auto name: outputNames) {
free(name);
}
inputNames.clear();
outputNames.clear();
}

void CrnnNet::setNumThread(int numOfThread) {
Expand Down Expand Up @@ -76,8 +72,10 @@ TextLine CrnnNet::scoreToTextLine(const std::vector<float> &outputData, int h, i
float maxValue;

for (int i = 0; i < h; i++) {
maxIndex = int(argmax(&outputData[i * w], &outputData[(i + 1) * w]));
maxValue = float(*std::max_element(&outputData[i * w], &outputData[(i + 1) * w]));
int start = i * w;
int stop = (i + 1) * w - 1;
maxIndex = int(argmax(&outputData[start], &outputData[stop]));
maxValue = float(*std::max_element(&outputData[start], &outputData[stop]));

if (maxIndex > 0 && maxIndex < keySize && (!(i > 0 && maxIndex == lastIndex))) {
scores.emplace_back(maxValue);
Expand Down
8 changes: 2 additions & 6 deletions src/DbNet.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ DbNet::DbNet() {}

DbNet::~DbNet() {
delete session;
for (auto name : inputNames) {
free(name);
}
for (auto name : outputNames) {
free(name);
}
inputNames.clear();
outputNames.clear();
}

void DbNet::setNumThread(int numOfThread) {
Expand Down

0 comments on commit 5fe2bdc

Please sign in to comment.