Unlocking the Potential: An Introduction to Jetson Nano

Ankit Jha
7 min readApr 14, 2024

--

In this article I will introduce Jetson Nano and dive deep into a small project for the Jetson Enthusiasts, This will be a very introductory article for the readers to know what exactly are Jetson Devices and how they are very useful in Embedded as well as AI applications

In this article we will cover these areas-:

  1. What is Jetson Nano?
  2. Linux Fundamentals for working with Jetson Nano
  3. Board Bring up
  4. Getting started with programming on Jetson Nano
  5. Working with cameras CSI and Web camera

What is Jetson Nano?

The Jetson Nano is a small, powerful computer developed by NVIDIA, designed specifically for AI and robotics applications. The Jetson platform includes a variety of Jetson modules with NVIDIA JetPack SDK.

Each Jetson module is a computing system packaged as a plug-in unit (a System on Module (SOM)), and NVIDIA offers a variety of Jetson modules with different capabilities. Despite its high computational power, the Jetson Nano is designed to be energy-efficient. Its low power consumption makes it suitable for battery-powered devices and edge computing deployments where energy efficiency is crucial.

NVIDIA provides comprehensive software support for the Jetson Nano, including the JetPack SDK, which includes libraries, APIs, and tools for AI development. The availability of pre-trained models, sample projects, and tutorials further simplifies the development process and accelerates time-to-market for AI applications.

Jetson Nano also comes with carrier board where one can have access to multiple CSI, SATA slots. It will be for the use case where one require multiple cameras connected to the same Jetson Device or the one where having multiple SATA cables solves your problem, identify your use case and choose the device of your choice.

Linux Fundamentals for working with Jetson Nano

The Jetson Nano, like many embedded systems and single-board computers, operates on a Linux-based operating system. Understanding the fundamentals of Linux is essential for effectively utilizing the Jetson Nano’s capabilities.

Commands and Keyboard shortcuts for working efficiently working in Linux-:

  • Open Terminal: Ctrl + Alt + T
  • List files and directories.
ls #List files and directories in the current directory
ls -a #List all files, including hidden ones
  • Change directory.
cd # Change to the user's home directory
  • Create, copy, remove, move, and find directories
mkdir new_dir # Create a directory named "new_dir" in the current directory
cp file1 file2 # Copy "file1" to "file2" in the current directory
mv file1 new_file # Rename "file1" to "new_file"
rm file1 # Remove "file1"
touch new_file.txt # Create an empty file named "new_file.txt"
find /path -name "*.txt" # Find all files with a .txt extension in the specified directory
  • File Management
cat file.txt # Display the content of "file.txt" in the terminal
diff file1.txt file2.txt # Compare the contents of "file1.txt" and "file2.txt" and display the differences
vim file.txt # vim editor command you have to first install vim to use this command
  • Process Management
top # Display a dynamic, real-time overview of system processes
htop # htop displays a color-coded list of processes, along with various system metrics at the top of the screen. But for this you have to install htop by using "sudo apt install htop"
kill PID # Terminate the process with the specified process ID (PID)

Board Bring up

Board bring-up, while an essential step in harnessing the power of embedded systems like the Jetson Nano, can be a daunting prospect, especially for those new to this realm.

Below I’m giving an example from one of the Nvidia docs about how to bring up the board when you intially got hands on it.

Here is the link to Nvidia docs Linux version 32.6.1

This Linux version is compatible with Jetson Nano but some higher version is compatible with other Jetson Devices like Orin Nano, Xavier NX, AGX Xavier

Link to Archived Documentations, here you can find all the archived documentation of all the Jetson Linux Releases and Jetpack version, you can Flash the Linux and Jetpack SDK of your choice by reading documentation.

You can try some other Linux version also by flashing it, if some features are not available in your current version. If you are facing some issues in board bring up the best go to place is Nvidia Developer forum, you can ask your problem and will get reply within a short span of time. Try to follow instructions as it is according to the Nvidia docs and you will be good to go.

Remember while setting up Jetson Devices you may not succeed in the first try you have to debug, watch tutorials, read blogs, delve deep into documentations but the knowledge gained will be an amazing experience.

Link to Developer forum

Getting started with programming in Jetson Nano

Before diving into writing your first program you will also have to make sure that your Jetson Device is connected to internet there are alot of ways to achieve this, and the one that will be best for you depends on your usecase. If you are planning to achieve this using Ethernet cable you can follow this Link.

Let’s dive into writing our first program in Jetson Nano.

Before writing our first program, it’s crucial to ensure that your system is up to date with the latest software packages.

sudo apt update
sudo apt upgrade

We will use vim as our code editor to write our first program in Jetson Nano, you can use other code editor also like nano.

Installing vim

sudo apt install vim

Creating file using vim-:

  • Open a terminal window on your Jetson Nano using Ctrl + Alt + T
  • Type vim followed by the file name that you want for your program.
vim factorial.py
  • Enter insert mode by pressing ‘i’
  • Press Esc to go out of insert mode
  • Press :w to save the file
  • Press :wq to quit with saving and :q to quit without saving

We will write a small program to find the factorial of a number

def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)

num = int(input("Hey welcome!, Enter a number: "))
print("Factorial of", num, "is", factorial(num))
  • To run the file type python factorial.py in the terminal and press Enter.

Congratulations you have successfully written your first program on Jetson Nano!

Working with cameras CSI and Web camera

In today’s world of artificial intelligence, research fields like object detection, face detection etc, rely heavily on image data. When embarking on deep learning applications with the Jetson board, one often needs to create custom datasets for specific use cases. Two popular options for capturing images on the Jetson board are CSI (Camera Serial Interface) cameras and web cameras.

This is a very good documentation that can help Jetson users to get started on working with cameras.

https://developer.nvidia.com/embedded/learn/tutorials/first-picture-csi-usb-camera

You can get started with cameras of your choice.

For checking whether cameras are connected to your Jetson Nano you can run on the terminal

ls /dev/video* # This will output all the mounted cameras to the Jetson Nano

You can also check if nvgstcapture is present in your system or not, for that to check you can run the following in the terminal

nvgstcapture-1.0 # This will open the camera with sensor id 0

If nvgstcapture capture is not present in your current Jetson Linux Version or Jet Pack, then may be you have to Flash a lower or higher version again, another good idea can be to post your problem in Nvidia Developer forum. Nvidia Developers forum is quite an active community for Jetson users.

Link to Developer forum

For using web camera you can use the following command-:

nvgstcapture-1.0 --camsrc=0 --cap-dev-node=<N> (where N is the /dev/videoN Node)

All these commands are officially in the nvidia docs.

Now Let’s do a small project to start the web cam using Python and OpenCV, instead of nvgstcapture command.

Nvidia Jetson OS comes with a preinstalled OpenCV but if it is not then you can install OpenCV using the following command-:

sudo apt-get install libopencv-dev
  • Create vim file web_cam.py
  • Use the following code to run your web camera attached to the Jetson Nano with sensor id 0.
import cv2

def capture_frames(device_id, output_filename):
cap = cv2.VideoCapture(device_id)

# Check if the video capture device is opened successfully
if cap is None or not cap.isOpened():
print("Error: Could not open video capture device")
if cap is not None:
cap.release()
return False

try:
ret, frame = cap.read()
if ret:
ret2 = cv2.imwrite(output_filename, frame)
if not ret2:
print("Error: Failed to write frame to file")
return False
else:
print("Frame saved successfully")
return True
except Exception as e:
print("Error:", e)
return False

# Release the video capture device
cap.release()
return False

# Example usage
device_id = 0 # Change the device ID if necessary
output_filename = "frame.jpg" # Change the output filename as needed

if capture_frames(device_id, output_filename):
print("Frame captured and saved successfully")
else:
print("Failed to capture frame")

You can change the device id for the id where your web cam is mounted to the Jetson Nano.

Thank you for reading this article till here. I am planing to write more such posts as I delve deeper in the world of AI and share my knowledge as much as I can in the journey.

Happy coding 🙌

--

--