How to fix Assertion Failure Opencv Programming - Visual C++ 2008 Express

816 views Asked by At

I made a windows form based program to load an image using opencv in Visual C++ 2008. But, the following code failed to load the image, and got an assertion failure.

private: System::Void buttonCitra_Click(System::Object^  sender, System::EventArgs^  e)
{
    if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
    {
        //error detected here variable Citra 
        Citra = cv::imread(MarshalString(openFileDialog1->FileName));
        pictureBoxCitra->Image = IplImageToBitmap(&(IplImage) Citra);
        this->Width = pictureBoxCitra->Image->Width+33;
        this->Height = pictureBoxCitra->Image->Height+85;
    }
} 

When I compile and build it, nothing happened, and the Form appeared properly. But when i chose an image using openFileDialog in my directory file, i got dialog box titled "Microsoft Visual C++ debug library" which contains the assertion failure,as follow :

"Debug Assertion Failed!
Program: .....Try.exe
file f:\dd\vctools\crt_bld\Self_x86\crt\src\fopen.c
Line 53
Expression: (file!=NULL)"
0

There are 0 answers