写这一篇文章主要是做一个简单的笔记,笔记任然有待完善,先做一个简单的记录。
1. tx2板子中自带python2.7以及python3.5的环境,但是需要安装pip
Install pip and virtualenv for Ubuntu 16.04LTS Maverick and newer,输入下面命令:
sudo apt-get install python-pip python-dev build-essential
sudo pip install --upgrade pip
sudo pip install --upgrade virtualenv
也可以通过以下方式安装:
For Python 3 :pip3
sudo apt-get install python3-pip
For Python 2 :pip
sudo apt-get install python-pip
2. pip安装完成之后可以修改pip源
临时使用:
可以在使用pip的时候加参数 -i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gevent
,这样就会从清华这边的镜像去安装 gevent 库。
阿里源地址为:
https://mirrors.aliyun.com/pypi/simple
永久使用:
linux下,修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna(没有就添加),内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
3. 使用pip安装有关的依赖包
可以使用以下几种方式来安装:xxx为包名,如 keras;
sudo pip install xxx
sudo pip install --extra-index-url=https://developer.download.nvidia.com/compute/redist/jp33 xxx
sudo apt-get install python-xxx
注意以下几个包的安装(我目前碰到的比较头疼的):
首先安装支持包:
sudo apt-get install libjpeg-dev libfreetype6-dev zlib1g-dev libpng12-dev
之后:
sudo pip install pillow
sudo pip install --extra-index-url=https://developer.download.nvidia.com/compute/redist/jp33 tensorflow-gpu
tensorflow-nvJetson
Jetson tx2的tensorflow keras环境搭建
之后跑tensorflow的代码可能会出现一些版本不兼容的问题,需要修改tensorflow的模型等。这个就随机应变了。兵来将挡 …
1. 修改本地IP地址,以及配置DNS(需要将本地IP修改成和)
sudo vim /etc/network/interfaces
加入以下内容:
auto eth0 # 设置自动启动eth0接口
iface eth0 inet static # 设置为静态ip
address 192.168.10.58 # ip地址
netmask 255.255.255.0 # 子网掩码
gateway 192.168.10.1 # 默认网关
dns-nameservers 8.8.8.8 114.114.114.114 # 配置多个DNS
其他:
sudo vim /etc/resolv.conf # DNS有关配置,开机重启之后就会清空
如果网络无法启动或不稳定,可尝试如下操作:
sudo gedit /etc/NetworkManager/NetworkManager.conf
将 managed=false 设置成 managed=true
2. python读取rtsp视频流demo
import cv2
capture = cv2.VideoCapture("rtsp://admin:[email protected]/cam/realmonitor?channel=1&subtype=0") # 换成你的摄像头的IP地址
while True:
ret, frame = capture.read()
cv2.imshow("frame", frame)
if 0xff & cv2.waitKey(1):
break
cv2.destroyAllWindows()
3. C++读取rtsp视频流demo
#include "opencv2/opencv.hpp"
#include
int main()
{
std::string str = "rtsp://admin:[email protected]/cam/realmonitor?channel=1&subtype=0";
// cv::VideoCapture cap("rtsp://admin:[email protected]:554/h264/ch1/main/av_stream");
cv::VideoCapture cap(str);
cv::Mat img;
cv::namedWindow("test", CV_WINDOW_NORMAL);
cv::setWindowProperty("test", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
while(1)
{
cap >> img;
cv::imshow("test", img);
if(27 == cv::waitKey(1))
break;
}
return 0;
}
1. python读取usb摄像头demo
import cv2
capture = cv2.VideoCapture(0) # 0 为默认摄像头,可以根据自己接的摄像头接口进行修改
while True:
ret, frame = capture.read()
cv2.imshow("frame", frame)
if 0xff & cv2.waitKey(1):
break
cv2.destroyAllWindows()
2. C++读取usb摄像头demo
#include
#include
using namespace cv;
using namespace std;
int main( )
{
//【1】从摄像头读入视频
VideoCapture capture(0);
//【2】循环显示每一帧
int j=0;
capture.set(CV_CAP_PROP_FRAME_WIDTH, 1080);
capture.set(CV_CAP_PROP_FRAME_HEIGHT,720);
while(1&&(j<100))
{ clock_t start,finish;
start=clock();
j++;
Mat frame; //定义一个Mat变量,用于存储每一帧的图像
capture>>frame; //读取当前帧
// imshow("读取视频",frame); //显示当前帧
cout<<frame.size()<<endl;
finish=clock();
cout << finish-start << "/" << CLOCKS_PER_SEC << " (s) "<< endl;
waitKey(1); //延时30ms
}
return 0;
}
C++ 代码编译方法:
build.sh
sudo g++ -o capture -I/usr/include -O3 -Wall testmain.cpp -L /usr/lib -lopencv_core -lopencv_imgproc -lopencv_flann -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_objdetect -lopencv_stitching -lopencv_videoio
build2.sh
sudo g++ -o capture2 -I ../opencv3.4/include -O3 -Wall testmain.cpp -L ../opencv3.4/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_video -lopencv_videoio -lopencv_imgcodecs