Skip to content

Commit 9195d2e

Browse files
committed
text: small adjustments in samples and image preprocessing
1 parent fb0338f commit 9195d2e

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

modules/text/samples/dictnet_demo.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
/*
2-
* dictnet_demo.cpp
3-
*
4-
* Demonstrates simple use of the holistic word classifier in C++
5-
*
6-
* Created on: June 26, 2016
7-
* Author: Anguelos Nicolaou <anguelos.nicolaou AT gmail.com>
8-
*/
9-
101
#include "opencv2/text.hpp"
112
#include "opencv2/highgui.hpp"
123
#include "opencv2/imgproc.hpp"

modules/text/samples/textbox_demo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ std::string getHelpStr(const std::string& progFname)
1414
{
1515
std::stringstream out;
1616
out << " Demo of text detection CNN for text detection." << std::endl
17-
<< " Max Jaderberg et al.: Reading Text in the Wild with Convolutional Neural Networks, IJCV 2015"<<std::endl<<std::endl
17+
<< " Minghui Liao, Baoguang Shi, Xiang Bai, Xinggang Wang, Wenyu Liu: TextBoxes: A Fast Text Detector with a Single Deep Neural Network, AAAI2017\n\n"
1818
<< " Usage: " << progFname << " <output_file> <input_image>" << std::endl
1919
<< " Caffe Model files (textbox.prototxt, TextBoxes_icdar13.caffemodel)"<<std::endl
2020
<< " must be in the current directory. See the documentation of text::TextDetectorCNN class to get download links." << std::endl;
2121
return out.str();
2222
}
2323

24-
bool fileExists (std::string filename)
24+
bool fileExists (const std::string& filename)
2525
{
2626
std::ifstream f(filename.c_str());
2727
return f.good();

modules/text/src/ocr_holistic.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// This file is part of OpenCV project.
2+
// It is subject to the license terms in the LICENSE file found in the top-level directory
3+
// of this distribution and at http://opencv.org/license.html.
4+
15
#include "precomp.hpp"
26
#include "opencv2/imgproc.hpp"
37
#include "opencv2/core.hpp"

modules/text/src/text_detectorCNN.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
#include "precomp.hpp"
66
#include "opencv2/imgproc.hpp"
77
#include "opencv2/core.hpp"
8+
#include "opencv2/dnn.hpp"
89

910
#include <fstream>
1011
#include <algorithm>
1112

12-
#include "opencv2/dnn.hpp"
13-
1413
using namespace cv::dnn;
1514

1615
namespace cv
@@ -75,20 +74,22 @@ class TextDetectorCNNImpl : public TextDetectorCNN
7574
void detect(InputArray inputImage_, std::vector<Rect>& Bbox, std::vector<float>& confidence)
7675
{
7776
CV_Assert(inputImage_.channels() == inputChannelCount_);
78-
Mat inputImage = inputImage_.getMat().clone();
77+
Size inputSize = inputImage_.getMat().size();
7978
Bbox.resize(0);
8079
confidence.resize(0);
8180

8281
for(size_t i = 0; i < sizes_.size(); i++)
8382
{
8483
Size inputGeometry = sizes_[i];
84+
Mat inputImage = inputImage_.getMat().clone();
85+
resize(inputImage, inputImage, inputGeometry);
8586
net_.setInput(blobFromImage(inputImage, 1, inputGeometry, Scalar(123, 117, 104)), "data");
8687
Mat outputNet = net_.forward();
8788
int nbrTextBoxes = outputNet.size[2];
8889
int nCol = outputNet.size[3];
8990
int outputChannelCount = outputNet.size[1];
9091
CV_Assert(outputChannelCount == 1);
91-
getOutputs((float*)(outputNet.data), nbrTextBoxes, nCol, Bbox, confidence, inputImage.size());
92+
getOutputs((float*)(outputNet.data), nbrTextBoxes, nCol, Bbox, confidence, inputSize);
9293
}
9394
}
9495
};

0 commit comments

Comments
 (0)