#include <Filter/DeInterlace.hh>
#include <Filter/Median.hh>
#include <Base/Image/ImageIO.hh>
#include <Base/Image/ImageConvert.hh>
#include <Base/Debug/TimeMeasure.hh>
#include <Utils/Param.hh>
using namespace BIAS;
using namespace std;
int ExtractNumbersFromRight(const std::string & inStr,
int & number, int& imgNum,
int & posL,
int & posR, int& posLImg, int& posRImg)
{
number=0;
imgNum = 0;
posL=posR=0;
posLImg = posRImg = 0;
bool done=false;
bool numericStarted=false;
bool numericEnded=false;
bool numericImgStarted = false;
int exp10=0;
int exp10Img = 0;
int current = inStr.size()-1;
while (!done && current>=0){
const char c=inStr[current];
switch (c) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
{
if(!numericImgStarted && !numericEnded){
if (!numericStarted){
numericStarted=true;
posR=current;
}
const int act =atoi(&c);
const int addAct = int(act*pow(10.0, exp10 ));
number += addAct;
exp10++;
}
if(numericStarted && numericEnded){
if(!numericImgStarted){
numericImgStarted = true;
posRImg = current;
}
const int act = atoi(&c);
const int addAct = int(act*pow(10.0, exp10Img));
exp10Img++;
imgNum += addAct;
}
break;
}
default:
{
if (numericStarted && !numericImgStarted){
numericEnded=true;
posL=current+1;
done=false;
}
if(numericImgStarted){
posLImg = current+1;
done=true;
}
}
};
current--;
}
if (!numericStarted) {
return -1;
}
return 0;
}
int main(int argc, char *argv[]) {
if (argc<4) {
cerr << argv[0] << "useEvenLines(bool) dodownsamplingbytwo(bool) src1 src2 ... \n";
return -2;
}
for (int countImgs = 0; countImgs < (argc-3); countImgs++) {
BIASERR("error loading image "<<argv[countImgs + 3]);
return -1;
} else {
cerr << "read "<<argv[countImgs + 3]<<endl;
}
BIASERR("error converting image "<<argv[countImgs + 3]);
}
cout << "Done with deinterlacer" << endl;
int num, imgNum, posL, posR, posLImg, posRImg;
ExtractNumbersFromRight(argv[countImgs + 3], num, imgNum, posL, posR, posLImg, posRImg);
cout << "extracted num " << num << " imgNum " << imgNum << " posL " << posL << " posR " << posR << " posLImg " << posLImg << " posRImg " << posRImg << endl;
ostringstream name;
name << "deint-" << setw(4) << setfill('0') << num << ".png";
}
return 0;
}