some functions not available

asked 2015-08-20 04:52:18 -0600

jeremyrutman gravatar image

updated 2015-08-24 06:04:34 -0600

I'd like to use fisherfaces but currently these funcs are not available; I did a clean cv2 v3.0 install and cmake like so:

cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DWITH_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON .. make clean make -j8 sudo make install

But then don't have access to createfisherfaces as you can see from the tab completion:

In [1]: import cv2

In [3]:> cv2.__version__

Out[3]: '3.0.0'

In [4]: cv2.cre

cv2.createAffineTransformer cv2.createAlignMTB cv2.createBackgroundSubtractorKNN cv2.createBackgroundSubtractorMOG2 cv2.createCLAHE cv2.createCalibrateDebevec cv2.createCalibrateRobertson cv2.createChiHistogramCostExtractor cv2.createEMDHistogramCostExtractor cv2.createEMDL1HistogramCostExtractor cv2.createHanningWindow cv2.createHausdorffDistanceExtractor cv2.createLineSegmentDetector cv2.createMergeDebevec cv2.createMergeMertens cv2.createMergeRobertson cv2.createNormHistogramCostExtractor cv2.createOptFlow_DualTVL1 cv2.createShapeContextDistanceExtractor cv2.createStitcher cv2.createThinPlateSplineShapeTransformer cv2.createTonemap cv2.createTonemapDrago cv2.createTonemapDurand cv2.createTonemapMantiuk cv2.createTonemapReinhard cv2.createTrackbar

I also tried a bunch of cmake variations such as

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$(python -c "import sys; print(sys.prefix)") -D PYTHON_EXECUTABLE=$(which python) -D BUILD_EXAMPLES=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_TESTS=ON -D BUILD_opencv_java=ON -D WITH_IPP=ON -D OPENCV_EXTRA_MODULES_PATH=/OpenCV/opencv_contrib-3.0.0/modules -D BUILD_NEW_PYTHON_SUPPORT=ON -DWITH_QT=ON -DWITH_OPENGL=ON -DWITH_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON ..

I tried git cloning the contrib as per berak's suggestion , and adding the path thereto to the cmake as follows:

jeremy@jrr:~/sw/OpenCV/opencv-3.0.0/build$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_EXAMPLES=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_TESTS=ON -D BUILD_opencv_java=ON -D WITH_IPP=ON -D OPENCV_EXTRA_MODULES_PATH=/home/jeremy/sw/OpenCV/opencv-3.0.0/contrib/opencv_contrib/modules -D BUILD_NEW_PYTHON_SUPPORT=ON -DWITH_QT=ON -DWITH_OPENGL=ON -DWITH_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON ..

but this seems to lead to make errors

[ 80%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_perf_xfeatures2d.dir/perf/perf_main.cpp.o
[ 82%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_perf_xfeatures2d.dir/perf/perf_surf.cuda.cpp.o
/home/jeremy/sw/OpenCV/opencv-3.0.0/contrib/opencv_contrib/modules/ximgproc/samples/disparity_filtering.cpp: In function ‘int main(int, char**)’:
/home/jeremy/sw/OpenCV/opencv-3.0.0/contrib/opencv_contrib/modules/ximgproc/samples/disparity_filtering.cpp:170:35: error: ‘MODE_SGBM_3WAY’ is not a member of ‘cv::StereoSGBM’
             left_matcher->setMode(StereoSGBM::MODE_SGBM_3WAY);
                                   ^
/home/jeremy/sw/OpenCV/opencv-3.0.0/contrib/opencv_contrib/modules/ximgproc/samples/disparity_filtering.cpp:235:30: error: ‘MODE_SGBM_3WAY’ is not a member of ‘cv::StereoSGBM’
             matcher->setMode(StereoSGBM::MODE_SGBM_3WAY);
                              ^
make[2]: *** [modules/ximgproc/CMakeFiles/example_ximgproc_disparity_filtering.dir/samples/disparity_filtering.cpp.o] Error 1
make[1]: *** [modules/ximgproc/CMakeFiles/example_ximgproc_disparity_filtering.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 82%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_perf_xfeatures2d.dir/perf/perf_latch.cpp.o
[ 82%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_rotation_and_scale_invariance.cpp.o
[ 82%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_main.cpp.o
[ 82%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_surf.ocl.cpp.o
[ 82%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_features2d.cpp.o
[ 82%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir ...
(more)
edit retag flag offensive close merge delete

Comments

you need the contrib repo . see readme there.

then it's all in cv2.face:

>>> help(cv2.face)
Help on module cv2.face in cv2:

NAME
    cv2.face

FILE
    (built-in)

FUNCTIONS
    createEigenFaceRecognizer(...)
        createEigenFaceRecognizer([, num_components[, threshold]]) -> retval

    createFisherFaceRecognizer(...)
        createFisherFaceRecognizer([, num_components[, threshold]]) -> retval

    createLBPHFaceRecognizer(...)
        createLBPHFaceRecognizer([, radius[, neighbors[, grid_x[, grid_y[, thres
hold]]]]]) -> retval
berak gravatar imageberak ( 2015-08-20 05:55:02 -0600 )edit
1

as detailed above i gave it a shot but the addition of contrib seems to lead to cmake errors

jeremyrutman gravatar imagejeremyrutman ( 2015-08-20 15:35:52 -0600 )edit

about the MODE_SGBM_3WAY , see here and here - recent addition, 3 weeks ago.

so, update the main opencv repo, too ! (sync problem)

berak gravatar imageberak ( 2015-08-20 22:57:59 -0600 )edit

Thanks again for response - I git cloned the main and contrib repos , and did cmake again, this time with no compile errors - but still don't see createfisherfaces in python tho the output of make show stuff is getting compiled - do I need to add something to my path?

jeremy@jrr:~/sw/OpenCV/opencv/build$ grep fisher makeoutput.txt

[ 36%] Building CXX object modules/face/CMakeFiles/opencv_face.dir/src/fisher_faces.cpp.o Scanning dependencies of target example_face_facerec_fisherfaces

[ 38%] Building CXX object modules/face/CMakeFiles/example_face_facerec_fisherfaces.dir/samples/facerec_fisherfaces.cpp.o Linking CXX executable ../../bin/example_face_facerec_fisherfaces

[ 38%] Built target example_face_facerec_fisherfaces

jeremyrutman gravatar imagejeremyrutman ( 2015-08-23 02:37:00 -0600 )edit

again, look into the cv2.face submodule in python.

berak gravatar imageberak ( 2015-08-23 03:09:39 -0600 )edit

great, thanks that did it. Now if only I can improve the recognition accuracy - the 98% claimed in the demo docs seems a bit out of reach ...

jeremyrutman gravatar imagejeremyrutman ( 2015-08-24 03:19:59 -0600 )edit

maybe you could make a little writeup with the steps to success, and make an answer here ?

berak gravatar imageberak ( 2015-08-24 04:08:29 -0600 )edit

ok i added a brief writeup, it was too long to fit here tho so it's sort of buried

jeremyrutman gravatar imagejeremyrutman ( 2015-08-24 06:05:30 -0600 )edit