在ubuntu14.04下安装kinect报了很多错误:主要是opencv的版本与ros之间的冲突:
报错:
make[2]: *** 没有规则可以创建“/.so”需要的目标“/usr/lib/x86_64-linux-gnu/libopencv_videostab.so.2.4.8”。 停止。
卸载cv_bridge重装:
sudo apt-get remove ros-indigo-cv-bridge
1.指定opencv版本编译:
这一步不管你单纯是cmake工程或者是ros的包,都可以通过下面的办法在CMakeLists.txt中添加相应的语句来选择不同版本的OpenCV进行编译。
1. set(OpenCV_DIR /home/ubuntu/opencv-2.4.13.6) 2. find_package(OpenCV 2.4 REQUIRED) 3. include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS} /home/ubuntu/opencv-2.4.13.6/include) 4. link_directories(${OpenCV_LIBRARY_DIRS} /home/ubuntu/opencv-2.4.13.6/lib)
2.cv_bridge与opencv兼容性问题
ROS kinetic中的cv_bridge中默认使用自带opencv3,而我们人脸识别程序使用的是opencv2,而需要解决cv3和cv2不兼容的问题,解决办法很简单,那就是找到/opt/ros/indigio/share/cv_bridge/cmake中的cv_bridgeConfig.cmake
1. if(NOT "include;/home/ubuntu/opencv-2.4.13.6;/home/ubuntu/opencv-2.4.13.6/include " STREQUAL " ") 2. set(cv_bridge_INCLUDE_DIRS "") 3. set(_include_dirs "include;/home/ubuntu/opencv-2.4.13.6;/home/ubuntu/opencv-2.4.13.6/include")
还有几个so文件路径改一下,在这里我们的路径在/usr/local/lib下,同理只要将上面的/usr/lib/x86_64-linux-gnu/路径改为自己的路径即可。
set(libraries "cv_bridge;/usr/local/lib/libopencv_videostab.so.2.4.13;/usr/local/lib/libopencv_video.so.2.4.13;/usr/local/lib/libopencv_superres.so.2.4.13;/usr/local/lib/libopencv_stitching.so.2.4.13;/usr/local/lib/libopencv_photo.so.2.4.13;/usr/local/lib/libopencv_ocl.so.2.4.13;/usr/local/lib/libopencv_objdetect.so.2.4.13;/usr/local/lib/libopencv_ml.so.2.4.13;/usr/local/lib/libopencv_legacy.so.2.4.13;/usr/local/lib/libopencv_imgproc.so.2.4.13;/usr/local/lib/libopencv_highgui.so.2.4.13;/usr/local/lib/libopencv_gpu.so.2.4.13;/usr/local/lib/libopencv_flann.so.2.4.13;/usr/local/lib/libopencv_features2d.so.2.4.13;/usr/local/lib/libopencv_core.so.2.4.13;/usr/local/lib/libopencv_contrib.so.2.4.13;/usr/local/lib/libopencv_calib3d.so.2.4.13")
此问题主要是对应目录没有相应的库,通过下面的脚本建立库的软连接。
3.建立脚本,changelib.sh
1. sudo ln -s /usr/local/lib/libopencv_calib3d.so /usr/lib/x86_64-linux-gnu/libopencv_calib3d.so.2.4.8 2. sudo ln -s /usr/local/lib/libopencv_contrib.so /usr/lib/x86_64-linux-gnu/libopencv_contrib.so.2.4.8 3. sudo ln -s /usr/local/lib/libopencv_core.so /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4.8 4. sudo ln -s /usr/local/lib/libopencv_detection_based_tracker.so /usr/lib/x86_64-linux-gnu/libopencv_detection_based_tracker.so.2.4.8 5. sudo ln -s /usr/local/lib/libopencv_esm_panorama.so /usr/lib/x86_64-linux-gnu/libopencv_esm_panorama.so.2.4.8 6. sudo ln -s /usr/local/lib/libopencv_facedetect.so /usr/lib/x86_64-linux-gnu/libopencv_facedetect.so.2.4.8 7. sudo ln -s /usr/local/lib/libopencv_features2d.so /usr/lib/x86_64-linux-gnu/libopencv_features2d.so.2.4.8 8. sudo ln -s /usr/local/lib/libopencv_flann.so /usr/lib/x86_64-linux-gnu/libopencv_flann.so.2.4.8 9. sudo ln -s /usr/local/lib/libopencv_gpu.so /usr/lib/x86_64-linux-gnu/libopencv_gpu.so.2.4.8 10. sudo ln -s /usr/local/lib/libopencv_highgui.so /usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4.8 11. sudo ln -s /usr/local/lib/libopencv_imgproc.so /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.8 12. sudo ln -s /usr/local/lib/libopencv_imuvstab.so /usr/lib/x86_64-linux-gnu/libopencv_imuvstab.so.2.4.8 13. sudo ln -s /usr/local/lib/libopencv_legacy.so /usr/lib/x86_64-linux-gnu/libopencv_legacy.so.2.4.8 14. sudo ln -s /usr/local/lib/libopencv_ml.so /usr/lib/x86_64-linux-gnu/libopencv_ml.so.2.4.8 15. sudo ln -s /usr/local/lib/libopencv_objdetect.so /usr/lib/x86_64-linux-gnu/libopencv_objdetect.so.2.4.8 16. sudo ln -s /usr/local/lib/libopencv_photo.so /usr/lib/x86_64-linux-gnu/libopencv_photo.so.2.4.8 17. sudo ln -s /usr/local/lib/libopencv_stitching.so /usr/lib/x86_64-linux-gnu/libopencv_stitching.so.2.4.8 18. sudo ln -s /usr/local/lib/libopencv_superres.so /usr/lib/x86_64-linux-gnu/libopencv_superres.so.2.4.8 19. sudo ln -s /usr/local/lib/libopencv_tegra.so /usr/lib/x86_64-linux-gnu/libopencv_tegra.so.2.4.8 20. sudo ln -s /usr/local/lib/libopencv_video.so /usr/lib/x86_64-linux-gnu/libopencv_video.so.2.4.8 21. sudo ln -s /usr/local/lib/libopencv_videostab.so /usr/lib/x86_64-linux-gnu/libopencv_videostab.so.2.4.8 22. sudo ln -s /usr/local/lib/libopencv_vstab.so /usr/lib/x86_64-linux-gnu/libopencv_vstab.so.2.4.8 23. 24. sudo ln -s /usr/local/lib/libopencv_ts.a /usr/lib/x86_64-linux-gnu/libopencv_ts.so.2.4.8 25. sudo ln -s /usr/local/lib/libopencv_ocl.so.2.4.13 /usr/lib/x86_64-linux-gnu/libopencv_ocl.so.2.4.8
4.运行:sh ./changelib.sh
> 我的微信公众号名称:深度学习与先进智能决策
> 微信公众号ID:MultiAgent1024
> 公众号介绍:主要研究分享深度学习、机器博弈、强化学习等相关内容!期待您的关注,欢迎一起学习交流进步!