一、安装ubuntu
1、下载ubuntu镜像文件
2、制作启动光盘
如果是windows操作系统:插入空白dvd光盘,在iso文件上右键,选择“刻录光盘映像”
参考windows7中把ISO文件轻松刻录成光盘的方法(图文教程)
如果是ubuntu系统:Ubuntu14.04系统下,如何将.iso文件刻录到CD/DVD光盘
3、安装
二、搜狗输入法安装
1、参考Ubuntu 16.04 LTS安装sogou输入法详解
注意:fcitx configure未出现sogou输入法,需要自己点击左下方+号添加并且需要把复选框only show current language去掉,否则无法找到sougou
2、如果提示缺少依赖包:参考Ubuntu16.04上安装搜狗输入法
注意:依赖包要同时安装,不能分开安装
3、使用vim时sogou无法控制,关闭sogou输入法
system settings---language support : Keyboard input method system 把fctix改为IBus
4、使用sogou输入法时
system settings---language support : Keyboard input method system 把IBus 改为fctix
5、输入中文时,若候选栏显示英文乱码、无法显示中文,可按如下方式处理:
terminal下:
cd ~/.config
rm -rf SogouPY* sogou*
然后注销重新登录即可。
三、opencv安装:
1、下载
放到home下并解压
其他版本下载
2、按以下命令安装,
参考链接基于ubuntu16.04系统下OpenCV源码安装及无法import cv2
# step 1 # 安装依赖 (太多了,自己相应替换)
sudo apt-get install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22libdc1394-22-dev libjpeg-dev libpng12-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip
sudo apt-get install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22libdc1394-22-dev libjpeg-dev libpng12-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip --fix-missing# step
# step 2# 编译
cd opencv-3.0.0-alpha
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
# step 3#安装
make #较慢
sudo make install
# step 4# 安装完成,进行整理
sudo /bin/bash -c'echo "/usr/local/lib" > /etc/ld.so.conf./opencv.conf'
sudo ldconfig
sudo apt-get update
四、测试
1、python
python2下
import cv2 #没错
python3下 import cv2 #出错
因为你是python2环境下的opencv,并不是python3环境下的,每个python版本的工具包都是独立的,需要分别安装
2、常用python命令
python --version #查看当前python版本
ls /usr/bin/python* #查看当前已安装的python版本
查看python所在路径:
which python //查看Python2.7所在的文件路径
which python3.6 //查看python3.6所在的文件路径
五、python3下安装opencv
0、下载
Ubuntu下OpenCV编程[1]-下载并安装测试OpenCV库
wget https://github.com/opencv/opencv/archive/3.3.0.tar.gz
tar -zxvf 3.3.0.tar.gz
cd opencv-3.3.0/
mkdir build
cd build
腾讯云上用的build文件夹,自己笔记本用的build3
1、安装依赖(其中安装numpy是个难点):
sudo apt-get update
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install python3-setuptools python3-dev
sudo easy_install3 pip
pip3 install numpy
sudo apt-get install cmake git libgtk2.0-dev
sudo apt install python3-dev libpython3.5-dev python3-numpy
2、编译opencv:
进入opencv源码文件
$ cd ~/opencv
$ mkdir build3
$ cd build3
$cmake -D CMAKE_BUILD_TYPE=RELEASE -D PYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 -D BUILD_opencv_python3=ON -D BUILD_opencv_python2=OFF -D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D PYTHON3_EXCUTABLE=/usr/bin/python3 -D PYTHON3_INCLUDE_DIR=/usr/include/python3.5m -D PYTHON3_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so -D PYTHON_NUMPY_PATH=/usr/local/lib/python3.5/dist-packages ..
问题1:ippicv_2017u3_lnx_intel64_general_20170822.tgz无法下载
源码编译opencv卡在IPPICV: Download: ippicv_2017u3_lnx_intel64_general_20170822.tgz解决办法
问题2:make: *** No targets specified and no makefile found. Stop.解决方法
3、make -j2
4、sudo make install
sudo /bin/bash -c'echo "/usr/local/lib" > /etc/ld.so.conf./opencv.conf'
sudo ldconfig
sudo apt-get update
5、测试
python3下 import cv2 ok
六、使用opencv
1、参考
2、在home下新建文件夹opencvtest,在此文件夹下新建test1.py
内容如下:
import cv2
#import sys
#cascPath = sys.argv[1]
cascPath = '/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml'
#Create the haar
faceCascade = cv2.CascadeClassifier(cascPath)
#Get images from the video
video_capture = cv2.VideoCapture(0)
while True:
# Capture frame-by-frame
ret, frame = video_capture.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.1,
minNeighbors=5,
minSize=(30, 30),
flags=cv2.CASCADE_SCALE_IMAGE
)
# Draw a rectangle around the faces
for (x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
# Display the resulting frame
cv2.imshow('Video', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything is done, release the capture
video_capture.release()
cv2.destroyAllWindows()
3、ctrl+alt+t打开terminal
执行如下命令
$cd opencvtest
$sudo python test1.py出现如下界面
七、安装keras
1.linux初始环境设置
# 系统升级
sudo apt update
sudo apt upgrade
# 安装python基础开发包
sudo apt install -y python-dev python-pip python-nose gcc g++ git gfortran vim
#安装nose
sudo pip install nose
#安装gfortran编译器
sudo apt-getinstall gfortran
#安装运算加速库
sudo apt install-ylibopenblas-devliblapack-devlibatlas-base-dev
2. Keras框架搭建
相关开发包安装
在终端中输入:
>>>sudo pip install -U --pre pip setuptools wheel
>>>sudo pip install -U --pre numpy scipy matplotlib scikit-learn scikit-image
>>>sudo pip install -U --pre tensorflow-gpu #gpu
# >>> sudo pip install -U --pre tensorflow #cpu
>>>sudo pip install -U --pre keras
测试是否安装成功:
安装完毕后,输入python,然后输入:
>>> import tensorflow
>>> import keras
参考链接:
keras安装及配置 ****
在一台全新的Ubuntu系统上安装和使用Keras的主要流程
八、安装TensorFlow
安装完会推荐安装visualstudio
安装完成后关闭Terminal, 再重新打开后,使用conda --version可以看到结果,否则先显示未知命令
TensorFlow 学习系列之四:配置TensorFlow环境
更正:两处少空格
1,conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
2,conda info --envs
TensorFlow学习系列之七:TensorFlow的源码编译
sudo apt-get update; sudo apt-get install oracle-java8-installer
sudo apt-get update; sudo apt-get install bazel