gpt4 book ai didi

image - OpenCV 无法加载图像

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

当我在做一个项目时,我注意到我无法加载图像。这是我用来检查的简单代码:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}

Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file

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

Mat gray_image;
cv::cvtColor(image, gray_image, CV_RGB2GRAY);

imwrite("Gray_Image.jpg",gray_image);

return 0;
}

这是我执行它时的输出:

root@beaglebone:~# ./tryit lena.jpg 
Could not open or find the image

我试图直接使用图像的地址(“/home/root/lena.jpg”)而不是 argv[1] 但没有任何改变。

可能是什么问题?

ps:我正在交叉编译这个 OpenCV 程序,然后在我的 BeagleBone 上运行它,它上面安装了 Angstrom Linux。这个问题可以相关吗?

最佳答案

我通过删除 angstrom 图像上现有的 OpenCV 库并将其替换为工作库来解决我的问题。

关于image - OpenCV 无法加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11666873/

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