1.将开启SSH功能的镜像写入SD卡
1.用SDFormatter格式化SD卡
2.用Win32DiskImager将下载好的镜像写入SD卡
2.设置开机自动连接WIFI
1.用读卡器读取SD卡,在boot分区下新建名为 wpa_supplicant.conf 的文件
2.在文件内写入以下内容:
country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="WiFi-A"
psk="12345678"
key_mgmt=WPA-PSK
priority=1
}
network={
ssid="WiFi-B"
psk="12345678"
key_mgmt=WPA-PSK
priority=2
}
注:两个不同的wifi优先级设置相同可能会导致不能自动连接WiFi
树莓派开机自动连接WiFi后进入路由器配置界面查看树莓派IP,通过IP即可通过ssh连接树莓派。(此方法不再需要网线)
3.解决乱码问题
1.进入树莓派系统
2.输入 sudo raspi-config
3.语言设置为en_US.UTF-8
4.cd /etc/default/
5.sudo nano locale
6.将locale内键值对的值全部修改为en_US.UTF-8
7.sudo reboot
4.设置开机自动启动VNC
1.进入树莓派
2.sudo rapsi-config
3.开启vnc
4.sudo reboot
5.sudo nano /etc/init.d/vncserver
6.复制以下内容并保存:
#!/bin/sh
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop vncserver
### END INIT INFO
# More details see:
# http://www.penguintutor.com/linux/vnc
### Customize this entry
# Set the USER variable to the name of the user to start vncserver under
export USER='pi'
### End customization required
eval cd ~$USER
case "$1" in
start)
# 启动命令行。此处自定义分辨率、控制台号码或其它参数。
su $USER -c '/usr/bin/vncserver -depth 16 -geometry 1024x768 :1'
echo "Starting VNC server for $USER "
;;
stop)
# 终止命令行。此处控制台号码与启动一致。
su $USER -c '/usr/bin/vncserver -kill :1'
echo "vncserver stopped"
;;
*)
echo "Usage: /etc/init.d/vncserver {start|stop}"
exit 1
;;
esac
exit 0
7.sudo chmod 755 /etc/init.d/vncserver
8.添加开机启动项:sudo update-rc.d vncserver defaults
9.sudo reboot
安装opencv
参照:https://docs.opencv.org/4.2.0/d7/d9f/tutorial_linux_install.html
1.sudo apt-get update
2.sudo apt-get install build-essential
3.sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
4.sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
5.下载opencv源码,并通过FileZilla传输给树莓派
6.解压opencv源码至家目录下
7.cd ~
8.cd opencv
9.mkdir build
10.cd build
11.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
12.make -j7 # runs 7 jobs in parallel(如果失败则重复命令)
13.sudo make install(如果失败则重复命令)
14.opencv安装完成,测试:
1.python3
2.import cv2
3.cv2.__version__
4.若输出opencv版本号则安装成功