编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

jetson学习笔记2(jetson-utils)

wxchong 2024-07-21 07:27:11 开源技术 15 ℃ 0 评论

1.openc4.1安装官方教程

网址:https://pysource.com/2019/08/26/install-opencv-4-1-on-nvidia-jetson-nano/

We’re going to learn in this tutorial how to install Opencv 4.1 on the Nvidia Jetson Nano.

First of all we need to make sure that there is enough memory to proceed with the installation.
The Jetson Nano has 4GB of ram, and they’re not enough for some installations, and Opencv is one of them. To solve this problem
we need to add some extra memory, called “Swap memory” which will take place when all the RAM has been used.

We will see in this post how we can create and or extend the Swap memory and then how to install Opencv.

Add Swap Memory

By default the Ubuntu 18.04 distribution of Jetson Nano comes with 2 gb of Swap memory.

To increase it we need to open the terminal and type the line:

sudo apt-get install zram-config

The zram module, on the Jetson nano allocates by default 2gb of Swap memory, so now we’re going to extend the size to 4gb by changing the configuration file.

Just type on the terminal:

sudo gedit /usr/bin/init-zram-swapping

Replace the line:
mem=$(((totalmem / 2 / ${NRDEVICES}) * 1024))

with this line:

mem=$(((totalmem / ${NRDEVICES}) * 1024))

And then reboot.

Install Opencv 4.1

The installation of Opencv on the Jetson Nano takes around one hour.
We need to build Opencv from the source code, and we can do it by following these 7 steps below.

1. Updating the packages:

sudo apt update

sudo apt install -y build-essential cmake git libgtk2.0-dev pkg-config libswscale-dev libtbb2 libtbb-dev

sudo apt install -y python-dev python3-dev python-numpy python3-numpy

sudo apt install -y curl

2. Install video & image formats:

sudo apt install -y libjpeg-dev libpng-dev libtiff-dev libjasper-dev

sudo apt install -y libavcodec-dev libavformat-dev

sudo apt install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

sudo apt install -y libv4l-dev v4l-utils qv4l2 v4l2ucp libdc1394-22-dev

3. Download OpenCV & Contribs Modules:

curl -L https://github.com/opencv/opencv/archive/4.1.0.zip -o opencv-4.1.0.zip

curl -L https://github.com/opencv/opencv_contrib/archive/4.1.0.zip -o opencv_contrib-4.1.0.zip

4. Unzipping packages:

unzip opencv-4.1.0.zip

unzip opencv_contrib-4.1.0.zip

cd opencv-4.1.0/

5. Create directory:

mkdir release

cd release/

6. Build Opencv using Cmake:

cmake -D WITH_CUDA=ON \

-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.0/modules \

-D WITH_GSTREAMER=ON \

-D WITH_LIBV4L=ON \

-D BUILD_opencv_python2=ON \

-D BUILD_opencv_python3=ON \

-D BUILD_TESTS=OFF \

-D BUILD_PERF_TESTS=OFF \

-D BUILD_EXAMPLES=OFF \

-D CMAKE_BUILD_TYPE=RELEASE \

-D CMAKE_INSTALL_PREFIX=/usr/local ..

7. Compile the OpenCV with Contribs Modules:

make -j4

sudo make install

The installation is now completed.

安装视频网址:https://www.bilibili.com/video/BV1ZE411h7d5/?spm_id_from=333.788.top_right_bar_window_custom_collection.content.click&vd_source=e5a06e9ba8831331823fbeac99f6e0bc

2.GPIO硬件控制教程

Jetson GPIO库提供了四种给IO引脚编号的方法。前两个对应于RPi.GPIO库提供的模式,即BOARD和BCM,分别引用40引脚GPIO接头连接器的引脚号和Broadcom SoC GPIO编号。其余两种模式CVM和TEGRA_SOC使用字符串代替数字,而数字分别对应于CVM CVB连接器和Tegra SoC上的信号名称。

要指定您正在使用哪种模式(强制性),请使用以下函数调用:

GPIO.setmode(GPIO.BOARD)# or

GPIO.setmode(GPIO.BCM)# or

GPIO.setmode(GPIO.CVM)# or

GPIO.setmode(GPIO.TEGRA_SOC)

要检查已设置的模式,可以调用:

mode = GPIO.getmode()

该模式必须为GPIO.BOARD,GPIO.BCM,GPIO.CVM,GPIO.TEGRA_SOC或无。

3.linux文件夹复制命令:

同一文件夹下复制目录文件夹:

sudo cp -r jetson-gpio_back jetson-gpio

4.pip3安装命令

sudo apt-get install python3-pip

查看pip版本:

pip3 --version

3、安装 pip3 工具: sudo apt-get install python3-pip

4、进入jetson-gpio库文件夹,并安装库。 cd /opt/nvidia/jetson-gpio sudo python3 setup.py install

5、使用前,还需要创建一个 gpio 组,把你的当前的账号加到这个组,并赋予使用权限 sudo groupadd -f -r gpio sudo usermod -a -G gpio user_name

sudo cp /opt/nvidia/jetson-gpio/lib/python/Jetson/GPIO/99-gpio.rules /etc/udev/rules.d/ 为了使新规则生效,您需要通过运行以下命令重新引导或重新加载udev规则 sudo udevadm control --reload-rules && sudo udevadm trigger 注意: user_name 是你使用的用户名,比如说 jetson

5.安装gedit

首先,安装Gedit前,可以通过Terminal来检查一下是否已经安装了。可以使用命令“dpkg –l gedit”来检查。运行结果如果显示“gedit已安装”,则说明该系统已有Gedit,无需再次安装。

其次,可以使用Terminal来进行安装。可以使用命令“sudo apt install gedit”来安装Gedit。在安装Gedit前,需要更新软件源,可以使用命令“sudo apt update”来更新软件源,它会从Linux服务器上获取Gedit安装文件。

接着,需要输入用户的密码,让系统建立安装文件的连接,将Gedit的安装文件放入计算机中,并开始安装。若是安装过程中出现 “xxx没有安装升级”或“忽略一些软件包”的警告,则可点击“确定(OK)”按钮,继续进行Gedit的安装。

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表