├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── LICENSE
├── README.md
├── buildLibrealsense.sh
├── installLibrealsense.sh
└── scripts
└── installDependencies.sh
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Issue report
3 | about: Create a report to help us improve
4 | title: "[BUG]"
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the issue**
11 | Please describe the issue
12 |
13 | **What version of L4T/JetPack**
14 | L4T/JetPack version:
15 |
16 | **Which Intel RealSense camera(s)**
17 | RealSense camera(s):
18 |
19 | **To Reproduce**
20 | Steps to reproduce the behavior:
21 | For example, what command line did you run?
22 |
23 | **Expected behavior**
24 | A clear and concise description of what you expected to happen.
25 |
26 | **Additional context**
27 | Add any other context about the problem here.
28 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: "[FEATURE REQUEST]"
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019-2021 JetsonHacksNano
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # installLibrealsense
2 | Build and install scripts for Intel's librealsense for the NVIDIA Jetson Developer Kits
3 |
4 | Original article on JetsonHacks: https://wp.me/p7ZgI9-34j
5 |
6 | The Intel® RealSense™ SDK is here: https://github.com/IntelRealSense/librealsense
7 | The SDK library name is librealsense. This is for version 2 of the library, which supports
8 | the D400 series depth cameras, T265 tracking camera, L515 lidar, and the SR300 depth camera.
9 |
10 | It is now possible on the NVIDIA Jetsons to do a simple install from a RealSense Debian repository
11 | (i.e. apt-get install). Previous versions of this repository require building librealsense from source, and (possibly) rebuilding the Linux kernel.
12 |
13 | The current recommendation from Intel is to use UVC for video input on the Jetson family. The
14 | UVC API in librealsense has been rewritten to better support this use case.
15 |
16 |
installLibrealsense.sh
17 | This script will install librealsense from the Intel Librealsense Debian Repository.
18 |
19 |
20 | ```
21 | $ ./installLibrealsense.sh
22 | ```
23 |
24 | Note: You do not have to patch modules and kernels.
25 |
26 |
buildLibrealsense.sh
27 | This script will build librealsense from source and install it on the system. Note: It is recommended to install from Debian repository as described above. However, if you need to compile from source, you will find this script useful.
28 |
29 |
30 | ```
31 | $ ./buildLibrealsense.sh [ -v | --version ] [ -j | -jobs ] [ -n | --no_cuda ]
32 | ```
33 |
34 | Where:
35 | * `` = Librealsense version. E.g. v2.49.0
36 | * `` = # of jobs to run concurrently when building. Defaults to 1 if the Jetson has <= 4GB memory
37 | * `` = Compile without CUDA support (by default, CUDA is on)
38 |
39 | The librealsense Github repository has good documentation for supporting more advanced modes for the RealSense sensors. Please see: [installation_jetson.md](https://github.com/IntelRealSense/librealsense/blob/master/doc/installation_jetson.md) The documentation covers different communication interfaces and how to explore different features, some of which may require recompiling kernel modules.
40 |
41 | Note: The build uses libuvc. You will not have to rebuild the kernel or modules in order to use this build.
42 |
43 | Notes
44 | If you use realsense-ros, make sure that you match the librealsense versions with the realsense-ros version requirement.
45 |
46 | ## Releases
47 |
48 | ### September, 2021
49 | * Release v1.1
50 | * Change release naming for this repository
51 | * Updated keyserver URL
52 | * Thank you Tomasz @tomek-I and Tommy @Tommyisr !
53 | * Enhanced buildLibrealsense script
54 | * Lookup latest version of librealsense from Github repository
55 | * Allow override via CLI argument ( -v | -version )
56 | * Allow user to specify number of build jobs ( -j | -jobs )
57 | * If Jetson has > 4GB use number of cores - 1 ; otherwise 1
58 | * Different parsing of comand line arguments using getopt
59 | * Tested on Jetson Nano, Jetson Xavier NX, L4T 32.6.1, JetPack 4.6
60 | * installLibrealsense.sh installed v2.49.0
61 | * Thank you Abdul @jazarie2 Matt @droter and @wegunterjrFIrefly for pull requests!
62 |
63 | January, 2020
64 |
65 | * Release vL4T32.3.1
66 | * Jetson Nano, Jetson TX1, Jetson TX2, Jetson AGX Xavier
67 | * L4T 32.3.1, JetPack 4.3, Kernel 4.9
68 | * librealsense version v2.31.0
69 |
70 |
71 | November, 2019
72 |
73 | * Initial release
74 | * Release vL4T32.2.1
75 | * Jetson Nano, Jetson TX1, Jetson TX2, Jetson AGX Xavier
76 | * L4T 32.2.1, JetPack 4.2.2, Kernel 4.9
77 | * librealsense version v2.30.0
78 |
79 |
--------------------------------------------------------------------------------
/buildLibrealsense.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Builds the Intel Realsense library librealsense on a Jetson Nano Development Kit
3 | # Copyright (c) 2016-21 Jetsonhacks
4 | # MIT License
5 |
6 | LIBREALSENSE_DIRECTORY=${HOME}/librealsense
7 | INSTALL_DIR=$PWD
8 | NVCC_PATH=/usr/local/cuda/bin/nvcc
9 |
10 | USE_CUDA=true
11 |
12 | function usage ()
13 | {
14 | echo "Usage: ./buildLibrealsense.sh [-n | -no_cuda] [-v | -version ] [-j | --jobs ] [-h | --help] "
15 | echo "-n | --no_cuda Build with no CUDA (Defaults to with CUDA)"
16 | echo "-v | --version Version of librealsense to build
17 | (defaults to latest release)"
18 | echo "-j | --jobs Number of concurrent jobs (Default 1 on <= 4GB RAM
19 | #of cores-1 otherwise)"
20 | echo "-h | --help This message"
21 | exit 2
22 | }
23 |
24 | PARSED_ARGUMENTS=$(getopt -a -n buildLibrealsense.sh -o nv:j:h --longoptions version:,no_cuda,jobs:,help -- "$@" )
25 | VALID_ARGUMENTS=$?
26 |
27 | if [ "$VALID_ARGUMENTS" != "0" ]; then
28 | echo ""
29 | usage
30 | fi
31 |
32 | eval set -- "$PARSED_ARGUMENTS"
33 |
34 | LIBREALSENSE_VERSION=""
35 | USE_CUDA=true
36 | NUM_PROCS=""
37 |
38 | while :
39 | do
40 | case "$1" in
41 | -n | --build_no_cuda) USE_CUDA=false ; shift ;;
42 | -v | --version ) LIBREALSENSE_VERSION="$2" ; shift 2 ;;
43 | -j | --jobs) NUM_PROCS="$2" ;
44 | shift 2 ;
45 | re_isanum='^[0-9]+$'
46 | if ! [[ $NUM_PROCS =~ $re_isanum ]] ; then
47 | echo "Number of jobs must be a positive, whole number"
48 | usage
49 | else
50 | if [ $NUM_PROCS -eq "0" ]; then
51 | echo "Number of jobs must be a positive, whole number"
52 | fi
53 | fi ;
54 | ;;
55 | -h | --help ) usage ; shift ;;
56 | # -- means the end of arguments
57 | --) shift; break ;;
58 | esac
59 | done
60 |
61 | # From lukechilds gist discussion: https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
62 | # We use wget instead of curl here
63 | # Sample usage:
64 | # VERSION_STRINGS=$(get_latest_release IntelRealSense/librealsense)
65 |
66 | function get_latest_release () {
67 | # redirect wget to standard out and grep out the tag_name
68 | wget -qO- https://api.github.com/repos/$1/releases/latest |
69 | grep -Po '"tag_name": "\K.*?(?=")'
70 | }
71 |
72 | if [[ $LIBREALSENSE_VERSION == "" ]] ; then
73 | echo "Getting latest librealsense version number"
74 | LIBREALSENSE_VERSION=$(get_latest_release IntelRealSense/librealsense)
75 | fi
76 |
77 | echo "Build with CUDA: "$USE_CUDA
78 | echo "Librealsense Version: $LIBREALSENSE_VERSION"
79 |
80 | red=`tput setaf 1`
81 | green=`tput setaf 2`
82 | reset=`tput sgr0`
83 | # e.g. echo "${red}The red tail hawk ${green}loves the green grass${reset}"
84 |
85 |
86 | echo ""
87 | echo "Please make sure that no RealSense cameras are currently attached"
88 | echo ""
89 | read -n 1 -s -r -p "Press any key to continue"
90 | echo ""
91 |
92 | if [ ! -d "$LIBREALSENSE_DIRECTORY" ] ; then
93 | # clone librealsense
94 | cd ${HOME}
95 | echo "${green}Cloning librealsense${reset}"
96 | git clone https://github.com/IntelRealSense/librealsense.git
97 | fi
98 |
99 | # Is the version of librealsense current enough?
100 | cd $LIBREALSENSE_DIRECTORY
101 | VERSION_TAG=$(git tag -l $LIBREALSENSE_VERSION)
102 | if [ ! $VERSION_TAG ] ; then
103 | echo ""
104 | tput setaf 1
105 | echo "==== librealsense Version Mismatch! ============="
106 | tput sgr0
107 | echo ""
108 | echo "The installed version of librealsense is not current enough for these scripts."
109 | echo "This script needs librealsense tag version: "$LIBREALSENSE_VERSION "but it is not available."
110 | echo "Please upgrade librealsense or remove the librealsense folder before attempting to install again."
111 | echo ""
112 | exit 1
113 | fi
114 |
115 | # Checkout version the last tested version of librealsense
116 | git checkout $LIBREALSENSE_VERSION
117 |
118 | # Install the dependencies
119 | cd $INSTALL_DIR
120 | sudo ./scripts/installDependencies.sh
121 |
122 | cd $LIBREALSENSE_DIRECTORY
123 | git checkout $LIBREALSENSE_VERSION
124 |
125 | # Now compile librealsense and install
126 | mkdir build
127 | cd build
128 | # Build examples, including graphical ones
129 | echo "${green}Configuring Make system${reset}"
130 | # Build with CUDA (default), the CUDA flag is USE_CUDA, ie -DUSE_CUDA=true
131 | export CUDACXX=$NVCC_PATH
132 | export PATH=${PATH}:/usr/local/cuda/bin
133 | export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib64
134 |
135 | /usr/bin/cmake ../ -DBUILD_EXAMPLES=true -DFORCE_LIBUVC=ON -DBUILD_WITH_CUDA="$USE_CUDA" -DCMAKE_BUILD_TYPE=release -DBUILD_PYTHON_BINDINGS=bool:true
136 |
137 | # The library will be installed in /usr/local/lib, header files in /usr/local/include
138 | # The demos, tutorials and tests will located in /usr/local/bin.
139 | echo "${green}Building librealsense, headers, tools and demos${reset}"
140 |
141 | # If user didn't set # of jobs and we have > 4GB memory then
142 | # set # of jobs to # of cores-1, otherwise 1
143 | if [[ $NUM_PROCS == "" ]] ; then
144 | TOTAL_MEMORY=$(free | awk '/Mem\:/ { print $2 }')
145 | if [ $TOTAL_MEMORY -gt 4051048 ] ; then
146 | NUM_CPU=$(nproc)
147 | NUM_PROCS=$(($NUM_CPU - 1))
148 | else
149 | NUM_PROCS=1
150 | fi
151 | fi
152 |
153 | time make -j$NUM_PROCS
154 | if [ $? -eq 0 ] ; then
155 | echo "librealsense make successful"
156 | else
157 | # Try to make again; Sometimes there are issues with the build
158 | # because of lack of resources or concurrency issues
159 | echo "librealsense did not build " >&2
160 | echo "Retrying ... "
161 | # Single thread this time
162 | time make
163 | if [ $? -eq 0 ] ; then
164 | echo "librealsense make successful"
165 | else
166 | # Try to make again
167 | echo "librealsense did not successfully build" >&2
168 | echo "Please fix issues and retry build"
169 | exit 1
170 | fi
171 | fi
172 | echo "${green}Installing librealsense, headers, tools and demos${reset}"
173 | sudo make install
174 |
175 | if grep -Fxq 'export PYTHONPATH=$PYTHONPATH:/usr/local/lib' ~/.bashrc ; then
176 | echo "PYTHONPATH already exists in .bashrc file"
177 | else
178 | echo 'export PYTHONPATH=$PYTHONPATH:/usr/local/lib' >> ~/.bashrc
179 | echo "PYTHONPATH added to ~/.bashrc. Pyhon wrapper is now available for importing pyrealsense2"
180 | fi
181 |
182 | cd $LIBREALSENSE_DIRECTORY
183 | echo "${green}Applying udev rules${reset}"
184 | # Copy over the udev rules so that camera can be run from user space
185 | sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/
186 | sudo udevadm control --reload-rules && udevadm trigger
187 |
188 | echo "${green}Library Installed${reset}"
189 | echo " "
190 | echo " -----------------------------------------"
191 | echo "The library is installed in /usr/local/lib"
192 | echo "The header files are in /usr/local/include"
193 | echo "The demos and tools are located in /usr/local/bin"
194 | echo " "
195 | echo " -----------------------------------------"
196 | echo " "
197 |
198 |
199 |
--------------------------------------------------------------------------------
/installLibrealsense.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Installs the Intel Realsense library librealsense on a Jetson Nano Development Kit
3 | # The installation is from a RealSense Debian repository
4 | # Copyright (c) 2016-21 Jetsonhacks
5 | # MIT License
6 | # https://github.com/IntelRealSense/librealsense/blob/master/doc/installation_jetson.md
7 | # Register the server's public key:
8 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key
9 |
10 | sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u
11 |
12 | sudo apt-get install apt-utils -y
13 | sudo apt-get install librealsense2-utils librealsense2-dev -y
14 |
--------------------------------------------------------------------------------
/scripts/installDependencies.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # installDependencies.sh
3 | # Install dependencies for the Intel Realsense library librealsense2 on a Jetson Nano Developer Kit
4 | # Copyright (c) 2016-19 Jetsonhacks
5 | # MIT License
6 | red=`tput setaf 1`
7 | green=`tput setaf 2`
8 | reset=`tput sgr0`
9 | # e.g. echo "${red}red text ${green}green text${reset}"
10 | echo "${green}Adding Universe repository and updating${reset}"
11 | apt-add-repository universe
12 | apt-get update
13 | echo "${green}Adding dependencies, graphics libraries and tools${reset}"
14 | apt-get install libssl-dev libusb-1.0-0-dev pkg-config -y
15 | # This is for ccmake
16 | apt-get install build-essential cmake cmake-curses-gui -y
17 |
18 | # Graphics libraries - for SDK's OpenGL-enabled examples
19 | apt-get install libgtk-3-dev libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev -y
20 |
21 | # QtCreator for development; not required for librealsense core library
22 | apt-get install qtcreator -y
23 |
24 | # Add Python 3 support
25 | apt-get install -y python3 python3-dev
26 |
27 |
--------------------------------------------------------------------------------