opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

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

Open shibajiu opened this issue 7 years ago • 9 comments

System information (version)
  • OpenCV => 3.4.1
  • Operating System / Platform => Windows10 64 Bit
  • Compiler => Visual Studio 2017
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()); }

shibajiu avatar May 10 '18 03:05 shibajiu

@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.

berak avatar May 11 '18 11:05 berak

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

xlla avatar Jul 05 '18 08:07 xlla

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

SmitSheth avatar Aug 16 '18 09:08 SmitSheth

Recursive include? Are you sure?

alalek avatar Aug 16 '18 09:08 alalek

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

SmitSheth avatar Aug 16 '18 09:08 SmitSheth

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

alalek avatar Aug 16 '18 09:08 alalek

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

SmitSheth avatar Aug 16 '18 09:08 SmitSheth

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

alalek avatar Aug 16 '18 11:08 alalek

Creating a new build directory solves this problem

IsWZZ avatar Apr 23 '24 08:04 IsWZZ