Tag Archives | Python

MatPltLib, OpenCV, Numpy, Visual Studio IDE, & Python

There are numerous configuration requirements involved in the setup and operation of the Jetson unit to produce relevant AI related projects. To support meaningful project activity, these are the steps to go through. Much of this effort

  • Install and update Linux
  • Install Visual Studio Code IDE
  • Install Python 3 using VS Code IDE
  • Install Code Interpreter
  • Install and update openCV library for AI applications
  • Install Numpy library for numerical function support
  • Install MatPltLib to plot mathematical operations and arrays

Upon completion of the setup walk-through, the short initialization program is necessary to get the camera operating. This initialization code adds libraries and configures the camera with settings unique to its resolution limits or parameters.

Rear port view of Jetson Nano prepared for updates.
Front view of Jetson with RPi camera module. It is also possible to run a USB webcam as well.
Visual Studio Code Integrated Development Environment (IDE). A host environment to support code languages such as Python.
Python 3 installation, confirmation to indicate version and readiness. After installation it is necessary to install the interpreter that runs beneath Python.
Once MatPltLib and Numpy is installed, sine and cosine functions are run as separate plots graphed. Or linear data is run as x and y array variables from memory. Simply to test and observe the numerical operation support along with the plotting utility.
Once openCV is installed and updated from the Linux terminal, set up and configuration is required to begin operating the Jetson unit and camera to support tracking and overlay for objection detection and computation.
Installation command and activity to install openCV. To update openCV it is necessary to remove the latest installed package version using the sudo apt-get remove python3-openCV.

Python Function Review for Jetson Nano Projects Pt.2

A separate walk through of how the prior session involved arrays and conditional loops is completed here only this time in headless mode. The objective of this session was to extend the function by assembling the logic and method by which grades are collected by user input and averaged for display as an output to a user. The screen captures below indicate the specific code and Python executable. The video provides for a more complete view of the session.

Python 3 code written in the Linux nano utility. A common old-school text editor to produce the code for Python to run the program.
Operating results of the Average Grades program written to collect, average, and display grades.
Video walk through to indicate both the code and executable.

Python Function Review for Jetson Nano Projects Pt.1

It is sometimes necessary to hash-out a range of code functions to prepare for projects that are active and would likely require efficient origination and debugging. To get to project completion in the shortest period of time, that corresponds to what you wish to accomplish, having clarity about syntactical operation that corresponds to the language in use ends of saving quite a bit of time. Normally, fluency in a specific language generally involves continued and active use within a programming environment. Otherwise, it is expected that language familiarity or proficiency becomes rusty.

The purpose of this posting is merely to introduce and review Python iterative functions. The IF statement, While, and For to include Arrays are common structural program elements involved in projects around SBC technologies, or in this case the NVIDIA Jetson Nano. In this case, a simple program is set up to indicate the syntax written in the Linux nano utility launched from an Ubuntu terminal window. First the code is written for each iterative program type and there after it is executed to demonstrate expected results.

If Statement with conditional operators based upon a user entered number.
Executed program instructions to operate the program and obtain results.
If Statement with conditional operators based upon a user entered number. A modified version of the basic IF Statement program to indicate Even or Odd condition of a computed result.
Executed program instructions to operate the program and obtain positive or negative results.
An auto increment method of sequential count between a range of numbers. Using the For Statement to hold condition true and display to screen with appropriate formatting until finished.
All three types of numerical and sequential computation using the For Statement to demonstrate the range, arrange, and linspace functions of Python.
The While Statement that makes use of a float data type input to obtain a maximum count number. Incremented count occurs within the While loop with the displayed number appropriately formatted until the final number is reached.
Demonstrated operation of program to indicate results of While Statement. Where operation counts by an increment of 1 and remains in a loop until completion and exit from that loop.
Using a For Statement to demonstrate the function and use of Arrays. Code defines the parameters of two arrays that includes one for grade entries and the other for displayed results.
The For loop statement to accept user inputs and thereafter display all results accordingly.

Jetson Nano Headless Setup and Operation

As a matter of convenience, it is better to operate the Jetson Nano without a dedicated keyboard, mouse, and monitor. The ability to log into Jetson without a concern of external connectivity is a capability necessary for the ease of development associate with program development involving AI related libraries and navigation through Linux without Ubuntu inhibiting matters.

To get connected to the Jetson, it is necessary to download, install, and configure a PuTTY for SSH client utility to get access. It is necessary to get the IP address of the Jetson on the local network through the ifconfig command prior to changing over to the headless setup.

Set Up of PuTTY Utility For Headless Login

Once connected and authenticated, a prompt follows to confirm headless access over WiFi or CAT-5/6.

Login Confirmation Prompt

To run a Python program, the nano editor program remotePy.py file is written to include simple code as given in this example.

Experimental Test Python Program Using Nano Editor

With all prior updates and the installation of Nano, the program execution of python3 remotePy.py returns the “Remote Operation Successful” message to indicate success.

Execution of Python Program to Confirm Operation