Commit 73ddeab6 authored by sghoshcvc's avatar sghoshcvc

simple cleaning and added comments

parent 1bc908bd
...@@ -65,6 +65,7 @@ component tree of the image. : ...@@ -65,6 +65,7 @@ component tree of the image. :
*/ */
struct CV_EXPORTS ERStat struct CV_EXPORTS ERStat
{ {
public: public:
//! Constructor //! Constructor
explicit ERStat(int level = 256, int pixel = 0, int x = 0, int y = 0); explicit ERStat(int level = 256, int pixel = 0, int x = 0, int y = 0);
......
...@@ -459,56 +459,6 @@ protected: ...@@ -459,56 +459,6 @@ protected:
#endif #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 #ifdef HAVE_CAFFE
Ptr<caffe::Net<float> > net_; Ptr<caffe::Net<float> > net_;
#endif #endif
...@@ -587,15 +537,6 @@ public: ...@@ -587,15 +537,6 @@ public:
inputImageList.push_back(image.getMat()); inputImageList.push_back(image.getMat());
classifyBatch(inputImageList,classProbabilities); 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) void classifyBatch(InputArrayOfArrays inputImageList, OutputArray classProbabilities)
{ {
......
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
void textDetectInImage(InputArray inputImage,CV_OUT std::vector<Rect>& Bbox,CV_OUT std::vector<float>& confidence) void textDetectInImage(InputArray inputImage,CV_OUT std::vector<Rect>& Bbox,CV_OUT std::vector<float>& confidence)
{ {
Mat netOutput; Mat netOutput;
// call the detect function of deepCNN class // call the detect function of deepTextCNN class
this->classifier_->detect(inputImage,netOutput); this->classifier_->detect(inputImage,netOutput);
// get the output geometry i.e height and width of output blob from caffe // get the output geometry i.e height and width of output blob from caffe
Size OutputGeometry_ = this->classifier_->getOutputGeometry(); Size OutputGeometry_ = this->classifier_->getOutputGeometry();
...@@ -102,12 +102,11 @@ public: ...@@ -102,12 +102,11 @@ public:
int component_level=0) int component_level=0)
{ {
CV_Assert(component_level==OCR_LEVEL_WORD);//Componnents not applicable for word spotting CV_Assert(component_level==OCR_LEVEL_WORD);//Componnents not applicable for word spotting
//double confidence;
//String transcription;
std::vector<Rect> bbox; std::vector<Rect> bbox;
std::vector<float> score; std::vector<float> score;
textDetectInImage(image,bbox,score); textDetectInImage(image,bbox,score);
//output_text=transcription.c_str();
if(component_rects!=NULL) if(component_rects!=NULL)
{ {
component_rects->resize(bbox.size()); // should be a user behavior component_rects->resize(bbox.size()); // should be a user behavior
......
...@@ -26,27 +26,6 @@ inline bool fileExists (String filename) { ...@@ -26,27 +26,6 @@ inline bool fileExists (String filename) {
return f.good(); 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{ class DeepCNNTextDetectorCaffeImpl: public DeepCNNTextDetector{
protected: protected:
...@@ -54,9 +33,7 @@ protected: ...@@ -54,9 +33,7 @@ protected:
void process_(Mat inputImage, Mat &outputMat) void process_(Mat inputImage, Mat &outputMat)
{ {
// do forward pass and stores the output in 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 #ifdef HAVE_CAFFE
net_->input_blobs()[0]->Reshape(1, this->inputChannelCount_,this->inputGeometry_.height,this->inputGeometry_.width); net_->input_blobs()[0]->Reshape(1, this->inputChannelCount_,this->inputGeometry_.height,this->inputGeometry_.width);
...@@ -191,12 +168,6 @@ public: ...@@ -191,12 +168,6 @@ public:
outputMat.copyTo(Bbox_prob); outputMat.copyTo(Bbox_prob);
} }
//int getOutputSize()
//{
// return this->outputSize_;
//}
Size getOutputGeometry() Size getOutputGeometry()
{ {
return this->outputGeometry_; return this->outputGeometry_;
...@@ -290,54 +261,7 @@ void DeepCNNTextDetector::preprocess(const Mat& input,Mat& output) ...@@ -290,54 +261,7 @@ void DeepCNNTextDetector::preprocess(const Mat& input,Mat& output)
this->preprocessor_->preprocess(input,output,inputHtWd,this->inputChannelCount_); 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 } } //namespace text namespace cv
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