1 编译librealsense中python相关的库
1、创建build目录
mkdir build
注意:
build目录是在librealsense
目录下创建的
2、进入build目录
cd build
3、cmake
cmake ../ -DBUILD_PYTHON_BINDINGS:bool=true -DPYTHON_EXECUTABLE=/usr/bin/python3
zhihui@zhihui-desktop:~/librealsense/build$ cmake ../ -DBUILD_PYTHON_BINDINGS:bool=true -DPYTHON_EXECUTABLE=/usr/bin/python3
-- Checking internet connection...
-- Failed to identify Internet connection
CMake Warning at CMakeLists.txt:16 (message):
No internet connection, disabling BUILD_WITH_TM2
CMake Warning at CMakeLists.txt:22 (message):
No internet connection, disabling IMPORT_DEPTH_CAM_FW
-- Info: REALSENSE_VERSION_STRING=2.41.0
-- Setting Unix configurations
-- using RS2_USE_V4L2_BACKEND
-- pybind11 v2.2.1
-- Could NOT find apriltag (missing: APRILTAG_INC APRILTAG_LIB)
-- Unable to find apriltag library, skipping pose-apriltag example
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zhihui/librealsense/build
zhihui@zhihui-desktop:~/librealsense/build$
注意:
- 在cmake的时候最好
把网断掉
,要不在编译的时候可能会检测网络是否连接,会很慢 - 如果不指定,默认是生成python2的动态库,这里我们指定为
python3
:-DPYTHON_EXECUTABLE=/usr/bin/python3
纠正一下:
一定要联网,一定要联网,一定要联网
,在cmke的时候,会去克隆github上的pybind11
仓库,大小大概9MB,因此必须联网,耐心等待一下即可!
4、make编译
make -j3
这个编译会久一点,大概半个小时左右,耐心等一下!
zhihui@zhihui-desktop:~/librealsense/build$ make -j3
Scanning dependencies of target pybac等一下kend2
Scanning dependencies of target realsense-file
[ 0%] Building CXX object wrappers/python/CMakeFiles/pybackend2.dir/pybackend.cpp.o
[ 0%] Building CXX object wrappers/python/CMakeFiles/pybackend2.dir/pybackend_extras.cpp.o
[ 0%] Building C object third-party/realsense-file/CMakeFiles/realsense-file.dir/lz4/lz4.c.o
[ 0%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/console_bridge/src/console.cpp.o
[ 0%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/cpp_common/src/debug.cpp.o
[ 1%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/cpp_common/src/header.cpp.o
[ 1%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/rosbag_storage/src/bag.cpp.o
[ 1%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/rosbag_storage/src/bag_player.cpp.o
In file included from /home/zhihui/librealsense/third-party/realsense-file/rosbag/rosbag_storage/src/bag_player.cpp:1:0:
/home/zhihui/librealsense/third-party/realsense-file/rosbag/rosbag_storage/include/rosbag/bag_player.h:81:42: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
BagPlayer(const std::string &filename) throw(BagException);
^~~~~
/home/zhihui/librealsense/third-party/realsense-file/rosbag/rosbag_storage/src/bag_player.cpp:8:48: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
BagPlayer::BagPlayer(const std::string &fname) throw(BagException) {
^~~~~
In file included from /home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/detail/maybe_include.hpp:18:0,
from /home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/detail/function_iterate.hpp:14,
from /home/zhihui/librealsense/third-party/realsense-file/boost/boost/preprocessor/iteration/detail/iter/forward1.hpp:52,
from /home/zhihui/librealsense/third-party/realsense-file/boost/boost/function.hpp:64,
from /home/zhihui/librealsense/third-party/realsense-file/rosbag/roscpp_traits/include/ros/message_event.h:42,
from /home/zhihui/librealsense/third-party/realsense-file/rosbag/rosbag_storage/include/rosbag/bag.h:50,
from /home/zhihui/librealsense/third-party/realsense-file/rosbag/rosbag_storage/include/rosbag/bag_player.h:40,
from /home/zhihui/librealsense/third-party/realsense-file/rosbag/rosbag_storage/src/bag_player.cpp:1:
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_template.hpp: In instantiation of ‘void boost::detail::function::basic_vtable1<R, T0>::assign_functor(FunctionObj, boost::detail::function::function_buffer&, mpl_::true_) const [with FunctionObj = rosbag::TopicQuery; R = bool; T0 = const rosbag::ConnectionInfo*; mpl_::true_ = mpl_::bool_<true>]’:
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_template.hpp:608:27: required from ‘bool boost::detail::function::basic_vtable1<R, T0>::assign_to(FunctionObj, boost::detail::function::function_buffer&, boost::detail::function::function_obj_tag) const [with FunctionObj = rosbag::TopicQuery; R = bool; T0 = const rosbag::ConnectionInfo*]’
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_template.hpp:498:27: required from ‘bool boost::detail::function::basic_vtable1<R, T0>::assign_to(F, boost::detail::function::function_buffer&) const [with F = rosbag::TopicQuery; R = bool; T0 = const rosbag::ConnectionInfo*]’
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_template.hpp:942:7: required from ‘void boost::function1<R, T1>::assign_to(Functor) [with Functor = rosbag::TopicQuery; R = bool; T0 = const rosbag::ConnectionInfo*]’
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_template.hpp:728:7: required from ‘boost::function1<R, T1>::function1(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = rosbag::TopicQuery; R = bool; T0 = const rosbag::ConnectionInfo*; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_template.hpp:1077:16: required from ‘boost::function<R(T0)>::function(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = rosbag::TopicQuery; R = bool; T0 = const rosbag::ConnectionInfo*; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
/home/zhihui/librealsense/third-party/realsense-file/rosbag/rosbag_storage/src/bag_player.cpp:50:60: required from here
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_template.hpp:572:11: warning: placement new constructing an object of type ‘rosbag::TopicQuery’ and size ‘24’ in a region of type ‘char’ and size ‘1’ [-Wplacement-new=]
new (reinterpret_cast<void*>(&functor.data)) FunctionObj(f);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/detail/prologue.hpp:17:0,
from /home/zhihui/librealsense/third-party/realsense-file/boost/boost/function.hpp:24,
from /home/zhihui/librealsense/third-party/realsense-file/rosbag/roscpp_traits/include/ros/message_event.h:42,
from /home/zhihui/librealsense/third-party/realsense-file/rosbag/rosbag_storage/include/rosbag/bag.h:50,
from /home/zhihui/librealsense/third-party/realsense-file/rosbag/rosbag_storage/include/rosbag/bag_player.h:40,
from /home/zhihui/librealsense/third-party/realsense-file/rosbag/rosbag_storage/src/bag_player.cpp:1:
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_base.hpp: In instantiation of ‘static void boost::detail::function::functor_manager_common<Functor>::manage_small(const boost::detail::function::function_buffer&, boost::detail::function::function_buffer&, boost::detail::function::functor_manager_operation_type) [with Functor = rosbag::TopicQuery]’:
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_base.hpp:364:56: required from ‘static void boost::detail::function::functor_manager<Functor>::manager(const boost::detail::function::function_buffer&, boost::detail::function::function_buffer&, boost::detail::function::functor_manager_operation_type, mpl_::true_) [with Functor = rosbag::TopicQuery; mpl_::true_ = mpl_::bool_<true>]’
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_base.hpp:412:18: required from ‘static void boost::detail::function::functor_manager<Functor>::manager(const boost::detail::function::function_buffer&, boost::detail::function::function_buffer&, boost::detail::function::functor_manager_operation_type, boost::detail::function::function_obj_tag) [with Functor = rosbag::TopicQuery]’
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_base.hpp:440:20: required from ‘static void boost::detail::function::functor_manager<Functor>::manage(const boost::detail::function::function_buffer&, boost::detail::function::function_buffer&, boost::detail::function::functor_manager_operation_type) [with Functor = rosbag::TopicQuery]’
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_template.hpp:940:13: required from ‘void boost::function1<R, T1>::assign_to(Functor) [with Functor = rosbag::TopicQuery; R = bool; T0 = const rosbag::ConnectionInfo*]’
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_template.hpp:728:7: required from ‘boost::function1<R, T1>::function1(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = rosbag::TopicQuery; R = bool; T0 = const rosbag::ConnectionInfo*; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_template.hpp:1077:16: required from ‘boost::function<R(T0)>::function(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = rosbag::TopicQuery; R = bool; T0 = const rosbag::ConnectionInfo*; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
/home/zhihui/librealsense/third-party/realsense-file/rosbag/rosbag_storage/src/bag_player.cpp:50:60: required from here
/home/zhihui/librealsense/third-party/realsense-file/boost/boost/function/function_base.hpp:318:13: warning: placement new constructing an object of type ‘boost::detail::function::functor_manager_common<rosbag::TopicQuery>::functor_type {
aka rosbag::TopicQuery}’ and size ‘24’ in a region of type ‘char’ and size ‘1’ [-Wplacement-new=]
new (reinterpret_cast<void*>(&out_buffer.data)) functor_type(*in_functor);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 1%] Building CXX object wrappers/python/CMakeFiles/pybackend2.dir/__/__/src/types.cpp.o
[ 2%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/rosbag_storage/src/buffer.cpp.o
[ 2%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/rosbag_storage/src/chunked_file.cpp.o
[ 2%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/rosbag_storage/src/lz4_stream.cpp.o
[ 2%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/rosbag_storage/src/message_instance.cpp.o
[ 3%] Building CXX object wrappers/python/CMakeFiles/pybackend2.dir/__/__/src/log.cpp.o
[ 4%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/rosbag_storage/src/query.cpp.o
[ 4%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/rosbag_storage/src/stream.cpp.o
[ 4%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/rosbag_storage/src/uncompressed_stream.cpp.o
[ 5%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/rosbag_storage/src/view.cpp.o
[ 5%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/roscpp_serialization/src/serialization.cpp.o
[ 5%] Building CXX object wrappers/python/CMakeFiles/pybackend2.dir/__/__/src/backend.cpp.o
[ 5%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/rostime/src/duration.cpp.o
[ 5%] Building CXX object wrappers/python/CMakeFiles/pybackend2.dir/__/__/src/libusb/interface-libusb.cpp.o
[ 5%] Building CXX object third-party/realsense-file/CMakeFiles/realsense-file.dir/rosbag/rostime/src/rate.cpp.o
In file included from /home/zhihui/librealsense/src/libusb/endpoint-libusb.h:8:0,
from /home/zhihui/librealsense/src/libusb/interface-libusb.h:6,
from /home/zhihui/librealsense/src/libusb/interface-libusb.cpp:4:
/usr/include/libusb-1.0/libusb.h:736:4: warning: ISO C++ forbids zero-size array ‘dev_capability_data’ [-Wpedantic]
[0] /* non-standard, but usually working code */
^
/usr/include/libusb-1.0/libusb.h:767:4: warning: ISO C++ forbids zero-size array ‘dev_capability’ [-Wpedantic]
[0] /* non-standard, but usually working code */
^
/usr/include/libusb-1.0/libusb.h:1263:4: warning: ISO C++ forbids zero-size array ‘iso_packet_desc’ [-Wpedantic]
[0] /* non-standard, but usually working code */
^
......
[ 94%] Building CXX object tools/realsense-viewer/CMakeFiles/realsense-viewer.dir/realsense-viewer.cpp.o
[ 94%] Building CXX object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/__/__/common/updates-model.cpp.o
/home/zhihui/librealsense/common/on-chip-calib.cpp: In member function ‘int rs2::tare_ground_truth_calculator::smooth_corner_locations(float&)’:
/home/zhihui/librealsense/common/on-chip-calib.cpp:2129:26: warning: operation on ‘((rs2::tare_ground_truth_calculator*)this)->rs2::tare_ground_truth_calculator::_corners_idx’ may be undefined [-Wsequence-point]
_corners_idx = ++_corners_idx % _frame_num;
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 94%] Building CXX object tools/realsense-viewer/CMakeFiles/realsense-viewer.dir/__/__/third-party/imgui/imgui.cpp.o
[ 94%] Building CXX object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/__/__/common/cah-model.cpp.o
[ 95%] Building CXX object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/__/__/common/sw-update/http-downloader.cpp.o
[ 96%] Building CXX object tools/realsense-viewer/CMakeFiles/realsense-viewer.dir/__/__/third-party/imgui/imgui_draw.cpp.o
[ 96%] Building CXX object tools/realsense-viewer/CMakeFiles/realsense-viewer.dir/__/__/third-party/imgui/imgui_impl_glfw.cpp.o
[ 96%] Building CXX object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/__/__/common/sw-update/dev-updates-profile.cpp.o
[ 96%] Building C object tools/realsense-viewer/CMakeFiles/realsense-viewer.dir/__/__/third-party/glad/glad.c.o
[ 96%] Building C object tools/realsense-viewer/CMakeFiles/realsense-viewer.dir/__/__/third-party/tinyfiledialogs/tinyfiledialogs.c.o
[ 97%] Building CXX object tools/realsense-viewer/CMakeFiles/realsense-viewer.dir/__/__/third-party/easyloggingpp/src/easylogging++.cc.o
[ 97%] Building CXX object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/__/__/common/sw-update/versions-db-manager.cpp.o
[ 97%] Linking CXX executable realsense-viewer
[ 98%] Building CXX object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/__/__/common/reflectivity/reflectivity.cpp.o
[ 98%] Built target realsense-viewer
[ 98%] Building CXX object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/rs-depth-quality.cpp.o
[ 98%] Building CXX object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/depth-quality-model.cpp.o
[ 98%] Building CXX object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/__/__/third-party/imgui/imgui.cpp.o
[ 99%] Building CXX object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/__/__/third-party/imgui/imgui_draw.cpp.o
[ 99%] Building CXX object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/__/__/third-party/imgui/imgui_impl_glfw.cpp.o
[ 99%] Building C object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/__/__/third-party/glad/glad.c.o
[100%] Building C object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/__/__/third-party/tinyfiledialogs/tinyfiledialogs.c.o
[100%] Building CXX object tools/depth-quality/CMakeFiles/rs-depth-quality.dir/__/__/third-party/easyloggingpp/src/easylogging++.cc.o
[100%] Linking CXX executable rs-depth-quality
[100%] Built target rs-depth-quality
zhihui@zhihui-desktop:~/librealsense/build$
5、开始安装
sudo make install
zhihui@zhihui-desktop:~/librealsense/build$ sudo make install
[sudo] password for zhihui:
[ 6%] Built target realsense-file
[ 43%] Built target realsense2
[ 47%] Built target pybackend2
[ 52%] Built target pyrealsense2
[ 56%] Built target realsense2-gl
[ 56%] Built target rs-hello-realsense
[ 56%] Built target rs-software-device
[ 56%] Built target rs-capture
[ 57%] Built target rs-callback
[ 58%] Built target rs-save-to-disk
[ 58%] Built target rs-multicam
[ 59%] Built target rs-pointcloud
[ 60%] Built target rs-align
[ 62%] Built target rs-align-advanced
[ 63%] Built target rs-sensor-control
[ 64%] Built target rs-measure
[ 64%] Built target rs-depth
[ 65%] Built target rs-color
[ 66%] Built target rs-distance
[ 67%] Built target rs-post-processing
[ 68%] Built target rs-record-playback
[ 69%] Built target rs-motion
[ 69%] Built target rs-gl
[ 69%] Built target rs-pose
[ 70%] Built target rs-pose-predict
[ 71%] Built target rs-pose-and-image
[ 72%] Built target rs-trajectory
[ 72%] Built target rs-ar-basic
[ 73%] Built target rs-ar-advanced
[ 74%] Built target rs-tracking-and-depth
[ 75%] Built target rs-hdr
[ 75%] Built target rs-convert
[ 75%] Built target rs-enumerate-devices
[ 76%] Built target rs-fw-logger
[ 77%] Built target rs-terminal
[ 78%] Built target rs-record
[ 79%] Built target rs-fw-update
[ 80%] Built target rs-data-collect
[ 88%] Built target realsense-viewer
[ 97%] Built target rs-depth-quality
[ 99%] Built target rs-rosbag-inspector
[100%] Built target rs-benchmark
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/librealsense2.so.2.41.0
-- Up-to-date: /usr/local/lib/librealsense2.so.2.41
-- Up-to-date: /usr/local/lib/librealsense2.so
-- Up-to-date: /usr/local/include/librealsense2
-- Up-to-date: /usr/local/include/librealsense2/hpp
-- Up-to-date: /usr/local/include/librealsense2/hpp/rs_types.hpp
-- Up-to-date: /usr/local/include/librealsense2/hpp/rs_context.hpp
-- Up-to-date: /usr/local/include/librealsense2/hpp/rs_processing.hpp
-- Up-to-date: /usr/local/include/librealsense2/hpp/rs_options.hpp
-- Up-to-date: /usr/local/include/librealsense2/hpp/rs_serializable_device.hpp
-- Up-to-date: /usr/local/include/librealsense2/hpp/rs_sensor.hpp
-- Up-to-date: /usr/local/include/librealsense2/hpp/rs_record_playback.hpp
-- Up-to-date: /usr/local/include/librealsense2/hpp/rs_export.hpp
-- Up-to-date: /usr/local/include/librealsense2/hpp/rs_frame.hpp
-- Up-to-date: /usr/local/include/librealsense2/hpp/rs_device.hpp
-- Up-to-date: /usr/local/include/librealsense2/hpp/rs_pipeline.hpp
-- Up-to-date: /usr/local/include/librealsense2/hpp/rs_internal.hpp
-- Up-to-date: /usr/local/include/librealsense2/rsutil.h
-- Up-to-date: /usr/local/include/librealsense2/rs_advanced_mode.h
-- Up-to-date: /usr/local/include/librealsense2/rs.h
-- Up-to-date: /usr/local/include/librealsense2/h
-- Up-to-date: /usr/local/include/librealsense2/h/rs_processing.h
-- Up-to-date: /usr/local/include/librealsense2/h/rs_frame.h
-- Up-to-date: /usr/local/include/librealsense2/h/rs_internal.h
-- Up-to-date: /usr/local/include/librealsense2/h/rs_types.h
-- Up-to-date: /usr/local/include/librealsense2/h/rs_sensor.h
-- Up-to-date: /usr/local/include/librealsense2/h/rs_pipeline.h
-- Up-to-date: /usr/local/include/librealsense2/h/rs_record_playback.h
-- Up-to-date: /usr/local/include/librealsense2/h/rs_device.h
-- Up-to-date: /usr/local/include/librealsense2/h/rs_option.h
-- Up-to-date: /usr/local/include/librealsense2/h/rs_context.h
-- Up-to-date: /usr/local/include/librealsense2/h/rs_advanced_mode_command.h
-- Up-to-date: /usr/local/include/librealsense2/h/rs_config.h
-- Up-to-date: /usr/local/include/librealsense2/rs_advanced_mode.hpp
-- Up-to-date: /usr/local/include/librealsense2/rs.hpp
-- Installing: /usr/local/lib/cmake/realsense2/realsense2Targets.cmake
-- Installing: /usr/local/lib/cmake/realsense2/realsense2Targets-noconfig.cmake
-- Installing: /usr/local/lib/cmake/realsense2/realsense2Config.cmake
-- Installing: /usr/local/lib/cmake/realsense2/realsense2ConfigVersion.cmake
-- Installing: /usr/local/lib/pkgconfig/realsense2.pc
-- Installing: /usr/local/lib/librealsense-file.a
-- Installing: /usr/local/lib/python3.6/pyrealsense2/pybackend2.cpython-36m-aarch64-linux-gnu.so.2.41.0
-- Installing: /usr/local/lib/python3.6/pyrealsense2/pybackend2.cpython-36m-aarch64-linux-gnu.so.2
-- Installing: /usr/local/lib/python3.6/pyrealsense2/pybackend2.cpython-36m-aarch64-linux-gnu.so
-- Installing: /usr/local/lib/python3.6/pyrealsense2/pyrealsense2.cpython-36m-aarch64-linux-gnu.so.2.41.0
-- Installing: /usr/local/lib/python3.6/pyrealsense2/pyrealsense2.cpython-36m-aarch64-linux-gnu.so.2.41
-- Installing: /usr/local/lib/python3.6/pyrealsense2/pyrealsense2.cpython-36m-aarch64-linux-gnu.so
-- Set runtime path of "/usr/local/lib/python3.6/pyrealsense2/pyrealsense2.cpython-36m-aarch64-linux-gnu.so.2.41.0" to ""
-- Installing: /usr/local/lib/cmake/pyrealsense2/pyrealsense2Targets.cmake
-- Installing: /usr/local/lib/cmake/pyrealsense2/pyrealsense2Targets-noconfig.cmake
-- Installing: /usr/local/lib/cmake/pyrealsense2/pyrealsense2Config.cmake
-- Installing: /usr/local/lib/cmake/pyrealsense2/pyrealsense2ConfigVersion.cmake
-- Installing: /usr/local/lib/librealsense2-gl.so.2.41.0
-- Up-to-date: /usr/local/lib/librealsense2-gl.so.2.41
-- Up-to-date: /usr/local/lib/librealsense2-gl.so
-- Set runtime path of "/usr/local/lib/librealsense2-gl.so.2.41.0" to ""
-- Up-to-date: /usr/local/include/librealsense2-gl/rs_processing_gl.h
-- Up-to-date: /usr/local/include/librealsense2-gl/rs_processing_gl.hpp
-- Installing: /usr/local/lib/cmake/realsense2-gl/realsense2-glTargets.cmake
-- Installing: /usr/local/lib/cmake/realsense2-gl/realsense2-glTargets-noconfig.cmake
-- Installing: /usr/local/lib/cmake/realsense2-gl/realsense2-glConfig.cmake
-- Installing: /usr/local/lib/cmake/realsense2-gl/realsense2-glConfigVersion.cmake
-- Installing: /usr/local/lib/pkgconfig/realsense2-gl.pc
-- Installing: /usr/local/bin/rs-hello-realsense
-- Set runtime path of "/usr/local/bin/rs-hello-realsense" to ""
-- Installing: /usr/local/bin/rs-software-device
-- Set runtime path of "/usr/local/bin/rs-software-device" to ""
-- Installing: /usr/local/bin/rs-capture
-- Set runtime path of "/usr/local/bin/rs-capture" to ""
-- Installing: /usr/local/bin/rs-callback
-- Set runtime path of "/usr/local/bin/rs-callback" to ""
-- Installing: /usr/local/bin/rs-save-to-disk
-- Set runtime path of "/usr/local/bin/rs-save-to-disk" to ""
-- Installing: /usr/local/bin/rs-multicam
-- Set runtime path of "/usr/local/bin/rs-multicam" to ""
-- Installing: /usr/local/bin/rs-pointcloud
-- Set runtime path of "/usr/local/bin/rs-pointcloud" to ""
-- Installing: /usr/local/bin/rs-align
-- Set runtime path of "/usr/local/bin/rs-align" to ""
-- Installing: /usr/local/bin/rs-align-advanced
-- Set runtime path of "/usr/local/bin/rs-align-advanced" to ""
-- Installing: /usr/local/bin/rs-sensor-control
-- Set runtime path of "/usr/local/bin/rs-sensor-control" to ""
-- Installing: /usr/local/bin/rs-measure
-- Set runtime path of "/usr/local/bin/rs-measure" to ""
-- Installing: /usr/local/bin/rs-depth
-- Set runtime path of "/usr/local/bin/rs-depth" to ""
-- Installing: /usr/local/bin/rs-color
-- Set runtime path of "/usr/local/bin/rs-color" to ""
-- Installing: /usr/local/bin/rs-distance
-- Set runtime path of "/usr/local/bin/rs-distance" to ""
-- Installing: /usr/local/bin/rs-post-processing
-- Set runtime path of "/usr/local/bin/rs-post-processing" to ""
-- Installing: /usr/local/bin/rs-record-playback
-- Set runtime path of "/usr/local/bin/rs-record-playback" to ""
-- Installing: /usr/local/bin/rs-motion
-- Set runtime path of "/usr/local/bin/rs-motion" to ""
-- Installing: /usr/local/bin/rs-gl
-- Set runtime path of "/usr/local/bin/rs-gl" to ""
-- Installing: /usr/local/bin/rs-pose
-- Set runtime path of "/usr/local/bin/rs-pose" to ""
-- Installing: /usr/local/bin/rs-pose-predict
-- Set runtime path of "/usr/local/bin/rs-pose-predict" to ""
-- Installing: /usr/local/bin/rs-pose-and-image
-- Set runtime path of "/usr/local/bin/rs-pose-and-image" to ""
-- Installing: /usr/local/bin/rs-trajectory
-- Set runtime path of "/usr/local/bin/rs-trajectory" to ""
-- Installing: /usr/local/bin/rs-ar-basic
-- Set runtime path of "/usr/local/bin/rs-ar-basic" to ""
-- Installing: /usr/local/bin/rs-ar-advanced
-- Set runtime path of "/usr/local/bin/rs-ar-advanced" to ""
-- Installing: /usr/local/bin/rs-tracking-and-depth
-- Set runtime path of "/usr/local/bin/rs-tracking-and-depth" to ""
-- Installing: /usr/local/bin/rs-hdr
-- Set runtime path of "/usr/local/bin/rs-hdr" to ""
-- Installing: /usr/local/bin/rs-convert
-- Set runtime path of "/usr/local/bin/rs-convert" to ""
-- Installing: /usr/local/bin/rs-enumerate-devices
-- Set runtime path of "/usr/local/bin/rs-enumerate-devices" to ""
-- Installing: /usr/local/bin/rs-fw-logger
-- Set runtime path of "/usr/local/bin/rs-fw-logger" to ""
-- Installing: /usr/local/bin/rs-terminal
-- Set runtime path of "/usr/local/bin/rs-terminal" to ""
-- Installing: /usr/local/bin/rs-record
-- Set runtime path of "/usr/local/bin/rs-record" to ""
-- Installing: /usr/local/bin/rs-fw-update
-- Set runtime path of "/usr/local/bin/rs-fw-update" to ""
-- Installing: /usr/local/bin/rs-data-collect
-- Set runtime path of "/usr/local/bin/rs-data-collect" to ""
-- Installing: /usr/local/bin/realsense-viewer
-- Set runtime path of "/usr/local/bin/realsense-viewer" to ""
-- Installing: /usr/local/bin/rs-depth-quality
-- Set runtime path of "/usr/local/bin/rs-depth-quality" to ""
-- Installing: /usr/local/bin/rs-rosbag-inspector
-- Set runtime path of "/usr/local/bin/rs-rosbag-inspector" to ""
-- Installing: /usr/local/bin/rs-benchmark
-- Set runtime path of "/usr/local/bin/rs-benchmark" to ""
zhihui@zhihui-desktop:~/librealsense/build$
编译完成之后,你会在:/usr/local/lib
下发现编译生成的librealsense2
动态库文件
zhihui@zhihui-desktop:/usr/local/lib$ ls
cmake librealsense2-gl.so librealsense2-gl.so.2.41.0 librealsense2.so.2.41 librealsense-file.a python2.7
libglfw3.a librealsense2-gl.so.2.41 librealsense2.so librealsense2.so.2.41.0 pkgconfig python3.6
zhihui@zhihui-desktop:/usr/local/lib$
同时在python3的库包存放位置/usr/local/lib/python3.6/pyrealsense2
,你也会看到生成的pyrealsense2
相关的动态库文件
zhihui@zhihui-desktop:/usr/local/lib/python3.6/pyrealsense2$ ls
pybackend2.cpython-36m-aarch64-linux-gnu.so pybackend2.cpython-36m-aarch64-linux-gnu.so.2.41.0 pyrealsense2.cpython-36m-aarch64-linux-gnu.so.2.41
pybackend2.cpython-36m-aarch64-linux-gnu.so.2 pyrealsense2.cpython-36m-aarch64-linux-gnu.so pyrealsense2.cpython-36m-aarch64-linux-gnu.so.2.41.0
zhihui@zhihui-desktop:/usr/local/lib/python3.6/pyrealsense2$ ^C
zhihui@zhihui-desktop:/usr/local/lib/python3.6/pyrealsense2$ ls
pybackend2.cpython-36m-aarch64-linux-gnu.so pybackend2.cpython-36m-aarch64-linux-gnu.so.2.41.0 pyrealsense2.cpython-36m-aarch64-linux-gnu.so.2.41
pybackend2.cpython-36m-aarch64-linux-gnu.so.2 pyrealsense2.cpython-36m-aarch64-linux-gnu.so pyrealsense2.cpython-36m-aarch64-linux-gnu.so.2.41.0
zhihui@zhihui-desktop:/usr/local/lib/python3.6/pyrealsense2$
但是,此时如果你在命令行中导入pyrealsense2
,虽然可以正确导入,但是并没有任何接口可以使用
zhihui@zhihui-desktop:~$ python3
Python 3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyrealsense2 as rs
>>> dir(rs)
['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>>
6、添加动态库相关环境变量
vim ~/.bashrc
export PYTHONPATH=$PYTHONPATH:/usr/local/lib:/usr/local/lib/python3.6/pyrealsense2
再次导入pyrealsense2
可以成功运行编译的库包
zhihui@zhihui-desktop:~$ python3
Python 3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyrealsense2 as rs
>>> dir(rs)
['BufData', 'D400', 'DEPTH', 'L500', 'SR300', 'STAEControl', 'STAFactor', 'STCensusRadius', 'STColorControl', 'STColorCorrection', 'STDepthControlGroup', 'STDepthTableControl', 'STHdad', 'STRauColorThresholdsControl', 'STRauSupportVectorControl', 'STRsm', 'STSloColorThresholdsControl', 'STSloPenaltyControl', 'T200', 'TRACKING', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '__version__', 'adjust_2D_point_to_boundary', 'align', 'any', 'any_intel', 'auto_calibrated_device', 'calibrated_sensor', 'calibration_status', 'calibration_type', 'camera_info', 'color_sensor', 'colorizer', 'composite_frame', 'config', 'context', 'debug_protocol', 'debug_stream_sensor', 'decimation_filter', 'depth_frame', 'depth_huffman_decoder', 'depth_sensor', 'depth_stereo_sensor', 'device', 'device_calibration', 'device_list', 'disparity_frame', 'disparity_transform', 'distortion', 'dsm_params', 'event_information', 'extension', 'extrinsics', 'filter', 'filter_interface', 'firmware_log_message', 'firmware_log_parsed_message', 'firmware_logger', 'fisheye_sensor', 'format', 'frame', 'frame_metadata_value', 'frame_queue', 'frame_source', 'hdr_merge', 'hole_filling_filter', 'intrinsics', 'is_pixel_in_line', 'log', 'log_message', 'log_severity', 'log_to_callback', 'log_to_console', 'log_to_file', 'max_usable_range_sensor', 'motion_device_intrinsic', 'motion_frame', 'motion_sensor', 'motion_stream', 'motion_stream_profile', 'next_pixel_in_line', 'non_intel', 'notification', 'notification_category', 'option', 'option_range', 'options', 'pipeline', 'pipeline_profile', 'pipeline_wrapper', 'playback', 'playback_status', 'pointcloud', 'points', 'pose', 'pose_frame', 'pose_sensor', 'pose_stream', 'pose_stream_profile', 'processing_block', 'product_line', 'quaternion', 'recorder', 'region_of_interest', 'roi_sensor', 'rs2_deproject_pixel_to_point', 'rs2_fov', 'rs2_project_color_pixel_to_depth_pixel', 'rs2_project_point_to_pixel', 'rs2_transform_point_to_point', 'rs400_advanced_mode', 'save_single_frameset', 'save_to_ply', 'sensor', 'sequence_id_filter', 'software_device', 'software_motion_frame', 'software_notification', 'software_pose_frame', 'software_sensor', 'software_video_frame', 'spatial_filter', 'stream', 'stream_profile', 'syncer', 'temporal_filter', 'terminal_parser', 'texture_coordinate', 'threshold_filter', 'timestamp_domain', 'tm2', 'units_transform', 'updatable', 'update_device', 'vector', 'vertex', 'video_frame', 'video_stream', 'video_stream_profile', 'wheel_odometer', 'yuy_decoder', 'zero_order_invalidation']
>>> rs.pipeline()
<pyrealsense2.pipeline object at 0x7f940d0420>
>>>
2 使用pyrealsense2获取Intel 的tof相机视频流用例
import pyrealsense2 as rs
import numpy as np
import cv2
# Configure depth and color streams
pipeline = rs.pipeline()
config = rs.config()
# config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
# config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)
# Start streaming
pipeline.start(config)
try:
while True:
# Wait for a coherent pair of frames: depth and color
frames = pipeline.wait_for_frames()
# 深度图
depth_frame = frames.get_depth_frame()
# 正常读取的视频流
color_frame = frames.get_color_frame()
if not depth_frame or not color_frame:
continue
# Convert images to numpy arrays
depth_image = np.asanyarray(depth_frame.get_data())
color_image = np.asanyarray(color_frame.get_data())
# print(f"depth_image shape: {depth_image.shape} color_image shape: {color_image.shape}")
print(f"depth_image value: {depth_image}") # 里面0值很多,还有很多1900左右的值 300mm 单位是毫米=30厘米=0.3米
# depth_image shape: (480, 640) color_image shape: (480, 640, 3)
# 深度图是单通道 颜色图是三通道的
# Apply colormap on depth image (image must be converted to 8-bit per pixel first)
# 在深度图像上应用colormap(图像必须先转换为每像素8位)
depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET)
# Stack both images horizontally
images = np.hstack((color_image, depth_colormap))
# Show images
cv2.namedWindow('RealSense', cv2.WINDOW_AUTOSIZE)
cv2.imshow('RealSense', images)
cv2.waitKey(1)
finally:
# Stop streaming
pipeline.stop()
zhihui@zhihui-desktop:/usr/local/bin$ ls
convert-caffe2-to-onnx jetson_config rs-align rs-capture rs-distance rs-hello-realsense rs-pose-and-image rs-save-to-disk
convert-onnx-to-caffe2 jetson_release rs-align-advanced rs-color rs-enumerate-devices rs-measure rs-pose-predict rs-sensor-control
cygdb jetson_swap rs-ar-advanced rs-convert rs-fw-logger rs-motion rs-post-processing rs-software-device
cython jtop rs-ar-basic rs-data-collect rs-fw-update rs-multicam rs-record rs-terminal
cythonize pasteurize rs-benchmark rs-depth rs-gl rs-pointcloud rs-record-playback rs-tracking-and-depth
futurize realsense-viewer rs-callback rs-depth-quality rs-hdr rs-pose rs-rosbag-inspector rs-trajectory
zhihui@zhihui-desktop:/usr/local/bin$
通过定时器实现视频流,用while循环获取视频流的方式,是第一帧获取完之后,立马去获取第二帧,这种方式会很消耗CPU资源,因此通过定时器获取视频流可以解决资源!