Commit 2b788904 authored by Anguelos Nicolaou's avatar Anguelos Nicolaou

Attenpt to supress visual studio and IOS warnings

parent 53a86776
# Protobuf package required for Caffe #Protobuf package required for Caffe
unset(Protobuf_FOUND) unset(Protobuf_FOUND)
find_library(Protobuf_LIBS NAMES protobuf find_library(Protobuf_LIBS NAMES protobuf
......
...@@ -38,14 +38,14 @@ def mouseCallback(event, x, y, flags, param): ...@@ -38,14 +38,14 @@ def mouseCallback(event, x, y, flags, param):
cv2.rectangle(drawImage, refPt[0], refPt[1], (0, 255, 0), 2) cv2.rectangle(drawImage, refPt[0], refPt[1], (0, 255, 0), 2)
cv2.putText(drawImage,"%s:%f"%(res[0],res[1]),refPt[0],cv2.FONT_HERSHEY_SIMPLEX,1,(255,255,255),2) cv2.putText(drawImage,"%s:%f"%(res[0],res[1]),refPt[0],cv2.FONT_HERSHEY_SIMPLEX,1,(255,255,255),2)
cv2.imshow("Select A Region", drawImage) cv2.imshow("Select A Region", drawImage)
if __name__=='__main__': if __name__=='__main__':
USEGPU=False USEGPU=False
helpStr=""" Usage: """+sys.argv[0]+""" IMAGE_FILENAME helpStr="""Usage: """+sys.argv[0]+""" IMAGE_FILENAME
Press 'q' or 'Q' exit Press 'q' or 'Q' exit
The modelFiles must be available in the current directory. The modelFiles must be available in the current directory.
In linux shell they can be downloaded (~2GB) with the following commands: In linux shell they can be downloaded (~2GB) with the following commands:
wget http://nicolaou.homouniversalis.org/assets/vgg_text/dictnet_vgg.caffemodel wget http://nicolaou.homouniversalis.org/assets/vgg_text/dictnet_vgg.caffemodel
...@@ -56,7 +56,7 @@ if __name__=='__main__': ...@@ -56,7 +56,7 @@ if __name__=='__main__':
print helpStr print helpStr
print 'No image file given Aborting!' print 'No image file given Aborting!'
sys.exit(1) sys.exit(1)
if not (os.path.isfile('dictnet_vgg_deploy.prototxt') and if not (os.path.isfile('dictnet_vgg_deploy.prototxt') and
os.path.isfile('dictnet_vgg.caffemodel') and os.path.isfile('dictnet_vgg.caffemodel') and
os.path.isfile('dictnet_vgg_labels.txt')): os.path.isfile('dictnet_vgg_labels.txt')):
print helpStr print helpStr
......
...@@ -67,7 +67,7 @@ protected: ...@@ -67,7 +67,7 @@ protected:
net_->Reshape(); net_->Reshape();
float* inputBuffer=net_->input_blobs()[0]->mutable_cpu_data(); float* inputBuffer=net_->input_blobs()[0]->mutable_cpu_data();
float* inputData=inputBuffer; float* inputData=inputBuffer;
for(int imgNum=0;imgNum<inputImageList.size();imgNum++){ for(size_t imgNum=0;imgNum<inputImageList.size();imgNum++){
Mat preprocessed; Mat preprocessed;
cv::Mat netInputWraped(this->inputGeometry_.height, this->inputGeometry_.width, CV_32FC1, inputData); cv::Mat netInputWraped(this->inputGeometry_.height, this->inputGeometry_.width, CV_32FC1, inputData);
this->preprocess(inputImageList[imgNum],preprocessed); this->preprocess(inputImageList[imgNum],preprocessed);
...@@ -87,11 +87,16 @@ protected: ...@@ -87,11 +87,16 @@ protected:
Size inputGeometry_; Size inputGeometry_;
const int minibatchSz_; const int minibatchSz_;
const bool gpuBackend_; const bool gpuBackend_;
Ptr<Mat> meanImage_;
bool standarize_;
std::vector<std::string> labels_;
int outputSize_; int outputSize_;
public: public:
DictNetCaffeImpl(const DictNetCaffeImpl& dn):inputGeometry_(dn.inputGeometry_),minibatchSz_(dn.minibatchSz_),
gpuBackend_(dn.gpuBackend_),outputSize_(dn.outputSize_){
//Implemented to supress Visual Studio warning
#ifdef HAVE_CAFFE
this->net_=dn.net_;
#endif
}
DictNetCaffeImpl(String modelArchFilename, String modelWeightsFilename, int maxMinibatchSz, bool useGpu) DictNetCaffeImpl(String modelArchFilename, String modelWeightsFilename, int maxMinibatchSz, bool useGpu)
:minibatchSz_(maxMinibatchSz), gpuBackend_(useGpu){ :minibatchSz_(maxMinibatchSz), gpuBackend_(useGpu){
CV_Assert(this->minibatchSz_>0); CV_Assert(this->minibatchSz_>0);
...@@ -128,9 +133,9 @@ public: ...@@ -128,9 +133,9 @@ public:
void classifyBatch(InputArrayOfArrays inputImageList, OutputArray classProbabilities){ void classifyBatch(InputArrayOfArrays inputImageList, OutputArray classProbabilities){
std::vector<Mat> allImageVector; std::vector<Mat> allImageVector;
inputImageList.getMatVector(allImageVector); inputImageList.getMatVector(allImageVector);
classProbabilities.create(Size(this->outputSize_,allImageVector.size()),CV_32F); classProbabilities.create(Size(unsigned int(this->outputSize_),allImageVector.size()),CV_32F);
Mat outputMat = classProbabilities.getMat(); Mat outputMat = classProbabilities.getMat();
for(int imgNum=0;imgNum<int(allImageVector.size());imgNum+=this->minibatchSz_){ for(size_t imgNum=0;imgNum<allImageVector.size();imgNum+=this->minibatchSz_){
int rangeEnd=imgNum+std::min<int>(allImageVector.size()-imgNum,this->minibatchSz_); int rangeEnd=imgNum+std::min<int>(allImageVector.size()-imgNum,this->minibatchSz_);
std::vector<Mat>::const_iterator from=allImageVector.begin()+imgNum; std::vector<Mat>::const_iterator from=allImageVector.begin()+imgNum;
std::vector<Mat>::const_iterator to=allImageVector.begin()+rangeEnd; std::vector<Mat>::const_iterator to=allImageVector.begin()+rangeEnd;
...@@ -250,7 +255,7 @@ public: ...@@ -250,7 +255,7 @@ public:
} }
if(component_confidences!=NULL){ if(component_confidences!=NULL){
component_confidences->resize(1); component_confidences->resize(1);
(*component_confidences)[0]=confidence; (*component_confidences)[0]=float(confidence);
} }
} }
void run(Mat& image, Mat& mask, std::string& output_text, std::vector<Rect>* component_rects=NULL, void run(Mat& image, Mat& mask, std::string& output_text, std::vector<Rect>* component_rects=NULL,
...@@ -261,13 +266,7 @@ public: ...@@ -261,13 +266,7 @@ public:
} }
std::vector<String>& getVocabulary(){ std::vector<String>& getVocabulary(){
return this->labels_; return this->labels_;
}/* }
void getVocabulary(CV_OUT const std::vector<String>& voc){
voc.reshape(this->labels_.size());
for(int k =0;k<voc.size();k++){
voc[k]=this->labels_[k];
}
}*/
}; };
Ptr<OCRHolisticWordRecognizer> OCRHolisticWordRecognizer::create(Ptr<TextImageClassifier> classifierPtr,String vocabullaryFilename ){ Ptr<OCRHolisticWordRecognizer> OCRHolisticWordRecognizer::create(Ptr<TextImageClassifier> classifierPtr,String vocabullaryFilename ){
......
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