1

我制作了一个基于 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)"
4

0 回答 0