只是想迅速计算个光流图片,结果搞了大半天都没装好。
工具:
https://github.com/feichtenhofer/gpu_flow
首先确认依赖是否都装好:
[OpenCV 2.4] (http://opencv.org/downloads.html)
确认版本:pkg-config --modversion opencv
[Qt 5.4] (https://www.qt.io/qt5-4/)
确认版本:qmake -v
[cmake] (https://cmake.org/)
然后开始吧:
- git clone --recursive https://github.com/feichtenhofer/gpu_flow
- cd gpu_flow
- mkdir build
- cd build
- cmake -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF ..
- make
cannot find lopencv_dep_cudarthttps://github.com/opencv/opencv/issues/6542
在CMakeLists.txt中:FIND_PACKAGE(OpenCV REQUIRED )之前添加:
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
参考链接:
http://www.cnblogs.com/darkknightzh/p/5638117.html
http://blog.csdn.net/qq_36130482/article/details/70171301
http://blog.csdn.net/u012526003/article/details/64500596
修改后的CMakeLists.txt:
- # OpenCV Config
- set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
- find_package( OpenCV REQUIRED )
- message(STATUS " version: ${OpenCV_VERSION}")
- message("-- OPENCV include: " ${OpenCV_INCLUDE_DIRS})
- message("-- OPENCV libs dir: " ${OpenCV_LIB_DIR})
- message("-- OPENCV libs: " ${OpenCV_LIBS} )
试了几次还是不行,于是
- rm build -rf
- mkdir build && cd build
- cmake ..
- make
还是不行。
于是:https://github.com/caffe2/caffe2/issues/303
- rm -rf build
- mkdir build && cd build
- cmake -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF ..
- make
可以了!感人。
``lib/libstdc++.so.6: version GLIBCXX_3.4.20 not found (required by /usr/local/lib/libopencv_gpu.so.2.4)http://blog.csdn.net/xiaolong2w/article/details/23915171
我的libstdc++.so.6是anaconda3里面的,用strings libstdc++.so.6查看了一下(忘了存结果):
只到3.4.19。
所以我升级了一下我的conda和所有的库:
- conda update conda #更新conda本身
- conda update --all #更新所有库,有点慢
现在:
- root@Amax-02:~/anaconda3$ strings /home/root/anaconda3/lib/libstdc++.so.6 | grep GLIBCXX
- GLIBCXX_DEBUG_MESSAGE_LENGTH
- GLIBCXX_3.4
- GLIBCXX_3.4.1
- GLIBCXX_3.4.2
- GLIBCXX_3.4.3
- GLIBCXX_3.4.4
- GLIBCXX_3.4.5
- GLIBCXX_3.4.6
- GLIBCXX_3.4.7
- GLIBCXX_3.4.8
- GLIBCXX_3.4.9
- GLIBCXX_3.4.10
- GLIBCXX_3.4.11
- GLIBCXX_3.4.12
- GLIBCXX_3.4.13
- GLIBCXX_3.4.14
- GLIBCXX_3.4.15
- GLIBCXX_3.4.16
- GLIBCXX_3.4.17
- GLIBCXX_3.4.18
- GLIBCXX_3.4.19
- GLIBCXX_3.4.20
- GLIBCXX_3.4.21
可以啦~
其他的在作者的README.md都写的很清楚啦:
You should adjust the input and output directories by editing the variables vid_path, out_path and out_path_jpeg in compute_flow.cpp. Note that these folders have to exist before executing.
./brox_flow [OPTION]...
Available options:
* start_video: start with video number in vid_path directory structure [1]
* gpuID: use this GPU ID [0]
* type: use this flow method Brox = 0, TVL1 = 1 [1]
* skip: the number of frames that are skipped between flow calcuation [1]
Additional features in compute_flow.cpp:
* float MIN_SZ = 256: defines the smallest side of the frame for optical flow computation
* float OUT_SZ = 256: defines the smallest side of the frame for saving as .jpeg
* bool clipFlow = true;: defines whether to clip the optical flow larger than [-20 20] pixels and maps the interval [-20 20] to [0 255] in grayscale image space. If no clipping is performed the mapping to the image space is achieved by finding the frame-wise minimum and maximum displacement and mapping to [0 255] via an adaptive scaling, where the scale factors are saved as a binary file to out_path.
./brox_flow gpuID=0 type=1