GithubHelp home page GithubHelp logo

kbatsos / cbmv Goto Github PK

View Code? Open in Web Editor NEW
53.0 9.0 13.0 25.94 MB

Welcome to the code repository of CBMV: A Coalesced Bidirectional Matching Volume for Disparity Estimation. CVPR 2018

License: GNU General Public License v3.0

C++ 81.29% Makefile 2.66% Cuda 6.26% Python 8.71% CMake 0.79% C 0.09% Shell 0.20%

cbmv's Introduction

CBMV: A Coalesced Bidirectional Matching Volume for Disparity Estimation

CBMV: A Coalesced Bidirectional Matching Volume for Disparity Estimation code repository. If you use this code please cite our paper CBMV: A Coalesced Bidirectional Matching Volume for Disparity Estimation.

@inproceedings{batsos2018cbmv,
  title={CBMV: A Coalesced Bidirectional Matching Volume for Disparity Estimation},
  author={Batsos, Konstantinos and Cai, Changjiang and Mordohai, Philipos},
  booktitle={IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2018}
}

The repository contains the code, models and procudures for training and testing. The code includes the cost-optimization and post-processing of MC-CNN Stereo Matching by Training a Convolutional Neural Network to Compare Image Patches as implemented by Jure Zbontar, and modified to interface with python. We aslo incorporate, as an alternative cost-optimization method, the code from Continuous 3D Label Stereo Matching using Local Expansion Moves.

Links

Training Data

CBMV model: the trained random forest model, with version 0.17.1 sklearn.

Run CBMV

To run CBMV you need the following python packages:

Python

  • numpy
  • scipy
  • sklearn (version 0.17.1)
  • cPickle

Much of CBMV code is written as C++ libraries and interface with python via boost python. To compile the C++ libraries you will need the following:

C++

  • OpenCV 3.0
  • Boost ( boost python )
  • CUDA

Compilation

Assuming this repository is rooted at "~/cbmv-cvpr18/", the OpenCV library is installed at /usr/local/opencv-3.2.0.

    1. To compile matchers, featextract and rectification:
      We provide both makefile and CMakeLists.txt(preferred) for compilation. If you have installed OpenCV at different directory, please update the line g++ -I/usr/local/opencv-3.2.0/include/ ... in the file */Debug/subdir.mk for including header files; and modify the line g++ ... -L/usr/local/opencv-3.2.0/lib ... in the file */Debug/makefile for library linking. Or to modify the line set(OpenCV_DIR "/usr/local/opencv-3.2.0/share/OpenCV/") in the file CMakeList.txt.
# 1) Method 1 : using CMake, will generate the libraries in the directory `~/cbmv-cvpr18/cpp/lib`.
cd ~/cbmv-cvpr18/cpp/ && mkdir build && cd build && cmake .. && build 

# 2) Method 2 : using makefile
#To compile `matchers` for four basic matchers:
cd ~/cbmv-cvpr18/cpp/matchers/Debug && make clean && make
# To compile `featextract` for feature extraction:
cd ~/cbmv-cvpr18/cpp/featextract/Debug && make clean && make
# To compile `rectification` for rectifying stereo image pair:
cd ~/cbmv-cvpr18/cpp/rectification/Debug && make clean && make
    1. To compile post for postprocessing:
      This part contains the GPU code. We assume the CUDA was installed at /usr/local/cuda-8.0/. If not, please modify the line CUDA_LIBS = /usr/local/cuda-8.0/lib64 in the file */post/makefile.
cd ~/cbmv-cvpr18/cpp/post/ && make clean && make
    1. To compile localexp for Local Expansion Moves:
      This part requires the Maxflow code by Boykov and Kolmogorov [Code v3.01] [Code v3.04]. For your convenience, we already include and confiure it. But please note they are freely available for research purposes only. You could also check the Local Expansion Move repository for the license. For localexp compilation, we provide the CMakeLists.txt file. Run the following
# will generate the libraries in the directory `*/localexp/lib`.
cd ~/cbmv-cvpr18/cpp/localexp && mkdir build && cd build && cmake .. && make

You can change the OMP threads number defined by #define THREADS_NUM_USED 16 at file ~/cbmv-cvpr18/cpp/paramSetting.hpp, for efficient parallel computation.


After compiling the C++ libraries, downloading the required python packages and precomputed model (Note: pay attention to the version of sklearn), CBMV can be executed using the following command

python main.py  --l ./datasets/ArtL/im0.png --r ./datasets/ArtL/im1.png --w 694 --h 554 --d 128 --model ./modelall_4m.rf --prob_save_path ./

For a complete list of arguments please see tha main.py file. We provide a script run_test_cbmv.sh to run CBMV for testing and see more details in section Disparity Estimation.

Training

The above link includes the data we used to trained CBMV. To train CBMV you can use the following command:

python main.py --train --data_path "./datasets/" --train_add ./mb/additional.txt --train_set ./mb/trainall.txt --model ./models/model.rf

The *.txt files specify the training sets used during the training process. For a complete list of arguments please see tha main.py file. We also provide a script run_train_cbmv.sh to train CBMV.

Disparity Estimation

Giveing the cost volume, there are two methods for cost-optimization in order to generate the disparity map as output.

  • Post-processing used by MC-CNN: see the code ~/cbmv-cvpr18/cpp/post/post.cu for details.
  • Local Expansion Moves: see the codes ~/cbmv-cvpr18/cpp/localexp/local_exp_stereo.cpp for more details. You can also modify the hyperparameters defined in function __postprocessing_localExp(...) in the file ~/cbmv-cvpr18/test.py.

cbmv's People

Contributors

ccj5351 avatar kbatsos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cbmv's Issues

post part does NOT work due to GCC GNU 7.0

When I try to run: cd ~/cbmv-cvpr18/cpp/post/ && make clean && make

I get a GNU version 6.0 error, because I have GNU 7.0:
cd ~/ICE/cbmv-cvpr18/cpp/post/ && make clean && make
rm -rf *.so *.o
nvcc -arch=sm_52 --default-stream per-thread -O3 -L/usr/lib -lboost_python -lpython2.7 -I/usr/include/python2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include -Xcompiler -fopenmp -Xcompiler -fPIC --shared post.cu -o post.so
In file included from /usr/include/host_config.h:50:0,
from /usr/include/cuda_runtime.h:78,
from :0:
/usr/include/crt/host_config.h:121:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported!
#error -- unsupported GNU version! gcc versions later than 6 are not supported!
^~~~~
In file included from /usr/include/common_functions.h:50:0,
from /usr/include/cuda_runtime.h:115,
from :0:
/usr/local/include/boost/config/compiler/nvcc.hpp:22:34: error: token ""CUDACC_VER is no longer supported. Use CUDACC_VER_MAJOR, CUDACC_VER_MINOR, and CUDACC_VER_BUILD instead."" is not valid in preprocessor expressions
#if !defined(CUDACC_VER) || (CUDACC_VER < 70500)
^
/usr/local/include/boost/config/compiler/nvcc.hpp:26:6: error: token ""CUDACC_VER is no longer supported. Use CUDACC_VER_MAJOR, CUDACC_VER_MINOR, and CUDACC_VER_BUILD instead."" is not valid in preprocessor expressions
#if (CUDACC_VER > 80000) && (CUDACC_VER < 80100)
^
makefile:27: recipe for target 'post.so' failed
make: *** [post.so] Error 1

Will I NOT be able to run the code if I have GCC GNU version above 6.0?

Agni.

build Command fails as no solution file is found

Hello,

After I run the following command from Method1 described on README:
cd ~/cbmv-cvpr18/cpp/ && mkdir build && cd build && cmake .. && build

I get the error:
MSBUILD: error MSBUILD0003: Please specify the project or solution file to build, as none was found in the current directory
I can see the cmake command has created the aforementioned files but cant find the solution file. Any suggestion?

Thanks,
Agni.

cuda problem?

I am using a Ubuntu 18.04, CUDA 9.0, Python 2.7, Scikit-learn 0.17.1, Numpy 1.16.4, Scipy 1.2.2 and cPickle 1.71, opencv 3.2.0 and nvcc is 9.0, V9.0.176.

I am trying to run the following command
python main.py --l ./datasets/ArtL/im0.png --r ./datasets/ArtL/im1.png --w 694 --h 554 --d 128 --model ./modelall_4m.rf --prob_save_path ./
But I get the following output:

Cost volume: ./.prob.npy not exists!
Batch testing
Iterations: 4.0
Progress |██████████████████████████████████████████████████| 100.0% Complete
CUDA initialized.
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
Error: no kernel image is available for execution on the device
0.346982002258
Saved ./results/disp.pfm

My guess is it's a problem with the CUDA architecture, any suggestion?
Also, what does this output number mean?
This is what my disp.pfm looks like:

image

Any help will be appreciated :) thanks!

#include "opencv2/xfeatures2d.hpp" NOT FOUND

Hello,

I am using Method 2 from README, first two steps ran successfully.
However when I run step 3: cd ~/cbmv-cvpr18/cpp/rectification/Debug && make clean && make
I get the error: ../rectification.cpp:12:10: fatal error: opencv2/xfeatures2d.hpp: No such file or directory
#include "opencv2/xfeatures2d.hpp"
When I issue: python on my server's terminal, and request version for cv2, I get:

cv2.version
'3.2.0'

I understand that xfeatures2d.hpp comes under the contrib package of openCV - any suggestion how I can get this to work?

Thanks,
Agni.

Scikit-learn(0.18.1) unable to unpickle a model saved from scikit-learn pre-0.18

Hello, thanks for you excellent work.
Recently, when i test the CBMV using your example command:

python main.py --l ./datasets/ArtL/im0.png --r ./datasets/ArtL/im1.png --w 694 --h 554 --d 128 --model ./modelall_4m.rf --prob_save_path ./

but it returns that UserWarning: Trying to unpickle estimator DecisionTreeClassifier from version pre-0.18 when using version 0.18.1. This might lead to breaking code or invalid results. Use at your own risk.

After searching for method to resolve it, i found that it's the conflict of scikit-learn version. Can you show us the scikit-learn version you use to save the model?

Or could you save the model by scikit-learn 0.18.1, and reload the new version of Model.

Thanks.

question

配置好环境之后,如何实现这个项目?????? 望大神不吝赐教

About the dataset

hi, Thank you for your wonderful work. Can u provide the information of your dataset?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.