我认为here发生的问题几乎相同。
我做了这个problem的评论和答复,在CMakeLists.txt中添加了set(OpenCV_DIR xxxxx / opencv-3.4.5 / build)……但仍然是与下面相同的错误。
有人可以帮助我吗?首先谢谢你!
这是我的CMakeLists.txt:
let number = (Number(n) === n && n % 1 !== 0) ? eval(parseFloat(n).toFixed(3)) : n;
这是CMake的日志。似乎成功了。
cmake_minimum_required(VERSION 3.1)
# Enable C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
# Define project name
project(xxxx)
set(OpenCV_DIR xxxxx/opencv-3.4.5/build)
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS " config: ${OpenCV_DIR}")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
add_executable(xxxx xxxx.cpp)
target_link_libraries(xxxx ${OpenCV_LIBS})
但是使失败。日志如下:
(base) ➜ cmake .
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.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: XXXXX/opencv-3.4.5/build (found version "3.4.5")
-- OpenCV library status:
-- config: XXXXX/opencv-3.4.5/build
-- version: 3.4.5
-- libraries: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_shape;opencv_stitching;opencv_superres;opencv_video;opencv_videoio;opencv_videostab;opencv_aruco;opencv_bgsegm;opencv_bioinspired;opencv_ccalib;opencv_cvv;opencv_datasets;opencv_dnn_objdetect;opencv_dpm;opencv_face;opencv_freetype;opencv_fuzzy;opencv_hdf;opencv_hfs;opencv_img_hash;opencv_line_descriptor;opencv_optflow;opencv_phase_unwrapping;opencv_plot;opencv_reg;opencv_rgbd;opencv_saliency;opencv_stereo;opencv_structured_light;opencv_surface_matching;opencv_text;opencv_tracking;opencv_xfeatures2d;opencv_ximgproc;opencv_xobjdetect;opencv_xphoto
-- include path: XXXXX/opencv-3.4.5/build;XXXXX/opencv-3.4.5/include;XXXXX/opencv-3.4.5/include/opencv;XXXXX/opencv-3.4.5/modules/core/include;XXXXX/opencv-3.4.5/modules/flann/include;XXXXX/opencv_contrib-3.4.5/modules/hdf/include;XXXXX/opencv-3.4.5/modules/imgproc/include;XXXXX/opencv-3.4.5/modules/ml/include;XXXXX/opencv_contrib-3.4.5/modules/phase_unwrapping/include;XXXXX/opencv-3.4.5/modules/photo/include;XXXXX/opencv_contrib-3.4.5/modules/plot/include;XXXXX/opencv_contrib-3.4.5/modules/reg/include;XXXXX/opencv_contrib-3.4.5/modules/surface_matching/include;XXXXX/opencv-3.4.5/modules/video/include;XXXXX/opencv_contrib-3.4.5/modules/xphoto/include;XXXXX/opencv-3.4.5/modules/dnn/include;XXXXX/opencv_contrib-3.4.5/modules/freetype/include;XXXXX/opencv_contrib-3.4.5/modules/fuzzy/include;XXXXX/opencv_contrib-3.4.5/modules/hfs/include;XXXXX/opencv_contrib-3.4.5/modules/img_hash/include;XXXXX/opencv-3.4.5/modules/imgcodecs/include;XXXXX/opencv-3.4.5/modules/shape/include;XXXXX/opencv-3.4.5/modules/videoio/include;XXXXX/opencv-3.4.5/modules/highgui/include;XXXXX/opencv-3.4.5/modules/superres/include;XXXXX/opencv-3.4.5/modules/ts/include;XXXXX/opencv_contrib-3.4.5/modules/bioinspired/include;XXXXX/opencv_contrib-3.4.5/modules/dnn_objdetect/include;XXXXX/opencv-3.4.5/modules/features2d/include;XXXXX/opencv_contrib-3.4.5/modules/line_descriptor/include;XXXXX/opencv_contrib-3.4.5/modules/saliency/include;XXXXX/opencv_contrib-3.4.5/modules/text/include;XXXXX/opencv-3.4.5/modules/calib3d/include;XXXXX/opencv_contrib-3.4.5/modules/ccalib/include;XXXXX/opencv_contrib-3.4.5/modules/cvv/include;XXXXX/opencv_contrib-3.4.5/modules/datasets/include;XXXXX/opencv-3.4.5/modules/objdetect/include;XXXXX/opencv_contrib-3.4.5/modules/rgbd/include;XXXXX/opencv_contrib-3.4.5/modules/stereo/include;XXXXX/opencv_contrib-3.4.5/modules/structured_light/include;XXXXX/opencv_contrib-3.4.5/modules/tracking/include;XXXXX/opencv-3.4.5/modules/videostab/include;XXXXX/opencv_contrib-3.4.5/modules/xfeatures2d/include;XXXXX/opencv_contrib-3.4.5/modules/ximgproc/include;XXXXX/opencv_contrib-3.4.5/modules/xobjdetect/include;XXXXX/opencv_contrib-3.4.5/modules/aruco/include;XXXXX/opencv_contrib-3.4.5/modules/bgsegm/include;XXXXX/opencv_contrib-3.4.5/modules/dpm/include;XXXXX/opencv_contrib-3.4.5/modules/face/include;XXXXX/opencv_contrib-3.4.5/modules/optflow/include;XXXXX/opencv-3.4.5/modules/stitching/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/Documents/pyproject/ocr/XXXXX
======================添加编辑======================= ====
cmake之后,build / lib中没有任何内容...
(base) ➜ make
-- OpenCV library status:
-- config: XXXXX/opencv-3.4.5/build
-- version: 3.4.5
-- libraries: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_shape;opencv_stitching;opencv_superres;opencv_video;opencv_videoio;opencv_videostab;opencv_aruco;opencv_bgsegm;opencv_bioinspired;opencv_ccalib;opencv_cvv;opencv_datasets;opencv_dnn_objdetect;opencv_dpm;opencv_face;opencv_freetype;opencv_fuzzy;opencv_hdf;opencv_hfs;opencv_img_hash;opencv_line_descriptor;opencv_optflow;opencv_phase_unwrapping;opencv_plot;opencv_reg;opencv_rgbd;opencv_saliency;opencv_stereo;opencv_structured_light;opencv_surface_matching;opencv_text;opencv_tracking;opencv_xfeatures2d;opencv_ximgproc;opencv_xobjdetect;opencv_xphoto
-- include path: XXXXX/opencv-3.4.5/build;XXXXX/opencv-3.4.5/include;XXXXX/opencv-3.4.5/include/opencv;XXXXX/opencv-3.4.5/modules/core/include;XXXXX/opencv-3.4.5/modules/flann/include;XXXXX/opencv_contrib-3.4.5/modules/hdf/include;XXXXX/opencv-3.4.5/modules/imgproc/include;XXXXX/opencv-3.4.5/modules/ml/include;XXXXX/opencv_contrib-3.4.5/modules/phase_unwrapping/include;XXXXX/opencv-3.4.5/modules/photo/include;XXXXX/opencv_contrib-3.4.5/modules/plot/include;XXXXX/opencv_contrib-3.4.5/modules/reg/include;XXXXX/opencv_contrib-3.4.5/modules/surface_matching/include;XXXXX/opencv-3.4.5/modules/video/include;XXXXX/opencv_contrib-3.4.5/modules/xphoto/include;XXXXX/opencv-3.4.5/modules/dnn/include;XXXXX/opencv_contrib-3.4.5/modules/freetype/include;XXXXX/opencv_contrib-3.4.5/modules/fuzzy/include;XXXXX/opencv_contrib-3.4.5/modules/hfs/include;XXXXX/opencv_contrib-3.4.5/modules/img_hash/include;XXXXX/opencv-3.4.5/modules/imgcodecs/include;XXXXX/opencv-3.4.5/modules/shape/include;XXXXX/opencv-3.4.5/modules/videoio/include;XXXXX/opencv-3.4.5/modules/highgui/include;XXXXX/opencv-3.4.5/modules/superres/include;XXXXX/opencv-3.4.5/modules/ts/include;XXXXX/opencv_contrib-3.4.5/modules/bioinspired/include;XXXXX/opencv_contrib-3.4.5/modules/dnn_objdetect/include;XXXXX/opencv-3.4.5/modules/features2d/include;XXXXX/opencv_contrib-3.4.5/modules/line_descriptor/include;XXXXX/opencv_contrib-3.4.5/modules/saliency/include;XXXXX/opencv_contrib-3.4.5/modules/text/include;XXXXX/opencv-3.4.5/modules/calib3d/include;XXXXX/opencv_contrib-3.4.5/modules/ccalib/include;XXXXX/opencv_contrib-3.4.5/modules/cvv/include;XXXXX/opencv_contrib-3.4.5/modules/datasets/include;XXXXX/opencv-3.4.5/modules/objdetect/include;XXXXX/opencv_contrib-3.4.5/modules/rgbd/include;XXXXX/opencv_contrib-3.4.5/modules/stereo/include;XXXXX/opencv_contrib-3.4.5/modules/structured_light/include;XXXXX/opencv_contrib-3.4.5/modules/tracking/include;XXXXX/opencv-3.4.5/modules/videostab/include;XXXXX/opencv_contrib-3.4.5/modules/xfeatures2d/include;XXXXX/opencv_contrib-3.4.5/modules/ximgproc/include;XXXXX/opencv_contrib-3.4.5/modules/xobjdetect/include;XXXXX/opencv_contrib-3.4.5/modules/aruco/include;XXXXX/opencv_contrib-3.4.5/modules/bgsegm/include;XXXXX/opencv_contrib-3.4.5/modules/dpm/include;XXXXX/opencv_contrib-3.4.5/modules/face/include;XXXXX/opencv_contrib-3.4.5/modules/optflow/include;XXXXX/opencv-3.4.5/modules/stitching/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/Documents/pyproject/ocr/XXXXX
Scanning dependencies of target XXXXX
[ 50%] Building CXX object CMakeFiles/XXXXX.dir/XXXXX.cpp.o
make[2]: *** No rule to make target 'XXXXX/opencv-3.4.5/build/lib/libopencv_stitching.so.3.4.5', needed by 'XXXXX'. Stop.
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/XXXXX.dir/all' failed
make[1]: *** [CMakeFiles/XXXXX.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
这是如下的opencv cmake cmd:
======================添加编辑======================= ====
(base) ➜ build cd lib
(base) ➜ lib ll
total 0
(base) ➜ lib pwd
/home/user/Documents/software/opencv-3.4.5/build/lib
(base) ➜ lib
......
(base) ➜ build ll
total 1.7M
drwxrwxrwx 11 root root 4.0K Feb 22 04:41 3rdparty
drwxrwxrwx 9 root root 4.0K Feb 22 04:41 apps
drwxrwxrwx 2 root root 4.0K Feb 22 04:41 bin
-rwxrwxrwx 1 root root 432K Feb 22 04:41 CMakeCache.txt
-rwxrwxrwx 1 root root 58K Feb 22 04:41 CMakeDownloadLog.txt
drwxrwxrwx 17 root root 4.0K Feb 22 04:41 CMakeFiles
-rwxrwxrwx 1 root root 7.8K Feb 22 04:41 cmake_install.cmake
-rwxrwxrwx 1 root root 1.2K Feb 22 04:39 cmake_uninstall.cmake
-rwxrwxrwx 1 root root 449K Feb 22 04:41 CMakeVars.txt
drwxrwxrwx 3 root root 4.0K Feb 22 04:39 configured
-rwxrwxrwx 1 root root 9.6K Feb 22 04:41 CPackConfig.cmake
-rwxrwxrwx 1 root root 10K Feb 22 04:41 CPackSourceConfig.cmake
-rwxrwxrwx 1 root root 604 Feb 22 04:41 CTestTestfile.cmake
-rwxrwxrwx 1 root root 70 Feb 22 04:39 custom_hal.hpp
-rwxrwxrwx 1 root root 5.1K Feb 22 04:41 cvconfig.h
-rwxrwxrwx 1 root root 796 Feb 22 04:41 cv_cpu_config.h
drwxrwxrwx 3 root root 4.0K Feb 22 04:41 data
drwxrwxrwx 3 root root 4.0K Feb 22 04:41 doc
drwxrwxrwx 3 root root 4.0K Feb 22 04:39 downloads
drwxrwxrwx 3 root root 4.0K Feb 22 04:41 include
drwxrwxrwx 2 root root 4.0K Feb 22 04:41 lib
-rwxrwxrwx 1 root root 438K Feb 22 04:41 Makefile
drwxrwxrwx 54 root root 4.0K Feb 22 04:41 modules
drwxrwxrwx 2 root root 4.0K Feb 22 04:41 opencv2
-rwxrwxrwx 1 root root 18K Feb 22 04:41 OpenCVConfig.cmake
-rwxrwxrwx 1 root root 418 Feb 22 04:41 OpenCVConfig-version.cmake
-rwxrwxrwx 1 root root 332 Feb 22 04:39 opencv_data_config.hpp
-rwxrwxrwx 1 root root 6.8K Feb 22 04:41 OpenCVGenPkgConfig.info.cmake
-rwxrwxrwx 1 root root 31K Feb 22 04:41 OpenCVModules.cmake
-rwxrwxrwx 1 root root 2.7K Feb 22 04:41 opencv_python_config.cmake
-rwxrwxrwx 1 root root 152 Feb 22 04:39 opencv_tests_config.hpp
-rwxrwxrwx 1 root root 46K Feb 22 04:41 pylint.cmake
drwxrwxrwx 3 root root 4.0K Feb 22 04:39 python_loader
drwxrwxrwx 10 root root 4.0K Feb 22 04:41 samples
-rwxrwxrwx 1 root root 650 Feb 22 04:41 setup_vars.sh
drwxrwxrwx 3 root root 4.0K Feb 22 04:39 share
drwxrwxrwx 5 root root 4.0K Feb 22 04:39 test-reports
-rwxrwxrwx 1 root root 124 Feb 22 04:39 text_config.hpp
drwxrwxrwx 2 root root 4.0K Feb 22 04:41 tmp
drwxrwxrwx 2 root root 4.0K Feb 22 04:41 unix-install
-rwxrwxrwx 1 root root 7.8K Feb 22 04:41 version_string.tmp
答案 0 :(得分:0)
不太确定,但是您是否尝试更改
$this->container->view->getEnvironment()->addGlobal('old', $_SESSION['old']);
$_SESSION['old'] = $request->getParams();
应该不是
set(OpenCV_DIR xxxxx/opencv-3.4.5/build)
或者只是尝试预先构建opencv,然后将其链接到您的可执行文件。
EDIT1:
来自opencv_root_dir / build
set(OpenCV_DIR xxxxx/opencv-3.4.5/)
然后
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
# use 3 cores to compile
make -j3
添加到您的cmake文件中:
# will install it to /usr/local )
sudo make install
还没有测试它,但是它对我的项目很有帮助。 好处是您不必每次都重建所有的opencv文件。 我也使用* .so文件进行链接。 * .a不适用于我,但您可以自己尝试。