Skip to content

Commit fc77cea

Browse files
committed
Removed const from classifer data memebers to allow for assignment operator (windows 7 warned it could not create one). Created size_t temporary variables to contain integer values so that there is never math/comparissons between ints and size_t
1 parent bb8a51b commit fc77cea

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

modules/text/src/ocr_holistic.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,33 @@ class DictNetCaffeImpl: public DictNet{
8585
Ptr<caffe::Net<float> > net_;
8686
#endif
8787
Size inputGeometry_;
88-
const int minibatchSz_;
89-
const bool gpuBackend_;
88+
int minibatchSz_;//The existence of the assignment operator mandates this to be nonconst
89+
bool gpuBackend_;//The existence of the assignment operator mandates this to be nonconst
9090
int outputSize_;
9191
public:
9292
DictNetCaffeImpl(const DictNetCaffeImpl& dn):inputGeometry_(dn.inputGeometry_),minibatchSz_(dn.minibatchSz_),
9393
gpuBackend_(dn.gpuBackend_),outputSize_(dn.outputSize_){
94-
//Implemented to supress Visual Studio warning
94+
//Implemented to supress Visual Studio warning "assignment operator could not be generated"
9595
#ifdef HAVE_CAFFE
9696
this->net_=dn.net_;
9797
#endif
9898
}
99+
DictNetCaffeImpl& operator=(const DictNetCaffeImpl &dn){
100+
#ifdef HAVE_CAFFE
101+
this->net_=dn.net_;
102+
#endif
103+
this->inputGeometry_=dn.inputGeometry_;
104+
this->minibatchSz_=dn.minibatchSz_;
105+
this->gpuBackend_=dn.gpuBackend_;
106+
this->outputSize_=dn.outputSize_;
107+
return *this;
108+
//Implemented to supress Visual Studio warning "assignment operator could not be generated"
109+
}
99110

100111
DictNetCaffeImpl(String modelArchFilename, String modelWeightsFilename, int maxMinibatchSz, bool useGpu)
101112
:minibatchSz_(maxMinibatchSz), gpuBackend_(useGpu){
102113
CV_Assert(this->minibatchSz_>0);
103-
CV_Assert(fileExists(modelArchFilename) );
114+
CV_Assert(fileExists(modelArchFilename));
104115
CV_Assert(fileExists(modelWeightsFilename));
105116
#ifdef HAVE_CAFFE
106117
if(this->gpuBackend_){
@@ -133,10 +144,12 @@ class DictNetCaffeImpl: public DictNet{
133144
void classifyBatch(InputArrayOfArrays inputImageList, OutputArray classProbabilities){
134145
std::vector<Mat> allImageVector;
135146
inputImageList.getMatVector(allImageVector);
136-
classProbabilities.create(Size((size_t)(this->outputSize_),allImageVector.size()),CV_32F);
147+
size_t outputSize=size_t(this->outputSize_);//temporary variable to avoid int to size_t arithmentic
148+
size_t minibatchSize=this->minibatchSz_;//temporary variable to avoid int to size_t arithmentic
149+
classProbabilities.create(Size(outputSize,allImageVector.size()),CV_32F);
137150
Mat outputMat = classProbabilities.getMat();
138-
for(size_t imgNum=0;imgNum<allImageVector.size();imgNum+=this->minibatchSz_){
139-
int rangeEnd=imgNum+std::min<int>(allImageVector.size()-imgNum,this->minibatchSz_);
151+
for(size_t imgNum=0;imgNum<allImageVector.size();imgNum+=minibatchSize){
152+
int rangeEnd=imgNum+std::min<size_t>(allImageVector.size()-imgNum,minibatchSize);
140153
std::vector<Mat>::const_iterator from=allImageVector.begin()+imgNum;
141154
std::vector<Mat>::const_iterator to=allImageVector.begin()+rangeEnd;
142155
std::vector<Mat> minibatchInput(from,to);

0 commit comments

Comments
 (0)