一、安装opencv:

Linux version 4.9.140-tegra (buildbrain@mobile-u64-3357)系统安装opencv-python

--1、2步是安装相关依赖包

1、sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

2、python3 -m pip install scikit-build -i https://pypi.tuna.tsinghua.edu.cn/simple

3、python3 -m pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple

 

二、ubuntu配置root用户密码:

1、先用安装时候的用户登录进入系统

2、输入:sudo passwd  按回车

3、输入新密码,重复输入密码,最后提示passwd:password updated sucessfully

此时已完成root密码的设置

4、输入:su root

切换用户到root试试.......

 

三、ubuntu报错:There are no enabled repos.

Run "yum repolist all" to see the repos you have.

You can enable repos with yum-config-manager --enable <repo>

一般来说著名的linux系统基本上分两大类:

1 RedHat系列:Redhat、Centos、Fedora等

2 Debian系列:Debian、Ubuntu等

RedHat 系列:

1 常见的安装包格式 rpm 包,安装rpm包的命令是 “rpm -参数”

2 包管理工具 yum

3 支持tar包

Debian系列

1 常见的安装包格式 deb 包,安装deb包的命令是 “dpkg -参数”

2 包管理工具 apt-get

3 支持tar包

所以你Ubuntu不该用yum 该用apt-get

yum -y install lrzsz

apt-get install lrzsz

 

四、解压缩报错:Cannot change ownership to uid 1000, gid 100: Operation not permitted

解决办法:

把文件复制到/home文件夹中再进行解压成功。原因不明。

  1. 操作摄像头:
  • linux下:

Jetson TX2自带有一个板载摄像头,当然也可以在TX2上连接usb摄像头和csi摄像头。

打开板载摄像头

    1)方法一:视屏分辨率预览

        nvgstcapture-1.0 --prev-res=3

    2)方法二:指定分辨率预览

        nvgstcapture-1.0 --cus-prev-res=1280x720

        命令行输入“q”退出,输入“j”图片将保存在当前目录下。

    3)python-opencv调用板载摄像头(一定要安装gstreamer这个依赖)

cap = cv2.VideoCapture("nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink")

  • 外接USB摄像头

VideoCapture cap(1) ,这个亲测可用

VideoCapture cap(2)......

读取板上的摄像头

VideoCapture cap("nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720,format=(string)I420, framerate=(fraction)24/1 ! nvvidconv flip-method=2 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink");

 

  • windows下:

cap = cv2.VideoCapture(0)可直接调用自带摄像头;

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐