Use the debugger to get the line which crashes, and post the code around it, or the whole function which contains that line.I tried the debugger and found nothing.
Use the debugger to get the line which crashes, and post the code around it, or the whole function which contains that line.I tried the debugger and found nothing.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
arpspatel (23rd February 2010)
using the debugger, the line with cvColor(...) gives error.
Thanksvoid 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());
}
Arpit
-1073741819 - 0xC0000005 - STATUS_ACCESS_VIOLATION
Test what return imread():
Qt Code:
img = imread(inName->toStdString() , 1 ); Q_ASSERT(img.data);To copy to clipboard, switch view to plain text mode
arpspatel (23rd February 2010)
what do you mean by test return?
i tried Q_ASSERT(img.data);
same 1073641819 error.. and i dont think its imread as i can read the image fine.
Last edited by arpspatel; 23rd February 2010 at 22:21. Reason: type mistake
I have attached the output of the debugger where the program stops responding.
Thanks
Arps
This line:
Should not even compile!Qt Code:
Mat gray, smallImg( cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1 );To copy to clipboard, switch view to plain text mode
Should it be maybe?:
Qt Code:
Mat gray; smallImg( cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1 );To copy to clipboard, switch view to plain text mode
In addition, put a break point on the crashing line:
And look at 'img' if it is valid.Qt Code:
cvtColor( img, gray, CV_BGR2GRAY );To copy to clipboard, switch view to plain text mode
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
arpspatel (1st March 2010)
This line compiles fine..Qt Code:
Mat gray, smallImg( cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1 );To copy to clipboard, switch view to plain text mode
It was this line which was causing problems, don't know why? I couldn't even get an answer from OpenCV forums. I just changed the coding myself to convert img to grayscale manually with direct pixel access..Qt Code:
cvtColor( img, gray, CV_BGR2GRAY );To copy to clipboard, switch view to plain text mode
I probably think this is issue with Qt+OpenCV2.0, not working together with certain functions.. (maybe overloaded somewhere)
Thanks for your help.
May be you need to initialize 'gray' to be the same size as smallImg.It was this line which was causing problems, don't know why?
What happens if you do:
Qt Code:
Mat gray( cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1 /*or what ever format that makes sense*/ ); Mat smallImg( cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1 ); ... cvtColor( img, gray, CV_BGR2GRAY );To copy to clipboard, switch view to plain text mode
Also, in the documentation fo cvtColor here:
http://www710.univ-lyon1.fr/~bouakaz...ecl_cvCvtColor
CV_8UC1 is not specified, are you sure it is a legal parameter?
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Bookmarks