Skip to content

cuda optflow TVL1 : run safely in async mode#17556

Merged
opencv-pushbot merged 2 commits intoopencv:3.4from
nglee:dev_optFlowTVL1Async
Jun 16, 2020
Merged

cuda optflow TVL1 : run safely in async mode#17556
opencv-pushbot merged 2 commits intoopencv:3.4from
nglee:dev_optFlowTVL1Async

Conversation

@nglee
Copy link
Copy Markdown
Contributor

@nglee nglee commented Jun 15, 2020

Fixes #16013

We are going to use texture object, rather than texture reference.
It allows us to run the algorithm asynchronously.
This is similar to what's been done in #11483

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under OpenCV (BSD) License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake
allow_multiple_commits=1
force_builders=Custom
buildworker:Custom=linux-4
build_image:Custom=ubuntu-cuda:18.04

@alalek
Copy link
Copy Markdown
Member

alalek commented Jun 15, 2020

@nglee Thank you for the contribution!

Could you please take a look on this error message (from Custom builder)?

/build/precommit_custom_linux/3.4/opencv/modules/cudaimgproc/src/cuda/canny.cu:93:8: error: 'struct canny::SrcTex' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct SrcTex
        ^~~~~~
/build/precommit_custom_linux/3.4/opencv/modules/cudaimgproc/src/cuda/canny.cu:104:8: error: base class 'struct canny::SrcTex' has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct SrcTexRef : SrcTex
        ^~~~~~~~~
/build/precommit_custom_linux/3.4/opencv/modules/cudaimgproc/src/cuda/canny.cu:104:8: error: 'struct canny::SrcTexRef' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
/build/precommit_custom_linux/3.4/opencv/modules/cudaimgproc/src/cuda/canny.cu:114:8: error: base class 'struct canny::SrcTex' has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct SrcTexObj : SrcTex
        ^~~~~~~~~
/build/precommit_custom_linux/3.4/opencv/modules/cudaimgproc/src/cuda/canny.cu:114:8: error: 'struct canny::SrcTexObj' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
cc1plus: some warnings being treated as errors

(perhaps it is enough to define destructor of the base class as virtual)

@nglee nglee force-pushed the dev_optFlowTVL1Async branch from 629d006 to 69a298b Compare June 15, 2020 18:47
@nglee
Copy link
Copy Markdown
Contributor Author

nglee commented Jun 15, 2020

@alalek Build error is now fixed!

also modify cuda canny to use createTextureObjectPitch2D, etc.
@nglee nglee force-pushed the dev_optFlowTVL1Async branch from 69a298b to 2043e06 Compare June 16, 2020 16:06
@nglee
Copy link
Copy Markdown
Contributor Author

nglee commented Jun 16, 2020

It is ready to be merged. I've also tested with OP's test code in #16013.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Well done! Thank you for contribution 👍

@opencv-pushbot opencv-pushbot merged commit 9755ab1 into opencv:3.4 Jun 16, 2020
@nglee nglee deleted the dev_optFlowTVL1Async branch June 16, 2020 23:16
@tomoaki0705
Copy link
Copy Markdown
Contributor

Hi @nglee , I see build error on Jetson TX1 and TX2.

/opencv-fork/modules/cudaimgproc/src/cuda/canny.cu(131): error: namespace "std" has no member "enable_if_t"

/opencv-fork/modules/cudaimgproc/src/cuda/canny.cu(131): error: expected a "," or ">"

The direct cause come from this line

https://github.com/opencv/opencv/blame/9755ab160d94f4ad2a672653cf657ad421d46837/modules/cudaimgproc/src/cuda/canny.cu#L131

We only enable C++11 feature on master, not on 3.4, but it seems enable_if_t is a c++14 feature

template< bool B, class T = void > using enable_if_t = typename enable_if<B,T>::type; |   | (since C++14)

I appreciate if you could have a look on this.
Still it's unknown why I didn't face this on Jetson Xavier and Jetson Nano.

@nglee
Copy link
Copy Markdown
Contributor Author

nglee commented Jun 17, 2020

@tomoaki0705

Thank you for investigation. Would you please check your g++ version?

The default mode is C++98 for GCC versions prior to 6.1, and C++14 for GCC 6.1 and above. (Link)

To enable c++14 via cmake, maybe we can try this flag: -DCMAKE_CXX_STANDARD=14.

Just removing the lines with enable_if_t would also work.

@tomoaki0705
Copy link
Copy Markdown
Contributor

Jetson TX1 GCC 5.4.0
Jetson TX2 GCC 5.4.0
Jetson Nano GCC 7.5.0
Jetson Xavier GCC 7.5.0
That makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug category: gpu/cuda (contrib) OpenCV 4.0+: moved to opencv_contrib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Corrupted optical flow using cuda::DenseOpticalFlow asynchronously in multithreaded environment

5 participants