biometrics / openbr

Open Source Biometrics, Face Recognition
www.openbiometrics.org
Other
2.85k stars 772 forks source link

openbr build failed with non-global OpenCV #533

Open shixudongleo opened 7 years ago

shixudongleo commented 7 years ago

I have multiple OpenCV versions on Ubuntu 14.04. OpenCV 3.0 is installed globally to /usr/local and OpenCV 2.4.11 locally $HOME/DevTools/OpenCV2.4.11/compiled.

And I want to compile openbr with OpenCV 2.4.11. I write a FindOpenCV.cmake under openbr/share/openbr/cmake/FindOpenCV.cmake.

# content of FindOpenCV.cmake
set (OpenCV_DIR /home/shixudongleo/DevTools/OpenCV2.4.11/compiled)

I found this problem is similar to issue #482, so even though I set the OpenCV version to use 2.4.11. It is still linking against global OpenCV 3.0. How should I fix the problem without install OpenCV 2.4.11 globally?

Here is the error when building openbr:

[  1%] Creating directories for 'models'
[  1%] Performing download step (download, verify and extract) for 'models'
-- downloading...
     src='http://github.com/biometrics/openbr/releases/download/v1.1.0/models.tar.gz'
     dst='/home/shixudongleo/Projects/openbr/build/models-prefix/src/models.tar.gz'
     timeout='none'
-- downloading... done
-- verifying file...
     file='/home/shixudongleo/Projects/openbr/build/models-prefix/src/models.tar.gz'
-- verifying file... done
-- extracting...
     src='/home/shixudongleo/Projects/openbr/build/models-prefix/src/models.tar.gz'
     dst='/home/shixudongleo/Projects/openbr/share/openbr/models'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[  1%] No patch step for 'models'
[  1%] No update step for 'models'
[  1%] No configure step for 'models'
[  2%] No build step for 'models'
[  2%] No install step for 'models'
[  2%] Completed 'models'
[  2%] Built target models
[  3%] Automoc for target openbr
Generating core.moc
Generating moc_algorithm.cpp
Generating moc_classifier.cpp
Generating moc_dataset.cpp
Generating moc_gallerytoolbar.cpp
Generating moc_galleryviewer.cpp
Generating moc_help.cpp
Generating moc_progress.cpp
Generating moc_rankretrieval.cpp
Generating moc_recognitionbar.cpp
Generating moc_score.cpp
Generating moc_splashscreen.cpp
Generating moc_tail.cpp
Generating moc_templatemetadata.cpp
Generating moc_templateviewer.cpp
Generating moc_templateviewergrid.cpp
Generating moc_view.cpp
Generating classification/adaboost.moc
Generating classification/boostedforest.moc
Generating classification/cascade.moc
Generating classification/ebif.moc
Generating classification/forest.moc
Generating classification/lda.moc
Generating classification/mlp.moc
Generating classification/svm.moc
Generating classification/turk.moc
Generating cluster/collectnn.moc
Generating cluster/kmeans.moc
Generating cluster/knn.moc
Generating cluster/lognn.moc
Generating cluster/meanshift.moc
Generating onlinerod.moc
Generating cluster/randomcentroids.moc
Generating core/algorithms.moc
Generating core/attributealgorithms.moc
Generating core/cache.moc
Generating core/contract.moc
Generating core/crossvalidate.moc
Generating core/discard.moc
Generating core/discardtemplates.moc
Generating core/distributetemplate.moc
Generating core/downsampletraining.moc
Generating core/event.moc
Generating core/expand.moc
Generating core/first.moc
Generating core/fork.moc
Generating core/fte.moc
Generating core/gallerycompare.moc
Generating core/identity.moc
Generating core/independent.moc
Generating core/loadstore.moc
Generating core/pipe.moc
Generating core/processwrapper.moc
Generating core/progresscounter.moc
Generating core/propagate.moc
Generating core/registrar.moc
Generating core/remove.moc
Generating core/rest.moc
Generating core/schrodinger.moc
Generating core/singleton.moc
Generating core/stream.moc
Generating distance/L1.moc
Generating distance/L2.moc
Generating distance/attribute.moc
Generating distance/bayesianquantization.moc
Generating distance/byteL1.moc
Generating distance/crossvalidate.moc
Generating distance/default.moc
Generating distance/dist.moc
Generating distance/emd.moc
Generating distance/filter.moc
Generating distance/fuse.moc
Generating distance/halfbyteL1.moc
Generating distance/heatmap.moc
Generating distance/identical.moc
Generating distance/keypointmatcher.moc
Generating distance/matchprobability.moc
Generating distance/metadata.moc
Generating distance/neglogplusone.moc
Generating distance/online.moc
Generating distance/permute.moc
Generating distance/pipe.moc
Generating distance/reject.moc
Generating distance/sum.moc
Generating distance/svm.moc
Generating distance/threshold.moc
Generating distance/turk.moc
Generating distance/unit.moc
Generating distance/zscore.moc
Generating format/binary.moc
Generating format/csv.moc
Generating format/ebts.moc
Generating format/lffs.moc
Generating format/mat.moc
Generating format/mtx.moc
Generating format/null.moc
Generating format/post.moc
Generating format/raw.moc
Generating format/scores.moc
Generating format/url.moc
Generating format/video.moc
Generating format/xml.moc
Generating gallery/arff.moc
Generating gallery/binary.moc
Generating gallery/crawl.moc
Generating gallery/csv.moc
Generating gallery/db.moc
Generating gallery/default.moc
Generating gallery/empty.moc
Generating gallery/fddb.moc
Generating gallery/flat.moc
Generating gallery/google.moc
Generating gt.moc
Generating gallery/landmarks.moc
Generating gallery/matlab.moc
Generating gallery/matrix.moc
Generating gallery/mem.moc
Generating gallery/post.moc
Generating gallery/seq.moc
Generating gallery/stat.moc
Generating gallery/template.moc
Generating gallery/turk.moc
Generating gallery/txt.moc
Generating gallery/vec.moc
Generating gallery/video.moc
Generating gallery/xml.moc
Generating gui/adjacentoverlay.moc
Generating gui/draw.moc
Generating gui/drawdelaunay.moc
Generating gui/drawgridlines.moc
Generating gui/drawopticalflow.moc
Generating gui/drawpropertiespoint.moc
Generating gui/drawpropertypoint.moc
Generating gui/drawsegmentation.moc
Generating gui/show.moc
Generating imgproc/abs.moc
Generating imgproc/absdiff.moc
Generating imgproc/adaptivethreshold.moc
Generating imgproc/affine.moc
Generating imgproc/and.moc
Generating imgproc/applymask.moc
Generating imgproc/bayesianquantization.moc
Generating imgproc/binarize.moc
Generating imgproc/blend.moc
Generating imgproc/blur.moc
Generating imgproc/byrow.moc
Generating imgproc/canny.moc
Generating imgproc/cat.moc
Generating imgproc/catcols.moc
Generating imgproc/catrows.moc
Generating imgproc/center.moc
Generating imgproc/contrasteq.moc
Generating imgproc/convexhull.moc
Generating imgproc/crop.moc
Generating imgproc/cropblack.moc
Generating imgproc/cropfromlandmarks.moc
Generating imgproc/cropfrommask.moc
Generating imgproc/cropsquare.moc
Generating imgproc/cryptographichash.moc
Generating imgproc/csdn.moc
Generating custom_sift.moc
Generating imgproc/cvt.moc
Generating imgproc/cvtfloat.moc
Generating imgproc/cvtuchar.moc
Generating imgproc/denoising.moc
Generating imgproc/discardalpha.moc
Generating imgproc/div.moc
Generating imgproc/dog.moc
Generating imgproc/downsample.moc
Generating imgproc/dup.moc
Generating imgproc/ensurechannels.moc
Generating imgproc/equalizehist.moc
Generating imgproc/fillcontours.moc
Generating imgproc/flip.moc
Generating imgproc/flood.moc
Generating imgproc/gabor.moc
Generating imgproc/gamma.moc
Generating imgproc/gradient.moc
Generating imgproc/gradientmask.moc
Generating imgproc/group.moc
Generating imgproc/heatmap.moc
Generating imgproc/hist.moc
Generating imgproc/histbin.moc
Generating imgproc/histeqquantization.moc
Generating imgproc/hog.moc
Generating imgproc/humoments.moc
Generating imgproc/if.moc
Generating imgproc/inpaint.moc
Generating imgproc/integral.moc
Generating imgproc/integralhist.moc
Generating imgproc/integralsampler.moc
Generating imgproc/kernelhash.moc
Generating imgproc/keypointdescriptor.moc
Generating imgproc/largestconvexarea.moc
Generating imgproc/lbp.moc
Generating imgproc/limitsize.moc
Generating imgproc/ltp.moc
Generating imgproc/madd.moc
Generating imgproc/mask.moc
Generating imgproc/matstats.moc
Generating imgproc/mean.moc
Generating imgproc/meanfill.moc
Generating imgproc/merge.moc
Generating imgproc/morph.moc
Generating imgproc/multiscale.moc
Generating imgproc/normalize.moc
Generating imgproc/origlinearregression.moc
Generating imgproc/pack.moc
Generating imgproc/pad.moc
Generating imgproc/pow.moc
Generating imgproc/productquantization.moc
Generating imgproc/quantize.moc
Generating imgproc/rank.moc
Generating imgproc/rectregions.moc
Generating imgproc/recursiveintegralsampler.moc
Generating imgproc/redlinearregression.moc
Generating imgproc/reshape.moc
Generating imgproc/resize.moc
Generating imgproc/resizefilter.moc
Generating imgproc/revertaffine.moc
Generating imgproc/rg.moc
Generating imgproc/rndaffine.moc
Generating imgproc/rndpoint.moc
Generating imgproc/rndregion.moc
Generating imgproc/rndrotate.moc
Generating imgproc/rndsample.moc
Generating imgproc/rndsubspace.moc
Generating imgproc/roi.moc
Generating imgproc/roifrompoints.moc
Generating imgproc/rootnorm.moc
Generating imgproc/rowwisemeancenter.moc
Generating imgproc/samplefrommask.moc
Generating imgproc/scale.moc
Generating imgproc/scalemat.moc
Generating imgproc/shapeaxisratio.moc
Generating imgproc/sift.moc
Generating imgproc/skinmask.moc
Generating imgproc/slidingwindow.moc
Generating imgproc/sobel.moc
Generating imgproc/split.moc
Generating imgproc/subdivide.moc
Generating imgproc/subtract.moc
Generating synthesizekeypoints.moc
Generating imgproc/threshold.moc
Generating imgproc/transpose.moc
Generating imgproc/trim.moc
Generating imgproc/watershedsegmentation.moc
Generating io/decode.moc
Generating io/download.moc
Generating io/galleryoutput.moc
Generating io/incrementaloutput.moc
Generating io/open.moc
Generating io/out.moc
Generating io/print.moc
Generating io/read.moc
Generating io/readlandmarks.moc
Generating io/write.moc
Generating io/youtubefacesdb.moc
Generating metadata/anonymizelandmarks.moc
Generating metadata/as.moc
Generating metadata/averagepoints.moc
Generating metadata/cascade.moc
Generating metadata/check.moc
Generating metadata/checkpoints.moc
Generating metadata/clearpoints.moc
Generating metadata/consolidatedetections.moc
Generating metadata/croprect.moc
Generating metadata/delaunay.moc
Generating metadata/expandrect.moc
Generating metadata/extractmetadata.moc
Generating metadata/eyes.moc
Generating metadata/facefromeyes.moc
Generating metadata/fileexclusion.moc
Generating metadata/filterdupemetadata.moc
Generating metadata/filtermetadata.moc
Generating metadata/fixrects.moc
Generating metadata/grid.moc
Generating metadata/groundtruth.moc
Generating metadata/hogpersondetector.moc
Generating metadata/ifmetadata.moc
Generating metadata/imposteruniquenessmeasure.moc
Generating metadata/ipd.moc
Generating metadata/json.moc
Generating metadata/keepmetadata.moc
Generating metadata/keypointdetector.moc
Generating metadata/keytolandmark.moc
Generating metadata/name.moc
Generating metadata/namelandmarks.moc
Generating metadata/normalizemetadata.moc
Generating metadata/normalizepoints.moc
Generating metadata/normalizepointstorect.moc
Generating metadata/pointdisplacement.moc
Generating metadata/pointstomatrix.moc
Generating metadata/pointstorects.moc
Generating metadata/procrustes.moc
Generating metadata/rectfrompoints.moc
Generating metadata/rectstomats.moc
Generating metadata/rectstotemplates.moc
Generating metadata/recttokeys.moc
Generating metadata/regexproperty.moc
Generating metadata/registerpointsasaffine.moc
Generating metadata/removemetadata.moc
Generating metadata/removetemplates.moc
Generating metadata/rename.moc
Generating metadata/renamefirst.moc
Generating metadata/reorderpoints.moc
Generating metadata/restoremat.moc
Generating metadata/savemat.moc
Generating metadata/scalemetadata.moc
Generating metadata/scalerects.moc
Generating metadata/selectpoints.moc
Generating metadata/setmetadata.moc
Generating metadata/setpointsinrect.moc
Generating metadata/squarefrompoints.moc
Generating metadata/stasm4.moc
Generating metadata/stopwatch.moc
Generating metadata/verifydetection.moc
Generating output/best.moc
Generating output/csv.moc
Generating output/default.moc
Generating output/empty.moc
Generating output/eval.moc
Generating output/heat.moc
Generating output/hist.moc
Generating output/knn.moc
Generating output/melt.moc
Generating output/mtx.moc
Generating output/null.moc
Generating output/rank.moc
Generating output/rr.moc
Generating output/tail.moc
Generating output/txt.moc
Generating representation/haar.moc
Generating representation/mblbp.moc
Generating representation/npd.moc
Generating representation/random.moc
Generating video/aggregate.moc
Generating video/drop.moc
Generating video/opticalflow.moc
Generating moc_faceviewer.cpp
Generating moc_formcombowidget.cpp
Generating moc_imageviewer.cpp
Generating moc_metadata.cpp
Generating moc_pageflipwidget.cpp
Generating moc_rangewidget.cpp
Generating moc_searchboxwidget.cpp
Generating moc_subjectviewer.cpp
Generating moc_subjectviewergrid.cpp
Generating moc_transformeditor.cpp
Generating moc_transformlisteditor.cpp
Generating moc_openbr_plugin.cpp
Generating moc_openbr_internal.cpp
[  3%] Built target openbr_automoc
[  3%] Generating qrc_icons.cpp
Scanning dependencies of target openbr
[  3%] Building CXX object openbr/CMakeFiles/openbr.dir/openbr.cpp.o
[  3%] Building CXX object openbr/CMakeFiles/openbr.dir/openbr_plugin.cpp.o
In file included from /home/shixudongleo/Projects/openbr/openbr/openbr_plugin.cpp:42:0:
/home/shixudongleo/Projects/openbr/openbr/core/opencvutils.h:55:27: error: ‘CvStatModel’ does not name a type
     void storeModel(const CvStatModel &model, QDataStream &stream);
                           ^
/home/shixudongleo/Projects/openbr/openbr/core/opencvutils.h:55:40: error: ISO C++ forbids declaration of ‘model’ with no type [-fpermissive]
     void storeModel(const CvStatModel &model, QDataStream &stream);
                                        ^
/home/shixudongleo/Projects/openbr/openbr/core/opencvutils.h:57:20: error: variable or field ‘loadModel’ declared void
     void loadModel(CvStatModel &model, QDataStream &stream);
                    ^
/home/shixudongleo/Projects/openbr/openbr/core/opencvutils.h:57:20: error: ‘CvStatModel’ was not declared in this scope
/home/shixudongleo/Projects/openbr/openbr/core/opencvutils.h:57:33: error: ‘model’ was not declared in this scope
     void loadModel(CvStatModel &model, QDataStream &stream);
                                 ^
/home/shixudongleo/Projects/openbr/openbr/core/opencvutils.h:57:52: error: expected primary-expression before ‘&’ token
     void loadModel(CvStatModel &model, QDataStream &stream);
                                                    ^
/home/shixudongleo/Projects/openbr/openbr/core/opencvutils.h:57:53: error: ‘stream’ was not declared in this scope
     void loadModel(CvStatModel &model, QDataStream &stream);
                                                     ^
make[2]: *** [openbr/CMakeFiles/openbr.dir/openbr_plugin.cpp.o] Error 1
make[1]: *** [openbr/CMakeFiles/openbr.dir/all] Error 2
make: *** [all] Error 2

I also found that openbr/share/openbr/cmake/InstallDependencies.cmake file is hard code the library path

# OpenCV Libs
function(install_opencv_library lib)
  if(${BR_INSTALL_DEPENDENCIES})
    if(CMAKE_HOST_WIN32)
      if(${CMAKE_BUILD_TYPE} MATCHES Debug)
        set(BR_INSTALL_DEPENDENCIES_SUFFIX "d")
      endif()
      if(NOT MSVC)
        set(BR_INSTALL_DEPENDENCIES_PREFIX "lib")
      endif()
      list(GET OpenCV_LIB_DIR 0 cv_lib_stripped)
      install(FILES ${cv_lib_stripped}/../bin/${BR_INSTALL_DEPENDENCIES_PREFIX}${lib}${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}${BR_INSTALL_DEPENDENCIES_SUFFIX}.dll DESTINATION bin)
    elseif(CMAKE_HOST_APPLE)
      set(OpenCV_LIB_DIR "/usr/local/lib")
      install(FILES ${OpenCV_LIB_DIR}/lib${lib}.${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR}.${OpenCV_VERSION_PATCH}${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION lib)
      install(FILES ${OpenCV_LIB_DIR}/lib${lib}.${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR}${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION lib)
      install(FILES ${OpenCV_LIB_DIR}/lib${lib}${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION lib)
    else()
      set(OpenCV_LIB_DIR "/usr/local/lib")
      install(FILES ${OpenCV_LIB_DIR}/lib${lib}${CMAKE_SHARED_LIBRARY_SUFFIX}.${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR}.${OpenCV_VERSION_PATCH} DESTINATION lib)
      install(FILES ${OpenCV_LIB_DIR}/lib${lib}${CMAKE_SHARED_LIBRARY_SUFFIX}.${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR} DESTINATION lib)
      install(FILES ${OpenCV_LIB_DIR}/lib${lib}${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION lib)
    endif()
  endif()
endfunction()
fly-duck commented 5 years ago

Did you find any solutions? I met the same issue

fly-duck commented 5 years ago

I remove the files in /usr/local/include/opencv and opencv2 it works