gpt4 book ai didi

c++ - 未处理的异常 Microsoft C++ 异常:cv::Exception at memory location

转载 作者:可可西里 更新时间:2023-11-01 11:18:28 24 4
gpt4 key购买 nike

我刚开始使用 OpenCV。我下载了 OpenCV 2.4.9,并安装了 MSVS 2010。我的 Windows 是 X64。我遵循了以下步骤:

一个。在 Configuration Properties 下,单击 Debugging -> Environment 并复制粘贴:PATH=C:\opencv\build\x86\vc10\bin

VC++ 目录 -> 包含目录并添加条目:C:\opencv\build\include

VC++ 目录 -> 库目录并添加条目:C:\opencv\build\x86\vc10\lib

Linker -> Input -> Additional Dependencies 并添加以下内容:

opencv_calib3d249.lib;opencv_contrib249.lib;opencv_core249.lib;opencv_features2d249.lib;opencv_flann249.lib;opencv_gpu249.lib;opencv_nonfree249.lib;opencv_highgui249.lib;opencv_imgproc249.lib;opencv_legacy249.lib;opencv_ml249.lib;opencv_objdetect249.lib;opencv_ts249.lib;opencv_video249.lib;

我运行了以下代码:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main() {
// read an image
cv::Mat image= cv::imread("img.jpg");
// create image window named "My Image"
cv::namedWindow("My Image");
cv::waitKey(1000);
// show the image on window
cv::imshow("My Image", image);
// wait key for 5000 ms
cv::waitKey(50);
return 1;
}

获取错误:

Unhandled exception at 0x76d2b727 in BTP1.exe: Microsoft C++ exception: cv::Exception at memory location 0x003af414

我想这可能是因为 X64 和 x86 不匹配。关于更改 a 中的条目。到 PATH=C:\opencv\build\x64\vc10\bin 和 c.到 C:\opencv\build\x64\vc10\lib,我得到以下错误:

The application was unable to start correctly (0xc000007b). Click OK to close the application.

关于我如何解决这个问题的任何提示?

最佳答案

这可能是因为您尝试显示的图像是空的,可能是因为图像不在正确的文件夹中。要确认这一点,请将您的代码更改为

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

#include <iostream> // std::cout

int main() {
// read an image
cv::Mat image= cv::imread("img.jpg");

// add the following lines
if(image.empty())
std::cout << "failed to open img.jpg" << std::endl;
else
std::cout << "img.jpg loaded OK" << std::endl;

... // the rest of your code

关于c++ - 未处理的异常 Microsoft C++ 异常:cv::Exception at memory location,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25587912/

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