Skip to content

Commit 5d5ec99

Browse files
committed
casted size_t values to std::vector<Mat>::const_iterator and fixed unreachable code in the cpp sample
1 parent 5c526f7 commit 5d5ec99

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

modules/text/samples/dictnet_demo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ int main(int argc, const char * argv[]){
4444

4545
if (argc < 3){
4646
std::cout<<getHelpStr(argv[0]);
47-
exit(1);
4847
std::cout<<"Insufiecient parameters. Aborting!"<<std::endl;
48+
exit(1);
4949
}
5050

5151
if (!fileExists("dictnet_vgg.caffemodel") ||

modules/text/src/ocr_holistic.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ class DictNetCaffeImpl: public DictNet{
4242
}else{//Assuming values are at the desired [0,1] range
4343
tmpInput.convertTo(output, CV_32FC1);
4444
}
45-
}else if(input.channels()==1){
46-
if(input.depth()==CV_8U){
47-
input.convertTo(output, CV_32FC1,1/255.0);
48-
}else{//Assuming values are at the desired [0,1] range
49-
input.convertTo(output, CV_32FC1);
50-
}
5145
}else{
52-
CV_Error(Error::StsError,"Expecting images with either 1 or 3 channels");
46+
if(input.channels()==1){
47+
if(input.depth()==CV_8U){
48+
input.convertTo(output, CV_32FC1,1/255.0);
49+
}else{//Assuming values are at the desired [0,1] range
50+
input.convertTo(output, CV_32FC1);
51+
}
52+
}else{
53+
CV_Error(Error::StsError,"Expecting images with either 1 or 3 channels");
54+
}
5355
}
5456
resize(output,output,this->inputGeometry_);
5557
Scalar dev,mean;
@@ -150,8 +152,8 @@ class DictNetCaffeImpl: public DictNet{
150152
Mat outputMat = classProbabilities.getMat();
151153
for(size_t imgNum=0;imgNum<allImageVector.size();imgNum+=minibatchSize){
152154
size_t rangeEnd=imgNum+std::min<size_t>(allImageVector.size()-imgNum,minibatchSize);
153-
std::vector<Mat>::const_iterator from=allImageVector.begin()+imgNum;
154-
std::vector<Mat>::const_iterator to=allImageVector.begin()+rangeEnd;
155+
std::vector<Mat>::const_iterator from=std::vector<Mat>::const_iterator(allImageVector.begin()+imgNum);
156+
std::vector<Mat>::const_iterator to=std::vector<Mat>::const_iterator(allImageVector.begin()+rangeEnd);
155157
std::vector<Mat> minibatchInput(from,to);
156158
classifyMiniBatch(minibatchInput,outputMat.rowRange(imgNum,rangeEnd));
157159
}

0 commit comments

Comments
 (0)