"xxx does not named a type" OpenCV 程序中的错误

"xxx does not named a type" error in OpenCV program

本文关键字:程序 错误 OpenCV xxx does not named type      更新时间:2023-10-16

我正在使用OpenCV库编写计算机视觉程序。在我的程序中,我通过"Vec3d"typedef"了一个名为"CLabPixelType"的类型,该类型表示Lab色彩空间中的彩色像素。但是,当我使用 XCode 4.4.1 在 Mac OS X Mountain Lion 下通过 g++ 编译代码时,我遇到了以下问题。

g++ ${CXXFLAGS} main.cpp slic.cpp slic_contrast.cpp -o sclbp -I/opt/local/include 
-L/opt/local/lib -lopencv_core.2.4.2 -lopencv_imgproc.2.4.2 -lopencv_highgui.2.4.2
In file included from /usr/include/c++/4.2.1/backward/map.h:59,
             from lxp_factory.h:8,
             from cmd_parser.h:4,
             from main.cpp:2:
/usr/include/c++/4.2.1/backward/backward_warning.h:32:2: warning: #warning This 
file includes at least one deprecated or antiquated header. Please consider using 
one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples 
include substituting the <X> header for the <X.h> header for C++ includes, or
<iostream> instead of the deprecated header     >>><iostream.h>. To disable this
warning use -Wno-deprecated.
In file included from lxp_framework.h:5,
             from lxp_factory.h:5,
             from cmd_parser.h:4,
             from main.cpp:2:
img_interpolater.h:10: error: ‘Vec3d’ does not name a type
img_interpolater.h:45: error: ‘CLabPixelType’ does not name a type
img_interpolater.h:97: error: ‘CLabPixelType’ does not name a type

我不知道为什么它显示"'Vec3d'没有命名类型?我在 Stackoverflow 中检查了有关此类"XX 不命名类型"错误的其他问题,但未能找到答案。

上次使用 opencv 库已经有一段时间了,但我认为问题可能是你没有考虑到命名空间 cv

尝试添加 using namespace cv ,或using namespace cv::CLabPixelType,或者每次使用名称时都像typedef cv::CLabPixelType Vec3d一样完全限定名称。