我制作了一个基于Windows窗体的程序,在Visual C ++ 2008中使用opencv加载图像。 但是,以下代码无法加载图像,并且断言失败。
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;
}
}
当我编译并构建它时,没有任何反应,并且表单正确显示。但是当我在目录文件中使用openFileDialog选择图像时,我得到了一个标题为“Microsoft Visual C ++调试库”的对话框,其中包含断言失败,如下所示:
"Debug Assertion Failed!
Program: .....Try.exe
file f:\dd\vctools\crt_bld\Self_x86\crt\src\fopen.c
Line 53
Expression: (file!=NULL)"