App crash error code c0000374

asked 2016-01-08 13:25:10 -0600

Bilityuk gravatar image

updated 2016-01-09 07:32:46 -0600

Hi guys.. I need your help... cant finish my project because of this error: c0000374. After starting the program it fails and crashes. I use opencv 3.1 with VS 2010. Programm basically have to show a video window from computer webcam. I found the matter of the problem, it because of CPropertySheet and CPropertyPages. My MFC dialog project is based on MFC Property sheets, and i noticed that when i am trying to run this code in Property Sheet project it crashes and fails every time, but if i run the same code in MFC dialog based project without any property pages and property sheets it runs well without any crashes and errors. I really need a help of guru, i can't find any solutions in google, even close to my problem, it seems like nobody meet the same problem...

I run this code in button click eventhandler from my MFC property page (if i run the same code not from the mfc property page, but from simple mfc dialog, it works without problem):

void CsdkDemoDlg::OnBnClickedButtonRecognizeFace() { cout << "start recognizing..." << endl;

//load pre-trained data sets
Ptr<cv::face::FaceRecognizer>  model = cv::face::createFisherFaceRecognizer(num_compFisher,thresholdFisher);
model->load("C:\\Users\\Alexey\\Documents\\Visual Studio 2012\\Projects\\RaptorBOT_PC_Control\\С++\\RaptorBOT_PC_Control\\OpenCV3.1\\IMG_DB\\YML\\fisherface.yml");


Mat testSample = imread("C:\\Users\\Alexey\\Documents\\Visual Studio 2012\\Projects\\RaptorBOT_PC_Control\\С++\\RaptorBOT_PC_Control\\OpenCV3.1\\IMG_DB\\DB_Bilityuk_Alexey\\Snapshot_20160106.JPG");

int img_width = testSample.cols;
int img_height = testSample.rows;

string classifier = "C:\\Program Files\\opencv\\build_\\install\\etc\\haarcascades\\haarcascade_frontalface_default.xml";


CascadeClassifier face_cascade;
string window = "Capture - face";


if (!face_cascade.load(classifier)){
    cout << " Error loading file" << endl;

}

VideoCapture cap(1);


if (!cap.isOpened())
{
    cout << "exit" << endl;

}

//double fps = cap.get(CV_CAP_PROP_FPS);
//cout << " Frames per seconds " << fps << endl;
//namedWindow(window, 1);

int count = 0;

while(true)
{

    vector<Rect> faces;
    Mat frame;
    Mat graySacleFrame;
    Mat original;

    cap >> frame;
    //cap.read(frame);
    count = count + 1;//count frames;

    if (!frame.empty()){

        //clone from original frame
        original = frame.clone();

        //convert image to gray scale and equalize
        cvtColor(original, graySacleFrame, CV_BGR2GRAY);
        //equalizeHist(graySacleFrame, graySacleFrame);

        //detect face in gray image
        face_cascade.detectMultiScale(graySacleFrame, faces, 1.1, 3, 0, cv::Size(80, 80));          
        //face_cascade.detectMultiScale(graySacleFrame, faces);

        //number of faces detected
        cout << faces.size() << " faces detected" << endl;          
        std::string frameset = SSTR(count);
        std::string faceset = SSTR(faces.size());

        int width = 0, height = 0;

        //region of interest
        //cv::Rect roi;

        //person name
        string Pname = "";

        for (int i = 0; i < faces.size(); i++)
        {
            //region of interest
            Rect face_i = faces[i];

            //crop the roi from grya image
            Mat face = graySacleFrame(face_i);

            //resizing the cropped image to suit to database image sizes
            Mat face_resized;
            cv::resize(face, face_resized, Size(img_width, img_height), 1.0, 1.0, INTER_CUBIC);

            //recognizing what faces detected
            int label = -1; double confidence = 0;
            model->predict(face_resized, label, confidence);            

            cout << " confidencde " << confidence << endl;
            cout << " label " << label << endl;

            //drawing green rectagle in recognize face
            rectangle(original, face_i, CV_RGB(255, 0, 0), 1);

            string text = "Opredelen";
            if (label == 1){
                //string text = format("Person is  = %d", label);
                Pname = "Alexey ...
(more)
edit retag flag offensive close merge delete

Comments

start with carefully checking your c++ / linker settings. probably your mfc project is using a different c-runtime than the opencv libs were linked to (/MTd).

berak gravatar imageberak ( 2016-01-09 07:59:56 -0600 )edit

Checked the linker settings. It linked to /MTd

Bilityuk gravatar imageBilityuk ( 2016-01-09 16:09:03 -0600 )edit

Is there any workarounds?

Bilityuk gravatar imageBilityuk ( 2016-01-10 10:31:33 -0600 )edit