PCL, OpenCV and flann conflict

只愿长相守 提交于 2019-12-08 04:24:08

问题


I'm using PCL 1.6, OpenCV 2.4.2 for my program (in Qt) and there is this flann (1.7.1) conflict I cannot resolve.

I have already read a lot about it on the internet, and tried most of the solutions (not using using namespace cv, update the latest version of OpenCV and put PCL includes before OpenCV inludes etc.), but still whenever I use PCL and OpenCV together, the flann-lib (which PCL uses) would cause problem and say e.g. for this line of code typedef flann::Index<Dist> FLANNIndex;

/usr/include/pcl-1.6/pcl/kdtree/kdtree_flann.h:74: error: 'flann' does not name a type

Is there any other workaround?


回答1:


ran into the same problem.

there's one implementation of flann in opencv, and another(probably the same) in pcl.

originally, they live in separate NAMESPACES, but if you do like

using namespace cv;
using namespace pcl;

you get the conflict there.

so, skipping the using namespace cv; line, and instead using cv::anything in the code solved it.




回答2:


I seemed to have found a solution, but I'm not sure it's the best one.

  1. I added #include <flann/flann.h> to ../include/pcl-1.6/pcl/kdtree/kdtree_flann.h, afterwards the error mentioned above went away.

  2. But then OpenCV was having trouble to find its "flann/flann.h", so I changed the directory in ../include/opencv2/flann to flanncv and of course I had also to do this for every .h file which includes this directory, too.

It's not a very neat solution, but it is working for now.



来源:https://stackoverflow.com/questions/11918504/pcl-opencv-and-flann-conflict

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!