Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSoC 2017: dynamicfusion #1349

Open
wants to merge 6 commits into
base: 4.x
Choose a base branch
from
Open

Conversation

mihaibujanca
Copy link

@mihaibujanca mihaibujanca commented Aug 29, 2017

GSoC Project: Implementing and extending DynamicFusion (Newcombe et al 2015)
Mentors: Zhe Zhang, Reza Amayeh

For now just added the code from my repository, with CMakeLists.txt building the project as stand-alone. I will be working towards changing that to be an opencv_contrib module.

docker_image:Custom=ubuntu-cuda:16.04

@mshabunin mshabunin added the GSoC label Aug 29, 2017
@zzhang001
Copy link

This is this GSoC project's mentor. @mshabunin Please advise the next steps moving forward. There will be dependencies to be installed for this to run. Any instructions we should follow to pass the checks, additional cleanups/refactors needed for us to merge in? Thanks in advance!

@mshabunin
Copy link
Contributor

@zzhang001 , as I can see, most of dependencies can be provided by OpenCV, for example OpenNI and CUDA. Module should be reconstructed to be supported by our build scripts, please take a look at some other modules in opencv_contrib.
General scheme is as follows:

├── CMakeLists.txt
├── doc
│   └── <module>.bib
├── include
│   └── opencv2
│       └── <module>.hpp
├── README.md
├── samples
│   ├── <sample_app1>.cpp
│   └── <sample_script1>.py
├── src
│   ├── <internal1>.hpp
│   └── <internal1>.cpp
├── test
│   ├── test_<block1>.cpp
│   ├── test_main.cpp
│   └── test_precomp.hpp
└── tutorials
    └── <tutorial1>.markdown

@mihaibujanca
Copy link
Author

@mshabunin What about dependencies like Ceres and Boost?

@mshabunin
Copy link
Contributor

Looks like it is possible to avoid using Boost in this case, as for Ceres - we have the sfm module which optionally uses this library, so you can take check corresponding cmake script. For this moment you should integrate it by yourself, but in future we can move Ceres detection to main repository.

find_package(OpenCV REQUIRED COMPONENTS core viz highgui calib3d)
#include(cmake/Targets.cmake)
#
## ---[ find dependencies
find_package(CUDA REQUIRED)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not use REQUIRED option, instead just check whether the dependency has been found and disable your module if it can not be built without it:

find_package(Ceres QUIET)
if (NOT Ceres_FOUND)
    message(STATUS "${module} has been disabled because Ceres library has not been found")
    ocv_module_disable(${module})
endif()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to use existing HAVE_CUDA variable, check the documentation at the beginning of https://github.com/opencv/opencv/blob/master/cmake/FindCUDA.cmake

# add_subdirectory(tests)
# endif()
#endif()
find_package(Boost REQUIRED COMPONENTS system filesystem program_options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the Boost is not needed anymore.

# endif()
#endif()
find_package(Boost REQUIRED COMPONENTS system filesystem program_options)
ocv_define_module(dynamicfusion opencv_core opencv_calib3d opencv_viz opencv_highgui)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any #include "opencv2/calib3d.hpp" in your code, it means that you don't need the dependency on opencv_calib3d module. Same for opencv_highgui.

Note that all samples will receive dependency on imgcodecs, videoio and highgui automatically, so you don't need to add them to your module.

#include <kfusion/cuda/tsdf_volume.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/utils/dual_quaternion.hpp>
Copy link
Contributor

@mshabunin mshabunin Sep 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be #include <opencv2/kfusion/utils/dual_quaternion.hpp>
You should create single include folder: include/opencv2/dynamicfusion and put all sub folders into it:

include/opencv2/
    dynamicfusion.hpp
    dynamicfusion/
        utils/
            ...
        kfusion/
            ...

Then: #include "opencv2/dynamicfusion/utils/dual_quaternion.hpp"


add_subdirectory(kfusion)
add_subdirectory(apps)
include_directories(${CERES_INCLUDE_DIRS} ${Boost_INCLUDE_DIR} ${CUDA_INCLUDE_DIRS} ${OPENNI_INCLUDE_DIR} "kfusion/src/utils" "kfusion/include/nanoflann")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use existing flann module instead of nanoflann?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into porting from nanoflann to flann at some point later

{
namespace kfusion
{
class KF_EXPORTS OpenNISource
Copy link
Contributor

@mshabunin mshabunin Sep 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this class is not used anymore, did you try to use VideoCapture with OPENNI backend?

VideoCapture cap(CAP_OPENNI2);

It has different properties which can be accessed via VideoCapture::get and ::set methods: link to documentation

@savuor savuor self-assigned this Nov 14, 2017
@savuor
Copy link
Contributor

savuor commented Dec 11, 2017

@mihaibujanca After fixing different compilation errors I failed to run your code.
It ends at 5th frame with "out of memory" error trying to allocate more GPU memory. (On older GPUs even earlier when device's memory is exhausted).
And I get no 3d data in view window at all.
I use your test data downloaded with provided script.
Can you please provide a working version of your application? Maybe stand-alone one you made before creating a module?

@mihaibujanca
Copy link
Author

@savuor it's changed quite a bit since the PR, but please check out https://github.com/mihaibujanca/dynamicfusion

Apologies for not having fixed it yet

@savuor
Copy link
Contributor

savuor commented Dec 19, 2017

@mihaibujanca The code from your repo doesn't work on your test data.
Some checks are missed, for example (on what I stopped now) WarpField is initialized on first frame size which is empty by some reason, and it leads to segfault.
But at least 3d viewer displays some data.
Can you fix this? At least in your standalone version but it'd be better to fix also this PR.

@mihaibujanca
Copy link
Author

Will be working on it, though not completely sure why the first frame would be empty - can have you downloaded the data and passed the directory as an argument?

@savuor
Copy link
Contributor

savuor commented May 31, 2018

@mihaibujanca
After many unsuccessful attempts to run your code on my machine I decided to implement at least basic version of KinectFusion. Here it is: #1627
Since OpenCV is a cross-platform library each algorithm needs to have a CPU implementation at least (though it can be very slow).
Our version of KinectFusion is CPU-based but works fast enough on rough scale.
Please feel free to add GPU-version (no CUDA code, OpenCL only to let it work on a maximum amount of platforms).
Also you may implement DynamicFusion based on current KinectFusion implementation. This should be similar to your code since the base code is the same (kinfu-remake by A. Baksheev).
But there should be a CPU-only implementation for tests and accuracy checks (even if it's quite slow).

@mihaibujanca
Copy link
Author

@savuor Thanks a lot for your work. I'm currently in the exam session so I don't expect to be able to do this for a while.
That being said, I apologise for my lack of activity on this and don't intend on leaving it the way it is now.

@savuor
Copy link
Contributor

savuor commented Jun 1, 2018

@mihaibujanca No problem, you can attend later when you have a time

@savuor
Copy link
Contributor

savuor commented Oct 3, 2018

@mihaibujanca FYI #1798

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants