opencv 3.0 face detect runtime error in visual studio 2012

asked 2017-12-02 07:54:46 -0500

Shivanshu gravatar image

This is part of my code on facial detection in opencv 3.0.I am using visual studio 2012.when ever I run my program the program crashes with error of accesses memory violation at some location.Image regarding the crash is provided with this question.

After doing an analysis to crash , I found that problem was with "faces" (vector of rectangle) being returned by function "detectMultiscale()".when ever destructor to "face" vector is called it gives this error,if I declare as global variable program works fine but not good.

Also to note that face.size() is also too large than I expect. Here is the code for detection..

void detectAndDisplay( Mat frame ) { std::vector<rect> faces; Mat frame_gray,hist;

cvtColor( frame, frame_gray, COLOR_BGR2GRAY );
equalizeHist( frame_gray, hist );
frame_gray.deallocate();
//-- Detect faces
face_cascade.detectMultiScale( hist, faces, 1.1, 2, 0|CASCADE_SCALE_IMAGE, Size(30, 30) );



//-- Show what you got
imshow( window_name, frame );

}

edit retag flag offensive close merge delete

Comments

most likely, you're linking opencv debug libs to a release project (or the other way)

please check your linker settings.

(did you build the opencv libs locally ?, the prebuild ones are for vs2015 x64 only !)

berak gravatar imageberak ( 2017-12-02 07:57:51 -0500 )edit

thank you for response first.I used prebuild library from opencv site and there is no saperate folder for debug or release libraries .It goes like this: C:\opencv\build\x64\vc12... I don't know why vector type is causing problem?? :(

Shivanshu gravatar imageShivanshu ( 2017-12-03 00:55:26 -0500 )edit

sorry i misunderstood ur answer its working now thankyou very much but no i get a runtime debug assertion failure which says: _pFirstblock==Phead;in file dbgheap.c what is problem now?

Shivanshu gravatar imageShivanshu ( 2017-12-04 11:02:25 -0500 )edit

that smells still like a linking problem.

any chance, you can update to VS2015, and current opencv3.3.1, and just use the prebuild libs as intended ?

berak gravatar imageberak ( 2017-12-04 11:05:09 -0500 )edit

what could be the linking error?if i linked with correct lib

Shivanshu gravatar imageShivanshu ( 2017-12-04 14:34:40 -0500 )edit

oh yes followed the smell of linker i found i was't linked with correct visual studio library i linked with vs 12 for msvs 2012 then i linked with vs11 folder and it works well .Thanks again Berak :)

Shivanshu gravatar imageShivanshu ( 2017-12-04 14:39:22 -0500 )edit

but how can i ffasten detection?

Shivanshu gravatar imageShivanshu ( 2017-12-04 14:39:55 -0500 )edit