qt - Opencv2 cvtColor() 不起作用

标签 qt opencv

我在 Ubuntu 12.04 上使用 OpenCV2。我可以成功运行图像读取显示代码。 但是我无法运行带有内置函数的代码,例如。 cvt颜色()

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

#include <stdio.h>

int main(int argc, char *argv[])
{
    cv::Mat image = cv::imread("img.jpg");

    if( image.data == NULL )
    {
        printf( "file cannot be loaded\n");
        return 1;
    }

    cv::namedWindow("My");
    cv::imshow("My", image);

    cv::Mat result;
    cv::cvtColor(image, result, CV_BGR2Luv);

    cv::imwrite("outImg.jpg", result);

    cv::waitKey(0);

    return 0;
}

我正在为我的 OpenCV 使用 Qt-creator 使用 --libs, --cflags 编译后出现以下编译器错误:

make: Entering directory `/home/swaroop/Work/ai-junkies/cuda/uc_davis/opencv2.x/OpenCV2Test'
g++ -g -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I/usr/include/opencv -I. -o main.o main.cpp
main.cpp: In function 'int main(int, char**)':
main.cpp:22:29: error: 'CV_BGR2Luv' was not declared in this scope
main.cpp:22:39: error: 'cvtColor' was not declared in this scope

请帮我解决这个问题。

最佳答案

cvtColoropencv2/imgproc/imgproc.hpp

中声明

记住它是#include而不是#import

#include <opencv2/imgproc/imgproc.hpp>

关于qt - Opencv2 cvtColor() 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16032845/

相关文章:

c++ - 同时滚动不同的 Widget

c++ - Qt:Centos 6.7 session 管理错误和符号查找错误

c++ - QT 如何使用 QDirIterator 访问子目录中的特定目录?

c++ - 如何使用 QtDesigner 将菜单栏添加到 QFrame?

opencv - 使用 HOG 特征和 cvsvm 进行汽车检测

c++ - QTextStream(*QFile) 构造函数被删除

python - 带有 Tesseract 的空字符串

python - 在一个子像素位置将一个图像补丁插入另一个图像

python-3.x - Bitwise_and 函数返回错误断言失败且掩码相同

opencv - 如何在 py-opencv 中保存 dpi 信息?