mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-20 21:40:49 +08:00
text: small adjustments in samples and image preprocessing
This commit is contained in:
@@ -1,12 +1,3 @@
|
||||
/*
|
||||
* 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();
|
||||
|
@@ -1,3 +1,7 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user