OpenCV 3 中的消息“‘CV_SHAPE_ELLIPSE’未在此范围内声明”

Message "‘CV_SHAPE_ELLIPSE’ was not declared in this scope" in OpenCV 3

版本为3.0.0。我没有编写源代码,也不是 C++ 专家。

我第一次尝试编译,不得不从 CV_LOAD_IMAGE_COLOR 更改为 cv::IMREAD_COLOR,然后 CV_YCrCb2BGR 更改为 cv::COLOR_YCrCb2BGR(其他颜色转换也是如此) ).

现在说CV_SHAPE_ELLIPSE没有申报,但我不知道下一步该怎么做,网上也找不到答案。

我想你想设置 getStructuringElement 的形状。

已更改为cv::MORPH_ELLIPSECV_SHAPE_ELLIPSE 是旧 OpenCV 中用于形态学操作的结构元素形状之一 1.x API.

根据 opencv2/imgproc/types_c.h 中的评论:

/** Shapes of a structuring element for morphological operations
@see cv::MorphShapes, cv::getStructuringElement
*/
enum MorphShapes_c
{
    CV_SHAPE_RECT      =0,
    CV_SHAPE_CROSS     =1,
    CV_SHAPE_ELLIPSE   =2,
    CV_SHAPE_CUSTOM    =100 //!< custom structuring element
};

CV_SHAPE_ELLIPSIS 现在是 MORPH_ELLIPSE.,定义在 opencv2/imgproc.hpp:

//! shape of the structuring element
enum MorphShapes {
    MORPH_RECT    = 0, //!< a rectangular structuring element:  \f[E_{ij}=1\f]
    MORPH_CROSS   = 1, //!< a cross-shaped structuring element:
                       //!< \f[E_{ij} =  \fork{1}{if i=\texttt{anchor.y} or j=\texttt{anchor.x}}{0}{otherwise}\f]
    MORPH_ELLIPSE = 2 //!< an elliptic structuring element, that is, a filled ellipse inscribed
                      //!< into the rectangle Rect(0, 0, esize.width, 0.esize.height)
};