简体   繁体   English

Visual Studio可以识别opencv函数,但不能识别COLOR_BGR2GRAY枚举

[英]visual studio recognizes opencv functions but not COLOR_BGR2GRAY enum

I am learning opencv in c++ but visual studio (2017 community) cant recognize the enum COLOR_BGR2GRAY but it recognizes other functions of opencv. 我正在C ++中学习opencv,但Visual Studio(2017年社区)无法识别枚举COLOR_BGR2GRAY,但它可以识别opencv的其他功能。

here is the source code: 这是源代码:

#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***
}

Any idea why it does recognize the functions but not COLOR_BGR2GRAY enum? 知道为什么它不能识别功能但不能识别COLOR_BGR2GRAY枚举吗?

尝试将COLOR_BGR2GRAY更改为cv::COLOR_BGR2GRAY并检查是否cv::COLOR_BGR2GRAY

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM