gpt4 book ai didi

c++ - opencv无法加载jp2图像文件

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

我在 Debian 上使用 opencv 2.3.1。以下代码无法加载给定的 jpeg 2000 文件。

#include "opencv/cv.h"
#include "opencv/highgui.h"
#include <vector>
#include <iostream>

int main()
{
IplImage* img_temp = cvLoadImage("delmeg.jp2", CV_LOAD_IMAGE_ANYCOLOR);
//IplImage* img_temp = cvLoadImage("delmec.jp2");
if(img_temp == NULL)
{
std::cout << "Can't load the image.." << std::endl;
return -1;
}
cv::Mat img(img_temp);

if (img_temp != NULL){
cvReleaseImage(&img_temp);
}
return 0;
}

我使用下面的命令来编译它:

g++ -Wall -g -I /usr/include/ testopencv2x.cpp -o testopencv2x -lopencv_core -lopencv_imgproc -lopencv_highgui

有人知道我在这里缺少什么吗?

谢谢。

最佳答案

我不知道 2.3.1,但这是 documentation says about 2.4.3 的内容:

Note: OpenCV offers support for the image formats Windows bitmap (bmp), portable image formats (pbm, pgm, ppm) and Sun raster (sr, ras). With help of plugins (you need to specify to use them if you build yourself the library, nevertheless in the packages we ship present by default) you may also load image formats like JPEG (jpeg, jpg, jpe), JPEG 2000 (jp2 - codenamed in the CMake as Jasper), TIFF files (tiff, tif) and portable network graphics (png). Furthermore, OpenEXR is also a possibility.

因此请确保构建 OpenCV 以支持此格式。

关于c++ - opencv无法加载jp2图像文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14733747/

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