"test/git@developer.sourcefind.cn:gaoqiong/yaml-cpp.git" did not exist on "c314860e005a4c3266964a46b918ddac86657857"
Commit 5fe2bdc6 authored by benjaminwan's avatar benjaminwan
Browse files

修复:scoreToTextLine方法索引越界问题

parent d14f23c4
...@@ -6,12 +6,8 @@ AngleNet::AngleNet() {} ...@@ -6,12 +6,8 @@ AngleNet::AngleNet() {}
AngleNet::~AngleNet() { AngleNet::~AngleNet() {
delete session; delete session;
for (auto name : inputNames) { inputNames.clear();
free(name); outputNames.clear();
}
for (auto name : outputNames) {
free(name);
}
} }
void AngleNet::setNumThread(int numOfThread) { void AngleNet::setNumThread(int numOfThread) {
......
...@@ -7,12 +7,8 @@ CrnnNet::CrnnNet() {} ...@@ -7,12 +7,8 @@ CrnnNet::CrnnNet() {}
CrnnNet::~CrnnNet() { CrnnNet::~CrnnNet() {
delete session; delete session;
for (auto name: inputNames) { inputNames.clear();
free(name); outputNames.clear();
}
for (auto name: outputNames) {
free(name);
}
} }
void CrnnNet::setNumThread(int numOfThread) { void CrnnNet::setNumThread(int numOfThread) {
...@@ -76,8 +72,10 @@ TextLine CrnnNet::scoreToTextLine(const std::vector<float> &outputData, int h, i ...@@ -76,8 +72,10 @@ TextLine CrnnNet::scoreToTextLine(const std::vector<float> &outputData, int h, i
float maxValue; float maxValue;
for (int i = 0; i < h; i++) { for (int i = 0; i < h; i++) {
maxIndex = int(argmax(&outputData[i * w], &outputData[(i + 1) * w])); int start = i * w;
maxValue = float(*std::max_element(&outputData[i * w], &outputData[(i + 1) * 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))) { if (maxIndex > 0 && maxIndex < keySize && (!(i > 0 && maxIndex == lastIndex))) {
scores.emplace_back(maxValue); scores.emplace_back(maxValue);
......
...@@ -5,12 +5,8 @@ DbNet::DbNet() {} ...@@ -5,12 +5,8 @@ DbNet::DbNet() {}
DbNet::~DbNet() { DbNet::~DbNet() {
delete session; delete session;
for (auto name : inputNames) { inputNames.clear();
free(name); outputNames.clear();
}
for (auto name : outputNames) {
free(name);
}
} }
void DbNet::setNumThread(int numOfThread) { void DbNet::setNumThread(int numOfThread) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment