opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.45k stars 5.77k forks source link

'cv::linemod::Modality': cannot instantiate abstract class #1638

Open shibajiu opened 6 years ago

shibajiu commented 6 years ago
System information (version)
Detailed description

I compiled OpenCV 3.4.1 & opencv_contrib 3.4.1 with VS2017 and get similiar error as #issues10844 and solved it by adding #include <opencv2/rgbd/linemod.hpp. Then, I got error: 'C2259 'cv::linemod::Modality': cannot instantiate abstract class opencv_python3'. So, is there anyway to fix it so I can use SIFT algorithm, thx!

Steps to reproduce

1>------ Build started: Project: gen_opencv_python_source, Configuration: Debug x64 ------ 2>------ Build started: Project: opencv_python3, Configuration: Debug x64 ------ 2>cv2.cpp 2>d:\projects\source\opencv\sources\modules\core\include\opencv2\core\ptr.inl.hpp(301): error C2259: 'cv::linemod::Modality': cannot instantiate abstract class 2>d:\projects\source\opencv\sources\modules\core\include\opencv2\core\ptr.inl.hpp(301): note: due to following members: 2>d:\projects\source\opencv\sources\modules\core\include\opencv2\core\ptr.inl.hpp(301): note: 'cv::String cv::linemod::Modality::name(void) const': is abstract 2>d:\projects\source\opencv_contrib-3.4.1\modules\rgbd\include\opencv2\rgbd\linemod.hpp(175): note: see declaration of 'cv::linemod::Modality::name' 2>d:\projects\source\opencv\sources\modules\core\include\opencv2\core\ptr.inl.hpp(301): note: 'void cv::linemod::Modality::read(const cv::FileNode &)': is abstract 2>d:\projects\source\opencv_contrib-3.4.1\modules\rgbd\include\opencv2\rgbd\linemod.hpp(177): note: see declaration of 'cv::linemod::Modality::read' 2>d:\projects\source\opencv\sources\modules\core\include\opencv2\core\ptr.inl.hpp(301): note: 'void cv::linemod::Modality::write(cv::FileStorage &) const': is abstract 2>d:\projects\source\opencv_contrib-3.4.1\modules\rgbd\include\opencv2\rgbd\linemod.hpp(178): note: see declaration of 'cv::linemod::Modality::write' 2>d:\projects\source\opencv\sources\modules\core\include\opencv2\core\ptr.inl.hpp(301): note: 'cv::Ptr<cv::linemod::QuantizedPyramid> cv::linemod::Modality::processImpl(const cv::Mat &,const cv::Mat &) const': is abstract 2>d:\projects\source\opencv_contrib-3.4.1\modules\rgbd\include\opencv2\rgbd\linemod.hpp(196): note: see declaration of 'cv::linemod::Modality::processImpl' 2>d:\projects\source\opencv\sources\modules\python\src2\cv2.cpp(432): note: see reference to function template instantiation 'cv::Ptr<cv::linemod::Modality> cv::makePtr<T>(void)' being compiled 2> with 2> [ 2> T=cv::linemod::Modality 2> ] 2>d:\projects\source\opencv\sources\modules\python\src2\cv2.cpp(1383): note: see reference to function template instantiation 'bool pyopencv_to<cv::linemod::Modality>(PyObject *,cv::Ptr<cv::linemod::Modality> &,const char *)' being compiled 2>d:\projects\source\opencv_contrib-3.4.1\modules\rgbd\misc\python\pyopencv_linemod.hpp(35): note: see reference to function template instantiation 'bool pyopencv_to_generic_vec<cv::Ptr<cv::linemod::Modality>>(PyObject *,std::vector<cv::Ptr<cv::linemod::Modality>,std::allocator<_Ty>> &,const ArgInfo)' being compiled 2> with 2> [ 2> _Ty=cv::Ptr<cv::linemod::Modality> 2> ] 2>Done building project "opencv_python3.vcxproj" -- FAILED. ========== Build: 1 succeeded, 1 failed, 133 up-to-date, 0 skipped ==========

template<typename T> Ptr<T> makePtr() { return Ptr<T>(new T()); }

berak commented 6 years ago

@shibajiu , #issues10844 does not exist, can you try again ?

it's somewhat unclear, what you did here.

and solved it by adding #include <opencv2/rgbd/linemod.hpp> where ? and why ?

you're probably missing this recent patch .

so, if you want to use the rgbd module, try to update the opencv_contrib repo, if all you wanted from it was SIFT, disable it like:

cmake -DBUILD_opencv_rgbd=OFF

then rerun cmake, make, make install.

xlla commented 6 years ago

I got similar error too: 3>C:\Users\xxx\git\opencv\modules\core\include\opencv2/core/ptr.inl.hpp(297): error C2259: “cv::linemod::Modality”:

windows 10 visual studio 2015 cuda & cnnCuda python 2.7

SmitSheth commented 6 years ago

@berak #include <opencv2/rgbd/linemod.hpp> was added in /home/ubuntu/opencv_contrib-3.4.1/modules/rgbd/misc/python/pyopencv_linemod.hpp

alalek commented 6 years ago

Recursive include? Are you sure?

SmitSheth commented 6 years ago

@alalek you have suggested to include the library in issue #10844 of opencv issue ref:https://github.com/opencv/opencv/issues/10844#issuecomment-364931865

alalek commented 6 years ago

The "same file" means "pyopencv_linemod.hpp" (two lines above)

SmitSheth commented 6 years ago

@alalek Have added the library in pyopencv_linemod.hpp. The error still persists.

alalek commented 6 years ago

So, my old suggestion doesn't work really. Thanks for update, I will fix my old comment.

IsWZZ commented 7 months ago

Creating a new build directory solves this problem