jetson nano +RTSP+OpenCv+python入坑
1.系统配置
镜像我直接选择了亚博智能的64G已经配置好的镜像,要是重新烧写镜像需要win10或者Ubuntu 系统。
远程连接选择NoMachine,将DEB文件传输到Jetson内,在文件目录内命令:
sudo dpkg -i nomachine_7.0.208_1_arm64.deb
默认5分钟屏幕被锁住,需要密码解锁。为了避免频繁登录的麻烦,下面设置屏幕常亮:设置->锁屏->第一个选项选择Never,第二个Lock选择OFF,第三个把√取消。
换源:先备份原版的源,以防丢失。
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
编写文件:sudo gedit /etc/apt/sources.list
替换成如下
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
最后再更新下源
sudo apt-get update
最好别upgrade 用到再更新一样 太费事了
2.串口权限
在使用jetson nano进行串口通信的时候,发现串口一直无法打开,而且在调试过程中发现,给jetson nano发送数据时,jetson nano会自动回复一些数据。直接修改权限也无法打开,后来发现了问题,jetson nano系统本身有服务已经占用了ttyTHS1的串口,所以首先要暂停这个服务,然后再修改权限。
sudo lsof | grep ttyTHS1 # 发现一直占用该串口的服务进程是: nvgetty
systemctl stop nvgetty # 停止服务
systemctl disable nvgetty # 取消服务
开启串口权限,注意这个权限关机后就也被关闭,下次需要重新开启
sudo chmod 777 /dev/ttyTHS1
sudo apt-get install python-serial #安装所需的串口包
#安装modbus_tk包(python2装不了)
3.python和opencv环境
经过实验 python3.6.9【GCC8.4.0】和opencv4.5.2是相互匹配的。首先要搞清楚自己的pip和pip2和pip3对应的是python的那个版本 输入 pip3 -V 得知我的pip3 是对应python3的 那就执行 pip3 install opencv-python(注意是pip3)最好先更新下pip 否则有可能会因为PIP版本问题报错 /usr/bin/python3 -m pip install --upgrade pip #更新pip
last 备注
ret, frame = cap.read()
cap.read()是返回两个参数的
imshow函数调用有问题。cv2.imshow() 第一个参数为一个路径,所以直接命名为’frame’系统是找不到的。因此,可以修改为:cv2.imshow(’./frame’,frame)
调用完cap别忘了设置一下
cap.set(3, 480)