在linxu環境下實現了face_recognition的運行後(參考:https://gist.github.com/ageitgey/1ac8dbe8572f3f533df6269dab35df65 ,切記勿按該文檔的說明去安裝PIXEL這個GUI,否則會灰屏卡死,然後重裝)
1. 製作啓動盤
1.1 下載鏡像
https://www.raspberrypi.org/downloads/raspbian/
最好下載一個帶桌面的版本
1.2 燒錄鏡像
下載一個win32 disk imager 專門用來寫“.img”
格式化 / 燒錄
格式化軟件可選:SD formatter
燒錄軟件可選:win32diskimager
燒錄完成的tf卡已經在電腦上顯示爲boot了,拔出tf並插入樹莓派板中,啓動:
按提示 依次修改密碼 / 選擇一個wifi / 地區選擇 / 軟件升級
2. 配置
2.1
(參考:https://gist.github.com/ageitgey/1ac8dbe8572f3f533df6269dab35df65 ,切記勿按該文檔的說明去安裝PIXEL這個GUI,否則會灰屏卡死,然後重裝)
通過上一步完成基本的配置後,開啓一個terminal即可按步驟進行配置。
Install required libraries with these commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential \
cmake \
gfortran \
git \
wget \
curl \
graphicsmagick \
libgraphicsmagick1-dev \
libatlas-dev \
libavcodec-dev \
libavformat-dev \
libboost-all-dev \
libgtk2.0-dev \
libjpeg-dev \
liblapack-dev \
libswscale-dev \
pkg-config \
python3-dev \
python3-numpy \
python3-pip \
zip
sudo apt-get clean
Install the picamera python library with array support (if you are using a camera):
sudo apt-get install python3-picamera
sudo pip3 install --upgrade picamera[array]
Temporarily enable a larger swap file size (so the dlib compile won't fail due to limited memory):
sudo nano /etc/dphys-swapfile
< change CONF_SWAPSIZE=100 to CONF_SWAPSIZE=1024 and save / exit nano >
sudo /etc/init.d/dphys-swapfile restart
Download and install dlib v19.6:
mkdir -p dlib
git clone -b 'v19.6' --single-branch https://github.com/davisking/dlib.git dlib/
cd ./dlib
sudo python3 setup.py install --compiler-flags "-mfpu=neon"
Install face_recognition
:
sudo pip3 install face_recognition
Revert the swap file size change now that dlib is installed:
sudo nano /etc/dphys-swapfile
< change CONF_SWAPSIZE=1024 to CONF_SWAPSIZE=100 and save / exit nano >
sudo /etc/init.d/dphys-swapfile restart
Download the face recognition code examples:
git clone --single-branch https://github.com/ageitgey/face_recognition.git
cd ./face_recognition/examples
python3 facerec_on_raspberry_pi.py
3. 遠程控制
如果想使用遠程桌面,有很多工具可選擇,比如putty,在IP地址處輸入樹莓派的ip地址(該IP地址是:在在無線網絡管理器處可查詢到連接詞此路由器的設備,並顯示該設備的IP地址),一定要在開啓樹莓派的ssh使能, raspi-config / ingterfaces / ssh
4. opencv 安裝
使用 以下指令安裝,可能會不穩定,有時候安裝不成功。
sudo pip3 install opencv-python (sudo pip install opencv-python)
pip3 install opencv-python
5. 可能遇到的問題
問題1: 連接網絡
若連接公司的寬帶網絡,可能需要賬號授權才能登陸,但是該raspberryPi系統不會彈出登陸頁面,最好連接wifi網絡,有兩種設置方法,分別如下:
1)通過代碼
掃描所有無線網絡:sudo iwlist wlan0 sacn
添加無線網絡:sudo vim /etc/wpa_supplicant/wpa_supplicant.conf
添加如下代碼,只是需要更改id號及相應密碼即可
network={
ssid="ssid_name"
key_mgmt=WPA-PSK
psk="password"
}
2)通過命令:
sudo raspi-config
依次選擇網絡選項/ WIFI/ 然後輸入wifi的id 及密碼即可
問題2:libcblas.so.3: cannot open shared object file: No such file or directory
解決方法:
需要安裝 libatlas-base-dev,命令如下:
sudo apt-get install libatlas-base-dev
參考:https://github.com/apache/incubator-mxnet/issues/5290
問題3 :opencv安裝
pip3 install opencv-python
問題4: 安裝出錯
若使用GIT命令克隆倉庫時出現以下錯誤提示,很可能是網絡不穩定導致的,可通過更換無線網絡解決。(自己手機開的熱點網絡變得不穩定,後面在筆記本上用360開了個熱點,問題解決)
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
問題5 : ImportError: libatlas.so.3: cannot open shared object file: no such file or derectory
解決方法:
需要安裝 libatlas-base-dev,命令如下:
sudo apt-get install libatlas-base-dev
問題6:camera is not enabled ,try running ......
通過sudo raspi-config / enable camera 未解決
搜了很多也沒找到確切答案,不過可能的願意是低電壓、插錯等
問題6: 運行程序 不顯示圖片及視頻
安裝imagemagick: sudo apt
-
get install imagemagick
原因:因爲我在Linux(openSUSE)中使用python,並沒有安裝pyhon默認的圖像瀏覽器ImageMagick,所以圖像瀏覽器無法啓動(參考:https://blog.csdn.net/wzheng92/article/details/79504654 ,http://blog.sina.com.cn/s/blog_5a81b79901015sf9.html )