ROS2之OpenCV的windows和linux差异在哪里

举报
zhangrelay 发表于 2022/06/15 23:02:57 2022/06/15
【摘要】 本质上并没有差异,但是环境配置上有很多小区别。 如果是python程序通常可以直接使用的。 但是如何是C++,则有可能出现编译不通过的情况。 案例如下: windows出错 C:\ros_ws\opencv_cam>colcon build --event-handlers console_cohesion+[2.13...

本质上并没有差异,但是环境配置上有很多小区别。


如果是python程序通常可以直接使用的。

但是如何是C++,则有可能出现编译不通过的情况。

案例如下:

windows出错


  
  1. C:\ros_ws\opencv_cam>colcon build --event-handlers console_cohesion+
  2. [2.135s] root DEBUG Using proactor: IocpProactor
  3. Starting >>> ros2_shared
  4. --- output: ros2_shared
  5. -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.22616.
  6. -- Found ament_cmake: 0.9.8 (C:/opt/ros/foxy/x64/share/ament_cmake/cmake)
  7. -- Using PYTHON_EXECUTABLE: C:/opt/ros/foxy/x64/python.exe
  8. -- Configuring done
  9. -- Generating done
  10. -- Build files have been written to: C:/ros_ws/opencv_cam/build/ros2_shared
  11. 用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.9.0+5e4b48a27
  12. 版权所有(C) Microsoft Corporation。保留所有权利。
  13. Checking Build System
  14. Building Custom Rule C:/ros_ws/opencv_cam/src/ros2_shared/CMakeLists.txt
  15. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/include
  16. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/include/ros2_shared
  17. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/include/ros2_shared/context_macros.hpp
  18. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/include/ros2_shared/param_macros.hpp
  19. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/include/ros2_shared/string_printf.hpp
  20. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/share/ament_index/resource_index/package_run_dependencies/ros2_shared
  21. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/share/ament_index/resource_index/parent_prefix_path/ros2_shared
  22. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/share/ros2_shared/environment/ament_prefix_path.bat
  23. -- Installing: C:/ros_ws/opencv_cam/install/ros2_shared/share/ros2_shared/environment/ament_prefix_path.dsv
  24. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/share/ros2_shared/environment/path.bat
  25. -- Installing: C:/ros_ws/opencv_cam/install/ros2_shared/share/ros2_shared/environment/path.dsv
  26. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/share/ros2_shared/local_setup.bat
  27. -- Installing: C:/ros_ws/opencv_cam/install/ros2_shared/share/ros2_shared/local_setup.dsv
  28. -- Installing: C:/ros_ws/opencv_cam/install/ros2_shared/share/ros2_shared/package.dsv
  29. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/share/ament_index/resource_index/packages/ros2_shared
  30. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/share/ros2_shared/cmake/ament_cmake_export_include_directories-extras.cmake
  31. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/share/ros2_shared/cmake/ros2_sharedConfig.cmake
  32. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/share/ros2_shared/cmake/ros2_sharedConfig-version.cmake
  33. -- Up-to-date: C:/ros_ws/opencv_cam/install/ros2_shared/share/ros2_shared/package.xml
  34. ---
  35. Finished <<< ros2_shared [6.11s]
  36. Starting >>> opencv_cam
  37. --- output: opencv_cam
  38. -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.22616.
  39. -- Found OpenCV version 4.3.0
  40. -- Found ament_cmake: 0.9.8 (C:/opt/ros/foxy/x64/share/ament_cmake/cmake)
  41. -- Using PYTHON_EXECUTABLE: C:/opt/ros/foxy/x64/python.exe
  42. -- Found camera_calibration_parsers: 2.3.0 (C:/opt/ros/foxy/x64/share/camera_calibration_parsers/cmake)
  43. -- Using all available rosidl_typesupport_c: rosidl_typesupport_fastrtps_c;rosidl_typesupport_introspection_c
  44. -- Found rosidl_adapter: 1.2.0 (C:/opt/ros/foxy/x64/share/rosidl_adapter/cmake)
  45. -- Using all available rosidl_typesupport_cpp: rosidl_typesupport_fastrtps_cpp;rosidl_typesupport_introspection_cpp
  46. -- Found rmw_implementation_cmake: 1.0.2 (C:/opt/ros/foxy/x64/share/rmw_implementation_cmake/cmake)
  47. -- Using RMW implementation 'rmw_fastrtps_cpp' as default
  48. -- Found class_loader: 2.0.1 (C:/opt/ros/foxy/x64/share/class_loader/cmake)
  49. -- Found rclcpp_components: 2.3.0 (C:/opt/ros/foxy/x64/share/rclcpp_components/cmake)
  50. -- Found ros2_shared: 0.1.0 (C:/ros_ws/opencv_cam/install/ros2_shared/share/ros2_shared/cmake)
  51. -- Configuring done
  52. -- Generating done
  53. -- Build files have been written to: C:/ros_ws/opencv_cam/build/opencv_cam
  54. 用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.9.0+5e4b48a27
  55. 版权所有(C) Microsoft Corporation。保留所有权利。
  56. Checking Build System
  57. Building Custom Rule C:/ros_ws/opencv_cam/src/opencv_cam/CMakeLists.txt
  58. opencv_cam_node.vcxproj -> C:\ros_ws\opencv_cam\build\opencv_cam\Release\opencv_cam_node.dll
  59. Building Custom Rule C:/ros_ws/opencv_cam/src/opencv_cam/CMakeLists.txt
  60. subscriber_node.vcxproj -> C:\ros_ws\opencv_cam\build\opencv_cam\Release\subscriber_node.dll
  61. Building Custom Rule C:/ros_ws/opencv_cam/src/opencv_cam/CMakeLists.txt
  62. LINK : fatal error LNK1181: cannot open input file 'Release\opencv_cam_node.lib' [C:\ros_ws\opencv_cam\build\opencv_cam\ipc_test_main.vcxproj]
  63. Building Custom Rule C:/ros_ws/opencv_cam/src/opencv_cam/CMakeLists.txt
  64. LINK : fatal error LNK1181: cannot open input file 'Release\opencv_cam_node.lib' [C:\ros_ws\opencv_cam\build\opencv_cam\opencv_cam_main.vcxproj]
  65. ---
  66. Failed <<< opencv_cam [8.31s, exited with code 1]
  67. Summary: 1 package finished [14.8s]
  68. 1 package failed: opencv_cam

linux正常:


  
  1. colcon build
  2. Starting >>> ros2_shared
  3. -- Install configuration: ""
  4. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/include
  5. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/include/ros2_shared
  6. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/include/ros2_shared/param_macros.hpp
  7. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/include/ros2_shared/string_printf.hpp
  8. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/include/ros2_shared/context_macros.hpp
  9. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ament_index/resource_index/package_run_dependencies/ros2_shared
  10. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ament_index/resource_index/parent_prefix_path/ros2_shared
  11. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ros2_shared/environment/ament_prefix_path.sh
  12. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ros2_shared/environment/ament_prefix_path.dsv
  13. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ros2_shared/environment/path.sh
  14. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ros2_shared/environment/path.dsv
  15. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ros2_shared/local_setup.bash
  16. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ros2_shared/local_setup.sh
  17. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ros2_shared/local_setup.zsh
  18. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ros2_shared/local_setup.dsv
  19. -- Installing: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ros2_shared/package.dsv
  20. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ament_index/resource_index/packages/ros2_shared
  21. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ros2_shared/cmake/ament_cmake_export_include_directories-extras.cmake
  22. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ros2_shared/cmake/ros2_sharedConfig.cmake
  23. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ros2_shared/cmake/ros2_sharedConfig-version.cmake
  24. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/ros2_shared/share/ros2_shared/package.xml
  25. Finished <<< ros2_shared [0.14s]
  26. Starting >>> opencv_cam
  27. [ 50%] Built target opencv_cam_node
  28. [ 50%] Built target subscriber_node
  29. [100%] Built target ipc_test_main
  30. [100%] Built target opencv_cam_main
  31. -- Install configuration: ""
  32. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/environment/library_path.sh
  33. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/environment/library_path.dsv
  34. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/ament_index/resource_index/package_run_dependencies/opencv_cam
  35. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/ament_index/resource_index/parent_prefix_path/opencv_cam
  36. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/environment/ament_prefix_path.sh
  37. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/environment/ament_prefix_path.dsv
  38. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/environment/path.sh
  39. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/environment/path.dsv
  40. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/local_setup.bash
  41. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/local_setup.sh
  42. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/local_setup.zsh
  43. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/local_setup.dsv
  44. -- Installing: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/package.dsv
  45. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/ament_index/resource_index/packages/opencv_cam
  46. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/ament_index/resource_index/rclcpp_components/opencv_cam
  47. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/cmake/export_opencv_cam_nodeExport.cmake
  48. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/cmake/export_opencv_cam_nodeExport-noconfig.cmake
  49. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/cmake/export_subscriber_nodeExport.cmake
  50. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/cmake/export_subscriber_nodeExport-noconfig.cmake
  51. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/cmake/ament_cmake_export_dependencies-extras.cmake
  52. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/cmake/ament_cmake_export_include_directories-extras.cmake
  53. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/cmake/ament_cmake_export_targets-extras.cmake
  54. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/cmake/ament_cmake_export_libraries-extras.cmake
  55. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/cmake/opencv_camConfig.cmake
  56. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/cmake/opencv_camConfig-version.cmake
  57. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/package.xml
  58. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/lib/libopencv_cam_node.so
  59. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/lib/libsubscriber_node.so
  60. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/lib/opencv_cam/opencv_cam_main
  61. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/lib/opencv_cam/ipc_test_main
  62. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/launch
  63. -- Up-to-date: /home/zhangrelay/ros_ws/opencv_camc/install/opencv_cam/share/opencv_cam/launch/composition_launch.py
  64. Finished <<< opencv_cam [0.29s]

如何解决这类报错,后续更新。

一个提示:

ROS2 is comfortably using Python3, so let that alleviate your concerns.

The error you see wnen using rosdep install is just rosdep telling you that it doesn't know what "opencv2" is for your given OS and so it can't install something that satisfies the requirement listed in the package.xml of your cv_basics pacakge. As for resolutions, I'll refer you to question #232795 which does a good job of explaining how rosdep works and what you can do next.

If you've installed OpenCV2 yourself and have confirmed that the version you've installed matches the version expected by whichever package has the dependency, then you should be okay to ignore the error. You can ignore errors when by adding -r to your rosdep call. This allows rosdep to continue installing dependencies, despite errors.

If you'd rather fix the error, then you probably want to change "opencv2" in your package.xml to "opencv-python" so that rosdep can find it. opencv-python points to OpenCV 4.5.3.56 so it should be what you're looking for.

 

ROS2 可以轻松地使用 Python3,因此可以减轻顾虑。

使用 rosdep install 看到 wnen 的错误只是 rosdep 告诉它不知道给定操作系统的“opencv2”是什么,因此它无法安装满足 cv_basics pacakge 的 package.xml 中列出的要求的东西.至于解决方案,建议参考问题#232795,该问题很好地解释了 rosdep 的工作原理以及您接下来可以做什么。

如果自己安装了 OpenCV2 并确认您安装的版本与任何具有依赖项的软件包所期望的版本相匹配,那么应该可以忽略该错误。通过在 rosdep 调用中添加 -r 可以忽略错误。这允许 rosdep 继续安装依赖项,尽管出现错误。

如果想修复错误,那么可能希望将 package.xml 中的“opencv2”更改为“opencv-python”,以便 rosdep 可以找到它。 opencv-python 指向 OpenCV 4.5.3.56 所以它应该是要找的。


文章来源: zhangrelay.blog.csdn.net,作者:zhangrelay,版权归原作者所有,如需转载,请联系作者。

原文链接:zhangrelay.blog.csdn.net/article/details/125287554

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。