PDA

View Full Version : exited with code -1073741819 error



arpspatel
23rd February 2010, 00:40
Hi.

I am writing a program which replaces detected face with replace image, the command line version works fine, but the gui just messes up, i dont know how.. I have compiled the command line one with Eclipse/MinGW/OpenCV2.0 and trying to compile GUI version with QT creator/OpenCV2.0/MinGW. the compile part work fine.. After select a input image and replace image, when i press the deanerize button the gui stops responding and gives "exited with code -1073741819 error". I tried the debugger and found nothing. mr. google said that i had an uninitialised value which i am trying to access and so it gives me error. I have written my code nearly 4-5 times from the working command line version but it just doesnt want to work. i have attached the code to work with please if you find anything even a small bit. it wil be very helpful. u can use any image for input/replace..

Thank you very much
Arps

Steps to Use:
1. Open Input Image
2. Open Replace Image
3. Deanerize button

high_flyer
23rd February 2010, 09:32
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.

arpspatel
23rd February 2010, 19:16
using the debugger, the line with cvColor(...) gives error.


void theGui::slDeanerize(){
if(inName->isEmpty() || repName->isEmpty()){
QMessageBox::information(this,tr("ReplaceWithDeaner"),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());
}


Thanks
Arpit

SABROG
23rd February 2010, 20:13
Hi.
"exited with code -1073741819 error". I tried the debugger and found nothing. mr. google said that i had an uninitialised value which i am trying to access and so it gives me error. I have written my code nearly 4-5 times from the working command line version but it just doesnt want to work.

-1073741819 - 0xC0000005 - STATUS_ACCESS_VIOLATION

Test what return imread():



img = imread(inName->toStdString() , 1 );
Q_ASSERT(img.data);

arpspatel
23rd February 2010, 23:20
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.

arpspatel
23rd February 2010, 23:39
I have attached the output of the debugger where the program stops responding.

Thanks
Arps

high_flyer
24th February 2010, 14:19
This line:

Mat gray, smallImg( cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1 );
Should not even compile!

Should it be maybe?:


Mat gray;
smallImg( cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1 );



In addition, put a break point on the crashing line:

cvtColor( img, gray, CV_BGR2GRAY );
And look at 'img' if it is valid.

arpspatel
1st March 2010, 17:28
This line:

Mat gray, smallImg( cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1 );
Should not even compile!

Should it be maybe?:


Mat gray;
smallImg( cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1 );



In addition, put a break point on the crashing line:

cvtColor( img, gray, CV_BGR2GRAY );
And look at 'img' if it is valid.


Mat gray, smallImg( cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1 );
This line compiles fine..


cvtColor( img, gray, CV_BGR2GRAY );
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..

I probably think this is issue with Qt+OpenCV2.0, not working together with certain functions.. (maybe overloaded somewhere)

Thanks for your help.

high_flyer
2nd March 2010, 10:47
It was this line which was causing problems, don't know why?
May be you need to initialize 'gray' to be the same size as smallImg.
What happens if you do:


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 );


Also, in the documentation fo cvtColor here:
http://www710.univ-lyon1.fr/~bouakaz/OpenCV-0.9.5/docs/ref/OpenCVRef_ImageProcessing.htm#decl_cvCvtColor
CV_8UC1 is not specified, are you sure it is a legal parameter?