open-mmlab / mmaction

An open-source toolbox for action understanding based on PyTorch
https://open-mmlab.github.io/
Apache License 2.0
1.86k stars 352 forks source link

denseflow compile problem #9

Closed aaab8b closed 5 years ago

aaab8b commented 5 years ago

it seeems like denseflow needs to be compiled with OpenCV 2.4.13 and CUDA. However this version of OpenCV does not match with CUDA9.0+... And I can't compile OpenCV successfully. Is there any solution? This is a CentOS 7.6, cmake 3.15.0, gcc 6.5.0, Titan X.

zhaoyue-zephyrus commented 5 years ago

Hi @aaab8b

After several workaround, dense_flow is now supporting the latest OpenCV 4.1.0 (https://github.com/yjxiong/dense_flow/pull/4)! Detailed steps are as follows. Note that these steps are tested on a machine with Ubuntu 18.04 + CUDA 9.2/10.0. Please report if you encounter any further problem.

  1. (For CUDA 10.0 only) CUDA 9.x should have no problem. Video decoder is deprecated in CUDA 10.0. To handle this, download NVIDIA VIDEO CODEC SDK and copy the header files to your cuda path (/usr/local/cuda-10.0/include/ for example). Note that you may have to do as root.
unzip Video_Codec_SDK_9.0.20.zip
cp Video_Codec_SDK_9.0.20/include/nvcuvid.h /usr/local/cuda-10.0/include/
cp Video_Codec_SDK_9.0.20/include/cuviddec.h /usr/local/cuda-10.0/include/
  1. Install OpenCV 4.1.0 Note that I didn't come across any other prerequisites for installation. If any, please kindly remind me to add in the comment.

(a) Obtain the OpenCV 4.1.0 and its extra modules (optflow. etc.) by

# assume you are now in the directory of /PATH/TO/MMACTION/third_party/
wget -O OpenCV-4.1.0.zip wget https://github.com/opencv/opencv/archive/4.1.0.zip 
unzip OpenCV-4.1.0.zip
wget -O OpenCV_contrib-4.1.0.zip https://github.com/opencv/opencv_contrib/archive/4.1.0.zip
unzip OpenCV_contrib-4.1.0.zip

(b) Install OpenCV 4.1.0 by

cd opencv-4.1.0
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DWITH_CUDA=ON -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.0/modules/ -DWITH_TBB=ON -DBUILD_opencv_cnn_3dobj=OFF -DBUILD_opencv_dnn=OFF -DBUILD_opencv_dnn_modern=OFF -DBUILD_opencv_dnns_easily_fooled=OFF ..
make -j

Note that remember to explicitly setting -DOPENCV_ENABLE_NONFREE=ON if you want to enable warped_flow (warped flow is proposed in TSN).

  1. Install dense_flow
cd ../../dense_flow
# git checkout opencv-4.1.0
# don't need switch to the branch for opencv-4.1.0
# it has been merged to master branch (Fix on 27/06/2019)
mkdir build && cd build
OpenCV_DIR=../../opencv-4.1.0/build/  cmake ..
make -j

where OpenCV_DIR specifies the OpenCV that we are using, which will be helpful if there are various opencvs on your machine.

Here the structure looks like

├── third_party
│   ├── decord
│   ├── opencv-4.1.0
│   ├── opencv_contrib-4.1.0
│   ├── dense_flow
zhangluustb commented 5 years ago

@zhaoyue-zephyrus git checkout opencv-4.1.0 #the branch is invalid now. use the master branch,get the error: fatal error: opencv2/xfeatures2d.hpp: No such file or directory

include "opencv2/xfeatures2d.hpp"

      ^~~~~~~~~~~~~~~~~~~~~~~~~

But my opencv is installed. . ├── decord │   ├── 3rdparty │   ├── cmake │   ├── CMakeLists.txt │   ├── docs │   ├── examples │   ├── include │   ├── LICENSE │   ├── python │   ├── README.md │   ├── src │   ├── tests │   └── tools ├── dense_flow │   ├── build │   ├── build_of.py │   ├── cmake │   ├── CMakeCache.txt │   ├── CMakeFiles │   ├── cmake_install.cmake │   ├── CMakeLists.txt │   ├── include │   ├── LICENSE │   ├── Makefile │   ├── matlab │   ├── README.md │   ├── src │   └── tools ├── libzip-1.5.2 │   ├── API-CHANGES.md │   ├── appveyor.yml │   ├── AUTHORS │   ├── build │   ├── cmake-config.h.in │   ├── CMakeLists.txt │   ├── cmake-zipconf.h.in │   ├── examples │   ├── FindNettle.cmake │   ├── INSTALL.md │   ├── lib │   ├── libzip.pc.in │   ├── LICENSE │   ├── man │   ├── NEWS.md │   ├── README.md │   ├── regress │   ├── src │   ├── THANKS │   └── TODO.md ├── opencv-4.1.0 │   ├── 3rdparty │   ├── apps │   ├── build │   ├── cmake │   ├── CMakeLists.txt │   ├── CONTRIBUTING.md │   ├── data │   ├── doc │   ├── include │   ├── LICENSE │   ├── modules │   ├── platforms │   ├── README.md │   └── samples └── opencv_contrib-4.1.0 ├── CONTRIBUTING.md ├── doc ├── LICENSE ├── modules ├── README.md └── samples

zhaoyue-zephyrus commented 5 years ago

Hi @zhangluustb

May I know your command for installing opencv? Seems that xfeatures2d is not installed properly. Make sure that your are installing with open_contrib by specifying -DOPENCV_EXTRA_MODULES_PATH=....

zhangluustb commented 5 years ago

@zhaoyue-zephyrus thank you for your reply,this error caused by that i have two versions of opencv,I fixed this error by modify the findPackge of opencv. But anothor error occur:

 ./extract_gpu -f=/home/zhanglu/Desktop/mmaction/data/ucf101/videos/Biking/v_Biking_g04_c03.avi -x=tmp/flow_x -y=tmp/flow_y -i=tmp/image -b=20 -t=1 -d=0 -s=1 -o=dir
2019-06-27 18:30:41,145 FATAL [default] CRASH HANDLED; Application has crashed due to [SIGSEGV] signal
2019-06-27 18:30:41,145 WARN  [default] Aborting application. Reason: Fatal log at [/home/zhanglu/Desktop/mmaction/third_party/dense_flow/include/easylogging++/src/easylogging++.h:5583]
Aborted (core dumped)

System:Ubuntu 18.04 nvcc:10.0 opencv-4.1.0

zhaoyue-zephyrus commented 5 years ago

@zhangluustb Good to hear that :)

As of the new error, it arises probably because you don't have sub-directory named tmp/ while trying to save images and optical flows to tmp/. The c++ interface of dense_flow cannot create new directory automatically. I will add this in the new README.

zhangluustb commented 5 years ago

@zhaoyue-zephyrus

./extract_warp_gpu -f test.avi -x tmp/flow_x -y tmp/flow_y -i tmp/image -b 20 -t 1 -d 0 -s 1 -o dir
2019-06-27 19:19:43,986 FATAL [default] Check failed: [video_stream.isOpened()] Cannot open video stream "true" for optical flow extraction.
2019-06-27 19:19:43,986 WARN  [default] Aborting application. Reason: Fatal log at [/home/zhanglu/Desktop/mmaction/third_party/dense_flow/src/dense_warp_flow_gpu.cpp:30]
Aborted (core dumped)

It's so wired.help me

zhaoyue-zephyrus commented 5 years ago

@zhangluustb Don't panic. Could you try the following script?

mkdir tmp/
./extract_warp_gpu -f=test.avi -x=tmp/flow_x -y=tmp/flow_y -i=tmp/image -b=20 -t=1 -d=0 -s=1 -o dir

Also, note that you have to build opencv-4.1.0 with -DOPENCV_ENABLE_NONFREE=ON.

aaab8b commented 5 years ago

i still can't make dense_flow correctly... I successfully installed opencv-4.1.0 with your guide, However, when i make dense_flow, it comes to some errors:

/data/bingzd/mmaction/third_party/dense_flow/include/common.h:23:20: 错误:‘vector’未声明 vector& encoded_x, vector& encoded_y, ^ /data/bingzd/mmaction/third_party/dense_flow/include/common.h:23:26: 错误:expected ‘,’ or ‘...’ before ‘<’ token vector& encoded_x, vector& encoded_y, ^ /data/bingzd/mmaction/third_party/dense_flow/include/common.h:36:18: 错误:变量或字段‘writeImages’声明为 void void writeImages(vector<vector> images, string name_temp); ^ /data/bingzd/mmaction/third_party/dense_flow/include/common.h:36:18: 错误:‘vector’在此作用域中尚未声明 /data/bingzd/mmaction/third_party/dense_flow/include/common.h:36:18: 附注:建议的替代: In file included from /usr/include/c++/4.8.2/vector:64:0, from /usr/include/c++/4.8.2/bits/random.h:34, from /usr/include/c++/4.8.2/random:50, from /usr/include/c++/4.8.2/bits/stl_algo.h:65, from /usr/include/c++/4.8.2/algorithm:62, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/core/base.hpp:55, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/core.hpp:54, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/video/tracking.hpp:47, from /data/bingzd/mmaction/third_party/dense_flow/include/common.h:10, from /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:5: /usr/include/c++/4.8.2/bits/stl_vector.h:210:11: 附注: ‘std::vector’ class vector : protected _Vector_base<_Tp, _Alloc> ^ In file included from /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:5:0: /data/bingzd/mmaction/third_party/dense_flow/include/common.h:36:25: 错误:‘vector’在此作用域中尚未声明 void writeImages(vector<vector> images, string name_temp); ^ /data/bingzd/mmaction/third_party/dense_flow/include/common.h:36:25: 附注:建议的替代: In file included from /usr/include/c++/4.8.2/vector:64:0, from /usr/include/c++/4.8.2/bits/random.h:34, from /usr/include/c++/4.8.2/random:50, from /usr/include/c++/4.8.2/bits/stl_algo.h:65, from /usr/include/c++/4.8.2/algorithm:62, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/core/base.hpp:55, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/core.hpp:54, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/video/tracking.hpp:47, from /data/bingzd/mmaction/third_party/dense_flow/include/common.h:10, from /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:5: /usr/include/c++/4.8.2/bits/stl_vector.h:210:11: 附注: ‘std::vector’ class vector : protected _Vector_base<_Tp, _Alloc> ^ In file included from /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:5:0: /data/bingzd/mmaction/third_party/dense_flow/include/common.h:36:37: 错误:expected primary-expression before ‘>>’ token void writeImages(vector<vector> images, string name_temp); ^ /data/bingzd/mmaction/third_party/dense_flow/include/common.h:36:40: 错误:‘images’在此作用域中尚未声明 void writeImages(vector<vector> images, string name_temp); ^ /data/bingzd/mmaction/third_party/dense_flow/include/common.h:36:48: 错误:‘string’在此作用域中尚未声明 void writeImages(vector<vector> images, string name_temp); ^ /data/bingzd/mmaction/third_party/dense_flow/include/common.h:36:48: 附注:建议的替代: In file included from /usr/include/c++/4.8.2/string:39:0, from /usr/include/c++/4.8.2/stdexcept:39, from /usr/include/c++/4.8.2/array:38, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/core/cvdef.h:671, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/core.hpp:52, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/video/tracking.hpp:47, from /data/bingzd/mmaction/third_party/dense_flow/include/common.h:10, from /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:5: /usr/include/c++/4.8.2/bits/stringfwd.h:62:33: 附注: ‘std::string’ typedef basic_string string; ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:33:20: 错误:‘vector’未声明 vector& encoded_x, vector& encoded_y, ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:33:26: 错误:expected ‘,’ or ‘...’ before ‘<’ token vector& encoded_x, vector& encoded_y, ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp: 在函数‘void encodeFlowMap(const cv::Mat&, const cv::Mat&, int)’中: /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:39:25: 错误:‘bound’在此作用域中尚未声明 -bound, bound); ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:41:9: 错误:‘to_jpg’在此作用域中尚未声明 if (to_jpg) { ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:42:38: 错误:‘encoded_x’在此作用域中尚未声明 imencode(".jpg", flow_img_x, encoded_x); ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:43:38: 错误:‘encoded_y’在此作用域中尚未声明 imencode(".jpg", flow_img_y, encoded_y); ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:45:9: 错误:‘encoded_x’在此作用域中尚未声明 encoded_x.resize(flow_img_x.total()); ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:46:9: 错误:‘encoded_y’在此作用域中尚未声明 encoded_y.resize(flow_img_y.total()); ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp: 在全局域: /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:52:18: 错误:变量或字段‘writeImages’声明为 void void writeImages(vector<vector> images, string name_temp){ ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:52:18: 错误:‘vector’在此作用域中尚未声明 /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:52:18: 附注:建议的替代: In file included from /usr/include/c++/4.8.2/vector:64:0, from /usr/include/c++/4.8.2/bits/random.h:34, from /usr/include/c++/4.8.2/random:50, from /usr/include/c++/4.8.2/bits/stl_algo.h:65, from /usr/include/c++/4.8.2/algorithm:62, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/core/base.hpp:55, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/core.hpp:54, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/video/tracking.hpp:47, from /data/bingzd/mmaction/third_party/dense_flow/include/common.h:10, from /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:5: /usr/include/c++/4.8.2/bits/stl_vector.h:210:11: 附注: ‘std::vector’ class vector : protected _Vector_base<_Tp, _Alloc> ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:52:37: 错误:expected primary-expression before ‘>>’ token void writeImages(vector<vector> images, string name_temp){ ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:52:40: 错误:‘images’在此作用域中尚未声明 void writeImages(vector<vector> images, string name_temp){ ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:52:48: 错误:‘string’在此作用域中尚未声明 void writeImages(vector<vector> images, string name_temp){ ^ /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:52:48: 附注:建议的替代: In file included from /usr/include/c++/4.8.2/string:39:0, from /usr/include/c++/4.8.2/stdexcept:39, from /usr/include/c++/4.8.2/array:38, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/core/cvdef.h:671, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/core.hpp:52, from /home/bingzd/opencv-4.1/include/opencv4/opencv2/video/tracking.hpp:47, from /data/bingzd/mmaction/third_party/dense_flow/include/common.h:10, from /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:5: /usr/include/c++/4.8.2/bits/stringfwd.h:62:33: 附注: ‘std::string’ typedef basic_string string; ^ make[2]: [CMakeFiles/denseflow.dir/src/common.cpp.o] 错误 1 make[1]: [CMakeFiles/denseflow.dir/all] 错误 2 make: *** [all] 错误 2

my environment is CentOS 7.6, CUDA 9.0 gcc-5.4.0,Titan X.

aaab8b commented 5 years ago

@zhaoyue-zephyrus is my opencv environment variables setting not correct? Since I don't have the root permission so i install opencv with -DCMAKE_INSTALL_PREFIX to another location instead of the default location. Then how should i set the enviroment variables... And thank you so much for your help...

zhangluustb commented 5 years ago

@zhangluustb Don't panic. Could you try the following script?

mkdir tmp/
./extract_warp_gpu -f=test.avi -x=tmp/flow_x -y=tmp/flow_y -i=tmp/image -b=20 -t=1 -d=0 -s=1 -o dir

Also, note that you have to build opencv-4.1.0 with -DOPENCV_ENABLE_NONFREE=ON.

It works,Thanks for u help.

zhaoyue-zephyrus commented 5 years ago

@aaab8b

Seems that you are actually using gcc-4.8.2 instead of gcc-5.4.0 as you claimed? Please check.

To specify the opencv path, do OpenCV_DIR=/PATH/TO/YOUR/OPENCV4/build cmake ... Remember to remove the cmake cache or more simply rm build/ before re-installing.

aaab8b commented 5 years ago

@zhaoyue-zephyrus thank you for your help, and i rechecked my gcc, re-make the opencv and do the dense flow cmake with your command.however it still get some errors like this...

In file included from /data/bingzd/mmaction/third_party/opencv-4.1.0/modules/core/include/opencv2/core.hpp:3288:0, [1879/1879] from /data/bingzd/mmaction/third_party/opencv-4.1.0/modules/video/include/opencv2/video/tracking.hpp:47, from /data/bingzd/mmaction/third_party/dense_flow/include/common.h:10, from /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:5: /data/bingzd/mmaction/third_party/opencv-4.1.0/modules/core/include/opencv2/core/operations.hpp:426:12: 错误:‘String’不是一个类型名 CV_EXPORTS String format( const char fmt, ... ) CV_FORMAT_PRINTF(1, 2); ^ In file included from /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/ios_base.h:41:0, from /home/bingzd/GCC-5.4.0/include/c++/5.4.0/ios:42, from /home/bingzd/GCC-5.4.0/include/c++/5.4.0/istream:38, from /home/bingzd/GCC-5.4.0/include/c++/5.4.0/sstream:38, from /home/bingzd/GCC-5.4.0/include/c++/5.4.0/complex:45, from /data/bingzd/mmaction/third_party/opencv-4.1.0/modules/core/include/opencv2/core/cvstd.inl.hpp:47, from /data/bingzd/mmaction/third_party/opencv-4.1.0/modules/core/include/opencv2/core.hpp:3289, from /data/bingzd/mmaction/third_party/opencv-4.1.0/modules/video/include/opencv2/video/tracking.hpp:47, from /data/bingzd/mmaction/third_party/dense_flow/include/common.h:10, from /data/bingzd/mmaction/third_party/dense_flow/src/common.cpp:5: /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h:163:18: 错误:‘string’不是命名空间‘std’中的一个类型名 locale(const std::string& s) : locale(s.c_str()) { } ^ /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h:177:40: 错误:‘string’不是命名空间‘std’中的一个类型名 locale(const locale& base, const std::string& s, category cat) ^ /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h:243:5: 错误:‘_GLIBCXX_DEFAULT_ABI_TAG’不是一个类型名 _GLIBCXX_DEFAULT_ABI_TAG ^ /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h: 在构造函数‘std::locale::locale(const int&)’中: /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h:163:49: 错误:对成员‘c_str’的请求出现在‘s’中,而后者具有非类类型‘const int’ locale(const std::string& s) : locale(s.c_str()) { } ^ /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h: 在构造函数‘std::locale::locale(const std::locale&, const int&, std::locale::category)’中: /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h:178:26: 错误:对成员‘c_str’的请求出现在‘s’中,而后者具有非类类型‘const int’ : locale(base, __s.c_str(), __cat) { } ^ /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h: 在全局域: /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h:633:44: 错误:expected initializer before ‘:’ token class _GLIBCXX_NAMESPACE_CXX11 collate : public locale::facet ^ /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h:784:23: 错误:expected initializer before ‘<’ token locale::id collate<_CharT>::id; ^ /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h:789:12: 错误:expected initializer before ‘<’ token collate::_M_compare(const char, const char) const throw(); ^ /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h:793:12: 错误:expected initializer before ‘<’ token collate::_M_transform(char, const char, size_t) const throw(); ^ /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h:798:12: 错误:expected initializer before ‘<’ token collate::_M_compare(const wchar_t, const wchar_t) const throw(); ^ /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h:802:12: 错误:expected initializer before ‘<’ token collate::_M_transform(wchar_t, const wchar_t*, size_t) const throw(); ^ /home/bingzd/GCC-5.4.0/include/c++/5.4.0/bits/locale_classes.h:807:51: 错误:expected initializer before ‘:’ token

acrophile commented 5 years ago

dense_flow downloaded with mmaction by the following command git clone --recursive https://github.com/open-mmlab/mmaction.git seems not to be the correct branch for OpenCV 4.1.0 (maybe for OpenCV 2.4.13?) and result in compile errors with no opencv2/gpu/gpu.hpp.

When I clone directly the dense_flow repository by the following command, compilation succeeded. git clone --recursive http://github.com/yjxiong/dense_flow

I would appreciate if the issue would be fixed. Thank you for publishing the fascinating framework.

zhaoyue-zephyrus commented 5 years ago

dense_flow downloaded with mmaction by the following command git clone --recursive https://github.com/open-mmlab/mmaction.git seems not to be the correct branch for OpenCV 4.1.0 (maybe for OpenCV 2.4.13?) and result in compile errors with no opencv2/gpu/gpu.hpp.

When I clone directly the dense_flow repository by the following command, compilation succeeded. git clone --recursive http://github.com/yjxiong/dense_flow

I would appreciate if the issue would be fixed. Thank you for publishing the fascinating framework.

@acrophile Thanks for pointing out this issue. This is because I was then waiting for Yuanjun to merge my PRs. Now the submodule has been updated with the master branch. You might check as well.

zhaoyue-zephyrus commented 5 years ago

Hi @aaab8b

Sorry I don't have any CentOS system to exactly reproduce this issue. Are you having the latest denseflow? Several changes have been made to support opencv-4.1 and please check the commits. It could be that you are still having the master branch originally for opencv-2.4

aaab8b commented 5 years ago

@zhaoyue-zephyrus Thanks a lot... I changed it to the latest denseflow and it worked just fine.

rishabh2301 commented 5 years ago

Hi @zhaoyue-zephyrus I am trying to use denseflow for extracting optical flow for my own data. I have successfully build opencv 4.1.0 with cuda 9.2 and have build the denseflow repo also. However when I run the command mkdir tmp/ ./extract_warp_gpu -f=test.avi -x=tmp/flow_x -y=tmp/flow_y -i=tmp/image -b=20 -t=1 -d=0 -s=1 -o dir from the build directory of denseflow it is just processing for a long time (without any output) and on nvidia-smi the process is also utilizing the GPU however there is nothing getting downloaded in the tmp folder nor any logs in the myeasylog.log. I am also not sure if in -f parser command I can pass the path to the video or the video needs to be present in the build directory of denseflow itself, also my videos are in .mp4 format is it necessary for them to be in .avi?

This is the output after building denseflow.

Screenshot from 2019-07-03 13-28-48

Can you please help me with this, I have been following this issue since a long while. Thank you very much.

rishabh2301 commented 5 years ago

Hi @zhaoyue-zephyrus I got the output downloaded to the tmp folder. But is the code very slow with the GPU as well? I was previously trying to extract with CPU and since the tvl1 algorithm was taking lot of time, I decided to use denseflow repo for the GPU support.

rahman-mdatiqur commented 5 years ago

Hello @rishabh2301 ,

I also noticed the same. I had a clip having 1482 frames, and it took really long time to extract the optical flow (type=tvl1). I used the python script build_rawframes.py in data_tools directory. Though it was using gpu, but it seemed that only a small amount of memory was being used by the process even though I had two gpus each with lot of memory left.

rishabh2301 commented 5 years ago

Hi @atique81 , yes it is taking time with GPU as well. The only thing that can be done is increasing the number of workers in the script build_rawframes.py for multiprocessing according to the architecture of your system. I am also facing the same issue as you.

YuLengChuanJiang commented 4 years ago

@zhaoyue-zephyrus Hello, I do as described, but I get an error as follows: VIDIOC_REQBUFS: Inappropriate ioctl for device 2019-12-13 21:45:16,650 FATAL [default] Check failed: [video_stream.isOpened()] Cannot open video stream "test.avi" for optical flow extraction. 2019-12-13 21:45:16,650 WARN [default] Aborting application. Reason: Fatal log at [/home/l/dense_flow/src/dense_flow_gpu.cpp:19]

Can you give me some suggestions to solve it? Thanks.

dmRuan commented 4 years ago

Hi @zhaoyue-zephyrus , I followed your instruction to set up the dense_flow. But when I make -j the dense_flow, I got the following error.

/mmaction/third_party/dense_flow/src/dense_flow.cpp: In function ‘void calcDenseFlow(std::cxx11::string, int, int, int, std::vector<std::vector >&, std::vector<std::vector >&, std::vector<std::vector >&)’: /mmaction/third_party/dense_flow/src/dense_flow.cpp:20:17: error: ‘DualTVL1OpticalFlow’ is not a member of ‘cv’ cv::Ptr alg_tvl1 = cv::createOptFlow_DualTVL1(); ^~~~~~~ /mmaction/third_party/dense_flow/src/dense_flow.cpp:20:17: note: suggested alternative: ‘DISOpticalFlow’ cv::Ptr alg_tvl1 = cv::createOptFlow_DualTVL1(); ^~~~~~~ DISOpticalFlow /mmaction/third_party/dense_flow/src/dense_flow.cpp:20:17: error: ‘DualTVL1OpticalFlow’ is not a member of ‘cv’ /mmaction/third_party/dense_flow/src/dense_flow.cpp:20:17: note: suggested alternative: ‘DISOpticalFlow’ cv::Ptr alg_tvl1 = cv::createOptFlow_DualTVL1(); ^~~~~~~ DISOpticalFlow /mmaction/third_party/dense_flow/src/dense_flow.cpp:20:36: error: template argument 1 is invalid cv::Ptr alg_tvl1 = cv::createOptFlow_DualTVL1(); ^ /mmaction/third_party/dense_flow/src/dense_flow.cpp:20:53: error: ‘createOptFlow_DualTVL1’ is not a member of ‘cv’ cv::Ptr alg_tvl1 = cv::createOptFlow_DualTVL1(); ^~~~~~ /mmaction/third_party/dense_flow/src/dense_flow.cpp:32:45: error: ‘CV_BGR2GRAY’ was not declared in this scope cvtColor(prev_image, prev_gray, CV_BGR2GRAY); ^~~ /mmaction/third_party/dense_flow/src/dense_flow.cpp:37:51: error: ‘CV_BGR2GRAY’ was not declared in this scope cvtColor(capture_image, capture_gray, CV_BGR2GRAY); ^~~ /mmaction/third_party/dense_flow/src/dense_flow.cpp:47:29: error: base operand of ‘->’ is not a pointer alg_tvl1->calc(prev_gray, capture_gray, flow); ^~ /mmaction/third_party/dense_flow/src/dense_flow_gpu.cpp: In function ‘void calcDenseFlowGPU(std::cxx11::string, int, int, int, int, std::vector<std::vector >&, std::vector<std::vector >&, std::vector<std::vector >&, int, int)’: /mmaction/third_party/dense_flow/src/dense_flow_gpu.cpp:57:45: error: ‘CV_BGR2GRAY’ was not declared in this scope cvtColor(prev_image, prev_gray, CV_BGR2GRAY); ^~~ /mmaction/third_party/dense_flow/src/dense_flow_gpu.cpp:70:51: error: ‘CV_BGR2GRAY’ was not declared in this scope cvtColor(capture_image, capture_gray, CV_BGR2GRAY); ^~~ /mmaction/third_party/dense_flow/src/dense_flow_gpu.cpp: In function ‘void calcDenseFlowPureGPU(std::cxx11::string, int, int, int, int, std::vector<std::vector >&, std::vector<std::vector >&, std::vector<std::vector >&)’: /mmaction/third_party/dense_flow/src/dense_flow_gpu.cpp:169:45: error: ‘CV_BGR2GRAY’ was not declared in this scope cvtColor(prev_image, prev_gray, CV_BGR2GRAY); ^~~ /mmaction/third_party/dense_flow/src/dense_flow_gpu.cpp:177:51: error: ‘CV_BGR2GRAY’ was not declared in this scope cvtColor(capture_image, capture_gray, CV_BGR2GRAY); ^~~ /mmaction/third_party/dense_flow/src/dense_warp_flow_gpu.cpp: In function ‘void calcDenseWarpFlowGPU(std::cxx11::string, int, int, int, int, std::vector<std::vector >&, std::vector<std::vector >&)’: /mmaction/third_party/dense_flow/src/dense_warp_flow_gpu.cpp:68:36: error: ‘CV_BGR2GRAY’ was not declared in this scope cvtColor(prev_image, prev_gray, CV_BGR2GRAY); ^~~ /mmaction/third_party/dense_flow/src/dense_warp_flow_gpu.cpp:84:42: error: ‘CV_BGR2GRAY’ was not declared in this scope cvtColor(capture_image, capture_gray, CV_BGR2GRAY); ^~~ CMakeFiles/denseflow.dir/build.make:95: recipe for target 'CMakeFiles/denseflow.dir/src/dense_flow.cpp.o' failed make[2]: [CMakeFiles/denseflow.dir/src/dense_flow.cpp.o] Error 1 make[2]: Waiting for unfinished jobs.... CMakeFiles/denseflow.dir/build.make:108: recipe for target 'CMakeFiles/denseflow.dir/src/dense_flow_gpu.cpp.o' failed make[2]: [CMakeFiles/denseflow.dir/src/dense_flow_gpu.cpp.o] Error 1 CMakeFiles/denseflow.dir/build.make:121: recipe for target 'CMakeFiles/denseflow.dir/src/dense_warp_flow_gpu.cpp.o' failed make[2]: [CMakeFiles/denseflow.dir/src/dense_warp_flow_gpu.cpp.o] Error 1 CMakeFiles/Makefile2:211: recipe for target 'CMakeFiles/denseflow.dir/all' failed make[1]: [CMakeFiles/denseflow.dir/all] Error 2 Makefile:103: recipe for target 'all' failed make: [all] Error 2

Here is my environment.

I would appreciate it if you can give me some suggestions.

xia123123 commented 4 years ago

Hi @zhaoyue-zephyrus I have already install dense follow But when I test it,it shows that

VIDIOC_REQBUFS: Inappropriate ioctl for device 2020-10-24 05:43:11,627 FATAL [default] Check failed: [video_stream.isOpened()] Cannot open video stream "test.avi" for optical flow extraction. 2020-10-24 05:43:11,627 WARN [default] Aborting application. Reason: Fatal log at [/data/xxy/dense_flow/src/dense_flow_gpu.cpp:19]

Environment OpenCV 4.1.0 CUDA 10.0 Could you give me some suggestion ?Thank you.

fengfan028 commented 3 years ago

Hi @zhaoyue-zephyrus When I compile dense_flow, it shows that, how to fix it?

Scanning dependencies of target denseflow [ 7%] Building CXX object CMakeFiles/denseflow.dir/src/zip_utils.cpp.o [ 14%] Building CXX object CMakeFiles/denseflow.dir/src/common.cpp.o [ 21%] Building CXX object CMakeFiles/denseflow.dir/src/dense_flow.cpp.o [ 28%] Building CXX object CMakeFiles/denseflow.dir/src/dense_flow_gpu.cpp.o [ 35%] Building CXX object CMakeFiles/denseflow.dir/src/dense_warp_flow_gpu.cpp.o [ 42%] Linking CXX static library libdenseflow.a [ 42%] Built target denseflow Scanning dependencies of target extract_warp_gpu Scanning dependencies of target extract_gpu Scanning dependencies of target pydenseflow Scanning dependencies of target extract_cpu [ 50%] Building CXX object CMakeFiles/extract_warp_gpu.dir/tools/extract_warp_flow_gpu.cpp.o [ 57%] Building CXX object CMakeFiles/extract_cpu.dir/tools/extract_flow.cpp.o [ 64%] Building CXX object CMakeFiles/pydenseflow.dir/src/py_denseflow.cpp.o [ 71%] Building CXX object CMakeFiles/extract_gpu.dir/tools/extract_flow_gpu.cpp.o [ 78%] Linking CXX executable extract_warp_gpu [ 85%] Linking CXX executable extract_cpu [ 92%] Linking CXX executable extract_gpu [ 92%] Built target extract_cpu [ 92%] Built target extract_warp_gpu [ 92%] Built target extract_gpu [100%] Linking CXX shared library libpydenseflow.so /usr/bin/ld: /usr/local/lib/libpython3.6m.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libpython3.6m.a: could not read symbols: Bad value collect2: error: ld returned 1 exit status CMakeFiles/pydenseflow.dir/build.make:155: recipe for target 'libpydenseflow.so' failed make[2]: [libpydenseflow.so] Error 1 CMakeFiles/Makefile2:215: recipe for target 'CMakeFiles/pydenseflow.dir/all' failed make[1]: [CMakeFiles/pydenseflow.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2