问题
I'm reading the article
http://docs.opencv.org/trunk/modules/contrib/doc/facerec/facerec_tutorial.html#conclusion
and try to run the code facerec_lbph.cpp
. However, I ran into the following errors:
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
The OpenCV version is
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
And the system version is fedora 16 which is 64 bits. The makefile I'm using is:
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
And I can update the error report whenever new information is necessary. Thanks!
回答1:
The problem is, that you are using OpenCV 2.3.1. This OpenCV Version didn't have a cv::FaceRecognizer yet, so that explains your error message. I would strongly suggest you update to OpenCV 2.4.2.
The documentation comes with a lot of samples:
- http://docs.opencv.org/trunk/modules/contrib/doc/facerec/index.html
- http://code.opencv.org/projects/opencv/repository/show/trunk/opencv/modules/contrib/doc/facerec/src
However if you can't update to recent OpenCV versions, you could also try to use version 0.03 of libfacerec (libfacerec is the project I contributed to OpenCV). It is compatible to all OpenCV 2.3 versions. It has a slightly different interface, but the same algorithms. Here are the available tags, you could download:
- https://github.com/bytefish/libfacerec/tags
来源:https://stackoverflow.com/questions/11397606/facerecognizer-in-opencv