gpt4 book ai didi

c++ - 我得到断言失败 "file_name != nullptr"但仅在 Release模式下

转载 作者:太空宇宙 更新时间:2023-11-04 12:41:54 25 4
gpt4 key购买 nike

当我尝试在 Debug模式下运行代码时,一切正常,但当我尝试在 Release模式下运行时,出现错误“file_name != nullptr”(错误来自 fopen)。我知道错误是什么意思,但我不知道为什么会出现错误以及如何修复它

#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
#include <string>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
String imageName("C:/Users/x/Desktop/pic.png"); // by default
if (argc > 1)
{
imageName = argv[1];
}

Mat image;
image = imread(imageName, IMREAD_COLOR); // Read the file

if (image.empty()) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl;
return -1;
}

namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
imshow("Display window", image); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}

错误信息:

>-----------Microsoft Visual C++ Runtime Library----------------
>
>
>Debug Assertion Assertion Faild!
>
>Programm: C:\Users\x\...\myProgramm.exe
>File: minkernel\crts\ucrt\src\appcrt\stdio\fopen.cpp
>
>Line: 30
>
>Expression: file_name != nullptr

最佳答案

您必须确保在调试和 Release模式下使用正确的依赖项(.lib 文件)。

关于c++ - 我得到断言失败 "file_name != nullptr"但仅在 Release模式下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53802979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com