2017-01-11 74 views
5

Próbuję zainstalować OpenCV 3.2 wraz z modułami z opencv_contrib na Ubuntu 16.04."OPENCV_TEST_DATA_PATH zmienna środowiskowa nie została określona" podczas instalowania OpenCV 3.2 z opencv_contib

Jednak, kiedy uruchomić polecenie z sudo make install, pojawia się następujący komunikat:

➜ build git:(master) sudo make install 
-- Detected version of GNU GCC: 54 (504) 
-- FP16: Feature disabled 
-- Found ZLIB: /usr/lib64/libz.so (found suitable version "1.2.8", minimum required is "1.2.3") 
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.8") 
-- Looking for linux/videodev.h 
-- Looking for linux/videodev.h - not found 
-- Looking for linux/videodev2.h 
-- Looking for linux/videodev2.h - found 
-- Looking for sys/videoio.h 
-- Looking for sys/videoio.h - not found 
-- Checking for module 'libavresample' 
-- No package 'libavresample' found 
-- Checking for module 'libgphoto2' 
-- No package 'libgphoto2' found 
-- Found TBB: /usr/lib64/libtbb.so 
-- found IPP (ICV version): 9.0.1 [9.0.1] 
-- at: /home/denis/code/opencv/build/3rdparty/ippicv/ippicv_lnx 
-- CUDA detected: 8.0 
-- CUDA NVCC target flags: -gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-D_FORCE_INLINES 
-- LAPACK_IMPL: OpenBLAS, LAPACK_LIBRARIES: /opt/OpenBLAS/lib/libopenblas.so 
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- Could NOT find Matlab (missing: MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) 
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file 
-- Caffe: NO 
-- Protobuf: YES 
-- Glog: YES 
-- freetype2: YES 
-- harfbuzz: YES 
-- Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags 
-- Assume that non-module dependency is available: freetype (for module opencv_freetype) 
-- Assume that non-module dependency is available: harfbuzz (for module opencv_freetype) 
CMake Error at /home/denis/code/opencv_contrib/modules/dnn/CMakeLists.txt:84 (message): 
    OPENCV_TEST_DATA_PATH environment variable was not specified 


-- Configuring incomplete, errors occurred! 
See also "/home/denis/code/opencv/build/CMakeFiles/CMakeOutput.log". 
See also "/home/denis/code/opencv/build/CMakeFiles/CMakeError.log". 
Makefile:10450: recipe for target 'cmake_check_build_system' failed 
make: *** [cmake_check_build_system] Error 1 

Chodzi o to, że był już prawie ten sam błąd, gdy próbuje uruchomić komendę make -j8 a potem już dodano zmienną środowiskową OPENCV_TEST_DATA_PATH do moich ~/.bashrc i ~/.zshrc plików takiego:

export OPENCV_TEST_DATA_PATH=/home/denis/code/opencv_extra/testdata 

Pobrałem opencv_extra repo wcześniej. A błąd zniknął! Mogłem pomyślnie uruchomić polecenie make -j8.

Po uruchomieniu polecenia make -j8, następnie spróbowałem uruchomić polecenie sudo make install i otrzymałem wynik, który widzisz powyżej.

Ta zmienna jest określona:

➜ build echo $OPENCV_TEST_DATA_PATH 
/home/denis/code/opencv_extra/testdata 

Tak, nie jestem pewien, co należy zrobić, aby prawidłowo zainstalować OpenCV.

PS: oto polecenie cmake użyłem:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_CUBLAS=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules .. 

mógłbyś mi pomóc rozwiązać ten problem?

Odpowiedz

3

OK, więc błąd wskazywał na linię 84 pliku opencv_contrib/modules/dnn/CMakeLists.txt. Sprawdziłem to i próbowałem skomentować całą sprawę Generating test data for Torch importer (spójrz na koniec pliku podanego poniżej).

Potem próbowałem ponownie uruchomić sudo make install i wszystko działało jak czar.

Nie jestem pewien, co się dzieje i co Torch ma wspólnego z OpenCV, jednak mam zainstalowany Torch7 na moim komputerze z Ubuntu 16.04. Nie jestem pewien, czy jest w jakiś sposób połączony, czy nie, ale pomógł mi komentarz.

Ważne jest, aby pamiętać, że wykonując te same czynności na komputerze Ubuntu 14.04 (bez zainstalowanego Torch7), błąd nie pojawił się wcale.


Poniżej znajduje się treść opencv_contrib/modules/dnn/CMakeLists.txt że pracował dla mnie:

cmake_minimum_required(VERSION 2.8) 

if(APPLE_FRAMEWORK OR WINRT 
    OR AARCH64 # protobuf doesn't know this platform 
) 
    ocv_module_disable(dnn) 
endif() 

set(the_description "Deep neural network module. It allows to load models from different frameworks and to make forward pass") 
set(OPENCV_MODULE_IS_PART_OF_WORLD OFF) 

ocv_add_module(dnn opencv_core opencv_imgproc WRAP python matlab) 
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses -Wmaybe-uninitialized -Wsign-promo 
            -Wmissing-declarations -Wmissing-prototypes 
) 
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4701 /wd4100) 

if(MSVC) 
    add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) 
    ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 
             /wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610 
             /wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506 
) 
else() 
    ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow 
             -Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo 
             -Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra 
             -Wunused-function -Wunused-const-variable -Wdeprecated-declarations 
) 
endif() 

if(ANDROID) 
    add_definitions(-DDISABLE_POSIX_MEMALIGN -DTH_DISABLE_HEAP_TRACKING) 
endif() 

# ---------------------------------------------------------------------------- 
# Resolve libprotobuf dependency 
# ---------------------------------------------------------------------------- 
include(cmake/OpenCVFindLibProtobuf.cmake) 
ocv_source_group("Src\\protobuf" FILES ${PROTOBUF_SRCS} ${PROTOBUF_HDRS}) 
ocv_module_include_directories(include ${PROTOBUF_INCLUDE_DIR}) 

ocv_glob_module_sources(${PROTOBUF_SRCS} ${PROTOBUF_HDRS} ${CBLAS_H_PROXY_PATH}) 
ocv_create_module(${PROTOBUF_LIBRARIES}) 
ocv_add_samples() 
ocv_add_accuracy_tests() 
ocv_add_perf_tests() 

# ---------------------------------------------------------------------------- 
# Download pre-trained models for complex testing on GoogLeNet and AlexNet 
# ---------------------------------------------------------------------------- 
OCV_OPTION(${the_module}_DOWNLOAD_CAFFE_MODELS "Use GoogLeNet Caffe model for testing" OFF IF BUILD_TESTS AND DEFINED ENV{OPENCV_TEST_DATA_PATH}) 
if(BUILD_TESTS AND DEFINED ENV{OPENCV_TEST_DATA_PATH} AND (DOWNLOAD_EXTERNAL_TEST_DATA OR ${the_module}_DOWNLOAD_CAFFE_MODELS)) 
    add_custom_command(TARGET opencv_test_${name} POST_BUILD 
         COMMAND ${CMAKE_COMMAND} -Dmodel=GoogleNet -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/download_model.cmake) 
    add_definitions(-DENABLE_CAFFE_MODEL_TESTS=1) 
endif() 

# ---------------------------------------------------------------------------- 
# Torch7 importer of blobs and models, produced by Torch.nn module 
# ---------------------------------------------------------------------------- 
OCV_OPTION(${the_module}_BUILD_TORCH_IMPORTER "Build Torch model importer" ON) 
if(${the_module}_BUILD_TORCH_IMPORTER) 
    add_definitions(-DENABLE_TORCH_IMPORTER=1) 
    ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702 /wd4127 /wd4267) #supress warnings in original torch files 

    if(NOT DEFINED HAVE_TORCH_EXE) 
     execute_process(COMMAND th ${CMAKE_CURRENT_SOURCE_DIR}/testdata/dnn/torch/torch_nn_echo.lua RESULT_VARIABLE TORCH_EXE_STATUS) 
     set(HAVE_TORCH_EXE OFF) 
     if(${TORCH_EXE_STATUS} EQUAL 0) 
      set(HAVE_TORCH_EXE ON) 
     endif() 
     set(HAVE_TORCH_EXE ${HAVE_TORCH_EXE} CACHE INTERNAL "Have torch binary") 
    endif() 
endif() 

# ---------------------------------------------------------------------------- 
# Generating test data for Torch importer 
# ---------------------------------------------------------------------------- 
# OCV_OPTION(${the_module}_BUILD_TORCH_TESTS "Build Torch tests (installed torch7 with nn module is required)" ON IF BUILD_TESTS AND ${the_module}_BUILD_TORCH_IMPORTER AND HAVE_TORCH_EXE) 
# if(${the_module}_BUILD_TORCH_TESTS) 
# 
#  if(NOT DEFINED ENV{OPENCV_TEST_DATA_PATH}) 
#   message(FATAL_ERROR "OPENCV_TEST_DATA_PATH environment variable was not specified") 
#  endif() 
# 
#  if(NOT HAVE_TORCH_EXE) 
#   message(FATAL_ERROR "Torch executable \"th\" not found or nn module not found") 
#  endif() 
# 
#  add_custom_command(TARGET opencv_test_${name} POST_BUILD 
#       COMMAND th ${CMAKE_CURRENT_SOURCE_DIR}/testdata/dnn/torch/torch_gen_test_data.lua 
#       WORKING_DIRECTORY $ENV{OPENCV_TEST_DATA_PATH}/dnn/torch) 
#  add_definitions(-DENABLE_TORCH_TESTS=1) 
# endif()