visual studio识别opencv函数,但不识别COLOR_BGR2GRAY枚举

时间:2017-12-10 17:56:51

标签: c++ opencv

我正在学习c ++中的opencv,但是visual studio(2017社区)无法识别枚举COLOR_BGR2GRAY,但它识别opencv的其他功能。

这是源代码:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <Windows.h>

using namespace cv;
using namespace std;

void drawSquares(Mat image);

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

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

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

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



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

void drawSquares(Mat image)
{
    Mat image_gray;
    cvCvtColor(&image, &image_gray, COLOR_BGR2GRAY); //***it doest recognize this enum in this line***
}

知道它为什么识别函数但不识别COLOR_BGR2GRAY枚举?

1 个答案:

答案 0 :(得分:0)

尝试将COLOR_BGR2GRAY更改为cv::COLOR_BGR2GRAY,然后检查是否可行