gpt4 book ai didi

c++ - imread 找不到图像

转载 作者:太空宇宙 更新时间:2023-11-03 22:29:47 24 4
gpt4 key购买 nike

我使用 visual studio 2013 和 opencv。我运行一个简单的代码来读取图像并显示它。我将图像从 Donloads 文件添加到我的项目的资源文件中。当我运行下面的代码时,image.data 是空的。

  #include "stdafx.h"
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\opencv.hpp>


int _tmain(int argc, _TCHAR* argv[])
{

cv::Mat image;
image = cv::imread("im.png", CV_LOAD_IMAGE_COLOR); // Read the file

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

cv::namedWindow("Display window", cv::WINDOW_AUTOSIZE);// Create a window for display.
imshow("Display window", image); // Show our image inside it.

cv::waitKey(0); // Wait for a keystroke in the window
return 0;

最佳答案

尝试:C:\\Users\\pr\\Downloads\\im.png 如果路径正确,应该可以。

关于c++ - imread 找不到图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28536582/

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