我正在阅读文章
http://docs.opencv.org/trunk/modules/contrib/doc/facerec/facerec_tutorial.html#conclusion
并尝试运行代码facerec_lbph.cpp
。但是,我遇到了以下错误:
facerec_lbph.cpp:109:9: error: ‘FaceRecognizer’ was not declared in this scope
facerec_lbph.cpp:109:23: error: template argument 1 is invalid
facerec_lbph.cpp:109:31: error: invalid type in declaration before ‘=’ token
facerec_lbph.cpp:109:58: error: ‘createLBPHFaceRecognizer’ was not declared in this scope
facerec_lbph.cpp:110:10: error: base operand of ‘->’ is not a pointer
facerec_lbph.cpp:113:31: error: base operand of ‘->’ is not a pointer
facerec_lbph.cpp:132:10: error: base operand of ‘->’ is not a pointer
facerec_lbph.cpp:136:27: error: base operand of ‘->’ is not a pointer
facerec_lbph.cpp:144:18: error: base operand of ‘->’ is not a pointer
facerec_lbph.cpp:145:18: error: base operand of ‘->’ is not a pointer
facerec_lbph.cpp:146:18: error: base operand of ‘->’ is not a pointer
facerec_lbph.cpp:147:18: error: base operand of ‘->’ is not a pointer
facerec_lbph.cpp:148:18: error: base operand of ‘->’ is not a pointer
facerec_lbph.cpp:151:35: error: base operand of ‘->’ is not a pointer
OpenCV版本
opencv-2.3.1-3.fc16.x86_64
opencv-python-2.3.1-3.fc16.x86_64
opencv-devel-2.3.1-3.fc16.x86_64
opencv-devel-docs-2.3.1-3.fc16.noarch
系统版本是fedora 16,即64位。我正在使用的makefile是:
CC = g++
SRC = facerec_lbph.cpp
TARGET = main
OBJS = facerec_lbph.o
INCDIRS = -I/usr/include/opencv -I/usr/include/opencv2
LIBDIRS = -L/usr/lib64
CFLAGS = -g $(INCDIRS)
LFLAGS = -lopencv_core -lopencv_highgui -lopencv_video -lopencv_imgproc -lopencv_objdetect -lopencv_ml -lopencv_contrib
all: $(OBJS)
$(CC) -o $(TARGET) $(OBJS) $(INCDIRS) $(LIBDIRS) $(LFLAGS)
main.o: $(SRC) $(INCLUDE)
$(CC) -c $(SRC) $(INCLUDE) $(INCDIRS) $(LIBDIRS) $(LFLAGS)
clean:
rm -f $(TARGET) $(OBJS) *.gch
每当需要新信息时,我都可以更新错误报告。谢谢!
答案 0 :(得分:2)
问题是,您使用的是OpenCV 2.3.1。此OpenCV版本还没有cv :: FaceRecognizer,因此可以解释您的错误消息。我强烈建议您更新到OpenCV 2.4.2。
文档附带了大量示例:
但是,如果您无法更新到最近的OpenCV版本,您还可以尝试使用libfacerec的0.03版本(libfacerec是我为OpenCV做出的贡献)。它与所有OpenCV 2.3版本兼容。它的界面略有不同,但算法相同。以下是可用的标签,您可以下载: