统信UOS开发机器配置
一、配置ssh远程登陆并设置为开机自启动
(1)sudo vim /etc/ssh/sshd_config
修改以下三行
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
(2)systemctl enable ssh
update-rc.d ssh enable 2 3 4 5
service sshd restart
二、安装开发环境所用的包
安装PyQt4
sudo apt-get install libxext6 libxext-dev libqt4-dev libqt4-gui libqt4-sql # libqt4-gui不可用
sudo apt-get install qt4-dev-tools qt4-doc qt4-qtconfig qt4-demos qt4-designer
sudo apt-get install python-qt4
sudo apt-get install python-qt4-*
sudo apt-get install python-qscintilla2
# 下面四行表示python3,可以不用安装
sudo apt-get install python3-pyqt4
sudo apt-get install python3-pyqt4.qsci
sudo apt-get install python3-pyqt4.qtsql
sudo apt-get install python3-pyqt4.phonon
安装pip
cd ~
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
sudo python ./get-pip.py
pip install --upgrade setuptools
pip install --upgrade pip
安装程序所需py包
pip install twisted
sudo pip install pyinstaller==3.6 # 3.6版本可以打包py2程序
pip install pyyaml
pip install requests_toolbelt
pyinstaller用于py2的打包,因为要使用pyinstaller程序,不使用sudo安装则可执行文件放置在用户家目录/.local/bin下,还要修改环境变量,因此直接使用sudo安装,pyinstaller程序就安装到/usr/local/bin目录下。
安装opencv-python
有三种安装方式,分别是:
-
apt-get安装
sudo apt-get install python-opencv
但安装后查看编译选项中GUI为GTK3,代码中调用cv2.namedWindow()会报错。
卸载:sudo apt-get remove python-opencv
-
pip安装
# 查看pip中有哪些版本 gw1@gw1-PC:~$ pip install opencv-python== ERROR: Could not find a version that satisfies the requirement opencv-python== (from versions: 3.4.0.14, 3.4.10.37, 4.3.0.38) ERROR: No matching distribution found for opencv-python==
仓库中只有三个版本from versions: 3.4.0.14, 3.4.10.37, 4.3.0.38,其中适用于py2的只有3.4.0.14
pip install opencv-python==3.4.0.14
但是最后会报错导致安装失败,暂时还未找到原因。
-
源码安装
sudo apt-get install cmake g++ # 安装gtk2支持 sudo apt-get install libgtk2.0-dev # 安装gtk3支持 sudo apt-get install libgtk-3-dev
使用opencv-3.4.1.zip源码包,放置到~/need_install/3opencv下
cd ~/need_install/3opencv unzip opencv-3.4.1.zip cd opencv-3.4.1 mkdir build cd build cmake -D WITH_GTK_2_X=ON ..
这里我只加了
WITH_GTK_2_X=ON
的编译选项,表示使用GTK2。
这里未指定安装位置,则采用默认位置安装,则会安装到系统如下目录:
/usr/local/bin
/usr/local/lib
/usr/local/share
后面的两个点表示上级目录,不能省略。cmake完成后,会出现如下结果:
-- General configuration for OpenCV 3.4.1 ===================================== -- Version control: unknown -- -- Platform: -- Timestamp: 2021-12-15T02:38:04Z -- Host: Linux 4.19.0-arm64-desktop aarch64 -- CMake: 3.13.4 -- CMake generator: Unix Makefiles -- CMake build tool: /usr/bin/make -- Configuration: Release -- -- CPU/HW features: -- Baseline: NEON FP16 -- required: NEON -- disabled: VFPV3 -- -- C/C++: -- Built as dynamic libs?: YES -- C++11: YES -- C++ Compiler: /usr/bin/c++ (ver 8.3.0) -- C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG -- C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG -- C Compiler: /usr/bin/cc -- C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG -- C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG -- Linker flags (Release): -- Linker flags (Debug): -- ccache: NO -- Precompiled headers: YES -- Extra dependencies: dl m pthread rt -- 3rdparty dependencies: -- -- OpenCV modules: -- To be built: calib3d core dnn features2d flann highgui imgcodecs imgproc java_bindings_generator ml objdetect photo python2 python_bindings_generator shape stitching superres ts video videoio videostab -- Disabled: js world -- Disabled by dependency: - -- Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python3 viz -- Applications: tests perf_tests apps -- Documentation: NO -- Non-free algorithms: NO -- -- GUI: -- GTK+: YES (ver 2.24.32) -- GThread : YES (ver 2.58.3) -- GtkGlExt: NO -- VTK support: NO -- -- Media I/O: -- ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11) -- JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (ver ) -- WEBP: build (ver encoder: 0x020e) -- PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.36) -- TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.1.0) -- JPEG 2000: build (ver 1.900.1) -- OpenEXR: /usr/lib/aarch64-linux-gnu/libImath.so /usr/lib/aarch64-linux-gnu/libIlmImf.so /usr/lib/aarch64-linux-gnu/libIex.so /usr/lib/aarch64-linux-gnu/libHalf.so /usr/lib/aarch64-linux-gnu/libIlmThread.so (ver 2.2.1) -- -- Video I/O: -- DC1394: YES (ver 2.2.5) -- FFMPEG: YES -- avcodec: YES (ver 58.35.100) -- avformat: YES (ver 58.20.100) -- avutil: YES (ver 56.22.100) -- swscale: YES (ver 5.3.100) -- avresample: YES (ver 4.0.0) -- GStreamer: NO -- libv4l/libv4l2: NO -- v4l/v4l2: linux/videodev2.h -- gPhoto2: YES -- -- Parallel framework: pthreads -- -- Trace: YES (built-in) -- -- Other third-party libraries: -- Lapack: NO -- Eigen: NO -- Custom HAL: YES (carotene (ver 0.0.1)) -- Protobuf: build (3.5.1) -- -- NVIDIA CUDA: NO -- -- OpenCL: YES (no extra features) -- Include path: /home/gw1/need_install/3opencv/opencv-3.4.1/3rdparty/include/opencl/1.2 -- Link libraries: Dynamic load -- -- Python 2: -- Interpreter: /usr/bin/python2.7 (ver 2.7.16) -- Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.16) -- numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.16.2) -- packages path: lib/python2.7/dist-packages -- -- Python (for build): /usr/bin/python2.7 -- -- Java: -- ant: NO -- JNI: NO -- Java wrappers: NO -- Java tests: NO -- -- Matlab: NO -- -- Install to: /usr/local -- ----------------------------------------------------------------- -- -- Configuring done -- Generating done -- Build files have been written to: /home/gw1/need_install/3opencv/opencv-3.4.1/build
其中
GTK+: YES (ver 2.24.32)
表示使用GTK2,Python 2
的Interpreter
、Libraries
、numpy
、packages path
都有相应目录则表示成功找到python2,否则最后在python中import cv2会失败。make -j4 sudo make install
上述三种方式中,我采用了源码安装,安装完成后,可通过python -c "import cv2; print(cv2.getBuildInformation())"
查看编译选项,通过如下验证python中是否可调用:
gw1@gw1-PC:~$ python
Python 2.7.16 (default, Feb 26 2021, 06:12:30)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.4.1'
安装视频捕获接口包
sudo apt-get install v4l-utils
三、关于卸载opencv-python
如果采用apt-get安装,卸载命令为sudo apt-get remove python-opencv
如果采用源码安装,则采用如下命令:
cd ~/need_install/3opencv/opencv-3.4.1/build
sudo make uninstall
sudo make clean
cd ..
sudo rm -r build
sudo rm -r
/usr/local/include/opencv2 \
/usr/local/include/opencv \
/usr/include/opencv \
/usr/include/opencv2 \
/usr/local/share/opencv \
/usr/local/share/OpenCV \
/usr/share/opencv \
/usr/share/OpenCV \
/usr/local/bin/opencv* \
/usr/local/lib/libopencv*
cd /usr/
find . -name "*opencv*" | xargs sudo rm -rf
统信终端机配置
终端机需要安装v4l-utils_1.16.3-3_arm64.deb包,其依赖包libv4l2rds0_1.16.3-3_arm64.deb也没有同样需要安装。