“xxx在OpenCV程序中没有命名类型”错误

时间:2012-08-15 02:11:18

标签: c++ opencv g++

我正在使用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没有命名类型“错误的问题,但未能找到答案。

1 个答案:

答案 0 :(得分:2)

有一段时间我最后一次使用opencv库,但我认为问题可能是你没有考虑到namespace cv

尝试添加using namespace cvusing namespace cv::CLabPixelType,或者只在每次使用时完全限定名称,例如typedef cv::CLabPixelType Vec3d