Ask Your Question

Revision history [back]

[4.1.0-dev] Issue while compiling FaceDetection.cpp example

Hello,

I finally write my first topic after having tried to compile one of the cpp tutorials example without any success. This one exactly : https://docs.opencv.org/master/d4/d26/samples_2cpp_2facedetect_8cpp-example.html

I'm using cpp (GCC) 8.3.0 with cmake 3.14.3 on a 5.0.9-2-MANJARO x86_64.


1/ So, I first met an issue concerning haarcascade_eye_tree_eyeglasses.xml and haarcascade_frontalface_alt.xml that were missing. After some searchs, I found a topic where it was written to download these files directly on the opencv github. https://github.com/opencv/opencv/tree/master/data/haarcascades

2/ My folder tree looks like this :

.
├── CMakeLists.txt
├── data
│   └── haarcascades
│       ├── haarcascade_eye_tree_eyeglasses.xml
│       └── haarcascade_frontalface_alt.xml
├── FaceDetect.cpp
├── FaceDetection.cpp
└── Makefile

2 directories, 6 files

3/ my CmakeLists.txt looks like this :

$ cat CMakeLists.txt 
cmake_minimum_required(VERSION 2.8)
project( FaceDetection )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( FaceDetection FaceDetection.cpp )
target_link_libraries( FaceDetection ${OpenCV_LIBS} )

4/ The output of cmake . looks good :

$ cmake .
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: /usr/local (found version "4.1.0") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vr0um/cpp/opencv/FaceDetection

5/ Same for the output of make that looks like below :

$ make
Scanning dependencies of target FaceDetection
[ 50%] Building CXX object CMakeFiles/FaceDetection.dir/FaceDetection.cpp.o
[100%] Linking CXX executable FaceDetection
[100%] Built target FaceDetection

6/ I'm facing to an issue once I'm trying to execute the program :

$ ./FaceDetection 
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.1.0-dev) /home/vr0um/OpenCV/opencv/modules/core/src/persistence.cpp:719: error: (-49:Unknown error code -49) Input file is empty in function 'open'

Aborted (core dumped)

I've been looking for a solution for few weeks now and I still don't find how to solve it. I didn't find similar issue that has been solved on search engines. I don't understand what it means by saying "input file is empty in function 'open'.

Do someone know how I could fix the issue?

Thank you.