simple cleaning and added comments

pull/1285/head
sghoshcvc 7 years ago
parent 1bc908bdbd
commit 73ddeab66f
  1. 1
      modules/text/include/opencv2/text/erfilter.hpp
  2. 59
      modules/text/src/ocr_holistic.cpp
  3. 7
      modules/text/src/text_detector.cpp
  4. 80
      modules/text/src/text_detectorCNN.cpp

@ -65,6 +65,7 @@ component tree of the image. :
*/
struct CV_EXPORTS ERStat
{
public:
//! Constructor
explicit ERStat(int level = 256, int pixel = 0, int x = 0, int y = 0);

@ -459,56 +459,6 @@ protected:
#endif
}
// void process_(Mat inputImage, Mat &outputMat)
// {
// // do forward pass and stores the output in outputMat
// //Process one image
// CV_Assert(this->minibatchSz_==1);
// //CV_Assert(outputMat.isContinuous());
//#ifdef HAVE_CAFFE
// net_->input_blobs()[0]->Reshape(1, this->channelCount_,this->inputGeometry_.height,this->inputGeometry_.width);
// net_->Reshape();
// float* inputBuffer=net_->input_blobs()[0]->mutable_cpu_data();
// float* inputData=inputBuffer;
// std::vector<Mat> input_channels;
// Mat preprocessed;
// // if the image have multiple color channels the input layer should be populated accordingly
// for (int channel=0;channel < this->channelCount_;channel++){
// cv::Mat netInputWraped(this->inputGeometry_.height, this->inputGeometry_.width, CV_32FC1, inputData);
// input_channels.push_back(netInputWraped);
// //input_data += width * height;
// inputData+=(this->inputGeometry_.height*this->inputGeometry_.width);
// }
// this->preprocess(inputImage,preprocessed);
// split(preprocessed, input_channels);
// //preprocessed.copyTo(netInputWraped);
// this->net_->Forward();
// const float* outputNetData=net_->output_blobs()[0]->cpu_data();
// // const float* outputNetData1=net_->output_blobs()[1]->cpu_data();
// this->outputGeometry_ = Size(net_->output_blobs()[0]->width(),net_->output_blobs()[0]->height());
// int outputSz = this->outputSize_ * this->outputGeometry_.height * this->outputGeometry_.width;
// outputMat.create(this->outputGeometry_.height , this->outputGeometry_.width,CV_32FC1);
// float*outputMatData=(float*)(outputMat.data);
// memcpy(outputMatData,outputNetData,sizeof(float)*outputSz);
//#endif
// }
#ifdef HAVE_CAFFE
Ptr<caffe::Net<float> > net_;
#endif
@ -587,15 +537,6 @@ public:
inputImageList.push_back(image.getMat());
classifyBatch(inputImageList,classProbabilities);
}
// void detect(InputArray image, OutputArray Bbox_prob)
// {
// Bbox_prob.create(this->outputGeometry_,CV_32F); // dummy initialization is it needed
// Mat outputMat = Bbox_prob.getMat();
// process_(image.getMat(),outputMat);
// //copy back to outputArray
// outputMat.copyTo(Bbox_prob);
// }
void classifyBatch(InputArrayOfArrays inputImageList, OutputArray classProbabilities)
{

@ -74,7 +74,7 @@ public:
void textDetectInImage(InputArray inputImage,CV_OUT std::vector<Rect>& Bbox,CV_OUT std::vector<float>& confidence)
{
Mat netOutput;
// call the detect function of deepCNN class
// call the detect function of deepTextCNN class
this->classifier_->detect(inputImage,netOutput);
// get the output geometry i.e height and width of output blob from caffe
Size OutputGeometry_ = this->classifier_->getOutputGeometry();
@ -102,12 +102,11 @@ public:
int component_level=0)
{
CV_Assert(component_level==OCR_LEVEL_WORD);//Componnents not applicable for word spotting
//double confidence;
//String transcription;
std::vector<Rect> bbox;
std::vector<float> score;
textDetectInImage(image,bbox,score);
//output_text=transcription.c_str();
if(component_rects!=NULL)
{
component_rects->resize(bbox.size()); // should be a user behavior

@ -26,27 +26,6 @@ inline bool fileExists (String filename) {
return f.good();
}
//************************************************************************************
//****************** TextImageClassifier *****************************************
//************************************************************************************
//void TextImageClassifier::preprocess(const Mat& input,Mat& output)
//{
// this->preprocessor_->preprocess_(input,output,this->inputGeometry_,this->channelCount_);
//}
//void TextImageClassifier::setPreprocessor(Ptr<ImagePreprocessor> ptr)
//{
// CV_Assert(!ptr.empty());
// preprocessor_=ptr;
//}
//Ptr<ImagePreprocessor> TextImageClassifier::getPreprocessor()
//{
// return preprocessor_;
//}
class DeepCNNTextDetectorCaffeImpl: public DeepCNNTextDetector{
protected:
@ -54,9 +33,7 @@ protected:
void process_(Mat inputImage, Mat &outputMat)
{
// do forward pass and stores the output in outputMat
//Process one image
// CV_Assert(this->outputGeometry_.batchSize==1);
//CV_Assert(outputMat.isContinuous());
#ifdef HAVE_CAFFE
net_->input_blobs()[0]->Reshape(1, this->inputChannelCount_,this->inputGeometry_.height,this->inputGeometry_.width);
@ -191,12 +168,6 @@ public:
outputMat.copyTo(Bbox_prob);
}
//int getOutputSize()
//{
// return this->outputSize_;
//}
Size getOutputGeometry()
{
return this->outputGeometry_;
@ -290,54 +261,7 @@ void DeepCNNTextDetector::preprocess(const Mat& input,Mat& output)
this->preprocessor_->preprocess(input,output,inputHtWd,this->inputChannelCount_);
}
//namespace cnn_config{
//namespace caffe_backend{
//#ifdef HAVE_CAFFE
//bool getCaffeGpuMode()
//{
// return caffe::Caffe::mode()==caffe::Caffe::GPU;
//}
//void setCaffeGpuMode(bool useGpu)
//{
// if(useGpu)
// {
// caffe::Caffe::set_mode(caffe::Caffe::GPU);
// }else
// {
// caffe::Caffe::set_mode(caffe::Caffe::CPU);
// }
//}
//bool getCaffeAvailable()
//{
// return true;
//}
//#else
//bool getCaffeGpuMode()
//{
// CV_Error(Error::StsError,"Caffe not available during compilation!");
// return 0;
//}
//void setCaffeGpuMode(bool useGpu)
//{
// CV_Error(Error::StsError,"Caffe not available during compilation!");
// CV_Assert(useGpu==1);//Compilation directives force
//}
//bool getCaffeAvailable(){
// return 0;
//}
//#endif
//}//namespace caffe
//}//namespace cnn_config
} } //namespace text namespace cv

Loading…
Cancel
Save