Commit 9195d2e6 authored by Vladislav Sovrasov's avatar Vladislav Sovrasov

text: small adjustments in samples and image preprocessing

parent fb0338fb
/*
* dictnet_demo.cpp
*
* Demonstrates simple use of the holistic word classifier in C++
*
* Created on: June 26, 2016
* Author: Anguelos Nicolaou <anguelos.nicolaou AT gmail.com>
*/
#include "opencv2/text.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
......
......@@ -14,14 +14,14 @@ std::string getHelpStr(const std::string& progFname)
{
std::stringstream out;
out << " Demo of text detection CNN for text detection." << std::endl
<< " Max Jaderberg et al.: Reading Text in the Wild with Convolutional Neural Networks, IJCV 2015"<<std::endl<<std::endl
<< " Minghui Liao, Baoguang Shi, Xiang Bai, Xinggang Wang, Wenyu Liu: TextBoxes: A Fast Text Detector with a Single Deep Neural Network, AAAI2017\n\n"
<< " Usage: " << progFname << " <output_file> <input_image>" << std::endl
<< " Caffe Model files (textbox.prototxt, TextBoxes_icdar13.caffemodel)"<<std::endl
<< " must be in the current directory. See the documentation of text::TextDetectorCNN class to get download links." << std::endl;
return out.str();
}
bool fileExists (std::string filename)
bool fileExists (const std::string& filename)
{
std::ifstream f(filename.c_str());
return f.good();
......
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "precomp.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/core.hpp"
......
......@@ -5,12 +5,11 @@
#include "precomp.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/core.hpp"
#include "opencv2/dnn.hpp"
#include <fstream>
#include <algorithm>
#include "opencv2/dnn.hpp"
using namespace cv::dnn;
namespace cv
......@@ -75,20 +74,22 @@ public:
void detect(InputArray inputImage_, std::vector<Rect>& Bbox, std::vector<float>& confidence)
{
CV_Assert(inputImage_.channels() == inputChannelCount_);
Mat inputImage = inputImage_.getMat().clone();
Size inputSize = inputImage_.getMat().size();
Bbox.resize(0);
confidence.resize(0);
for(size_t i = 0; i < sizes_.size(); i++)
{
Size inputGeometry = sizes_[i];
Mat inputImage = inputImage_.getMat().clone();
resize(inputImage, inputImage, inputGeometry);
net_.setInput(blobFromImage(inputImage, 1, inputGeometry, Scalar(123, 117, 104)), "data");
Mat outputNet = net_.forward();
int nbrTextBoxes = outputNet.size[2];
int nCol = outputNet.size[3];
int outputChannelCount = outputNet.size[1];
CV_Assert(outputChannelCount == 1);
getOutputs((float*)(outputNet.data), nbrTextBoxes, nCol, Bbox, confidence, inputImage.size());
getOutputs((float*)(outputNet.data), nbrTextBoxes, nCol, Bbox, confidence, inputSize);
}
}
};
......
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