Commit 5fe2bdc6 authored by benjaminwan's avatar benjaminwan
Browse files

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

parent d14f23c4
......@@ -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) {
......
......@@ -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) {
......@@ -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);
......
......@@ -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) {
......
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