void theGui::slDeanerize(){
if(inName->isEmpty() || repName->isEmpty()){
QMessageBox::information(this,tr("ReplaceWithDeane r"),tr("Parameters:\tInput/Replace Image File Missing, Open and Try Again"));
return;
}
//Init Application
Mat img;
String cascadeName = "./cascadeMain.xml";
CascadeClassifier cascade;
double scale = 1;
if( !cascade.load( cascadeName ) )
{
QBoxError("Cascade Error: Could not load cascade file, please check the path");
}
img = imread(inName->toStdString() , 1 );
vector<Rect> faces;
//Detect Faces Here ------------
Mat gray, smallImg( cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1 );
cvtColor( img, gray, CV_BGR2GRAY );
The debugger shows this line, but i use the same method in command line version and it works fine
cv::resize( gray, smallImg, smallImg.size(), 0, 0, INTER_LINEAR );
equalizeHist( smallImg, smallImg );
cascade.detectMultiScale( smallImg, faces,
1.1, 2, 0
//|CV_HAAR_FIND_BIGGEST_OBJECT
//|CV_HAAR_DO_ROUGH_SEARCH
|CV_HAAR_SCALE_IMAGE
,
Size(30, 30) );
//----------------END
//Replace Faces Here ------------
int replaceMode = checkRadioButtons();
int facesTotal = faces.size();
int replaceTotal = replaceCountCalc(replaceMode, facesTotal);
outMat = img;
Mat crImgMat = imread(repName->toStdString(),1);
for (int i=0; i < replaceTotal; i++){
Mat roi(outMat,faces.at(i));
if((faces.at(i).size() != crImgMat.size())){
//IplImage *newImage = cvCreateImage(cvSize(faces.at(i).width,faces.at(i) .height), replaceImage->depth, replaceImage->nChannels);
Mat newMat(crImgMat.size(), crImgMat.type());
cv::resize(crImgMat,newMat,faces.at(i).size());
//cvResize(replaceImage, newImage, CV_INTER_CUBIC);
crImgMat = newMat;
}
roi = crImgMat;
}
//----------------End
IplImage outImg = outMat;
//setImageLabel(outputImageLabel, outImg);
outName = new QString(QFileInfo(inName->toStdString().c_str()).absolutePath() + "/deaner" + QFileInfo(inName->toStdString().c_str()).fileName());
}
Bookmarks