TensorFlow Lite - 人物偵測
材料準備
• AmebaD [ AMB23 / AMB21 / AMB22 / BW16 / AW-CU488 Thing Plus / AMB25 ] x 1
• Arducam Mini 2MP Plus OV2640 SPI 攝像機模組 x 1
• LED x 3
範例
流程
AMB21 / AMB22 接線圖:
如下圖所示,將攝像機和LED連接到 AMB21 / AMB22 開發板上。
AMB23 接線圖:
BW16 接線圖:
BW16 type C 接線圖:
AW-CU488 Thing Plus 接線圖:
AMB25 接線圖:
從以下網址下載TensorFlow Lite for Microcontrollers的Ameba版本 https://github.com/ambiot/ambd_arduino/tree/master/Arduino_zip_libraries。
請按照以下說明進行安裝操作 https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries。
確保在以下位置找到patch文件並安裝 https://github.com/ambiot/ambd_arduino/tree/master/Ameba_misc/。
還需要安裝TensorFlow Lite庫與Ameba_ArduCAM庫。
在Arduino IDE中,安裝JPEGDecoder庫。 此範例已經通過測試1.8.0版的JPEGDecoder庫。
安裝庫後,您需要對其進行配置,以禁用一些與RTL8722DM不兼容的可選組件。 打開以下文件:
Arduino/libraries/JPEGDecoder/src/User_Config.h
確保將#define LOAD_SD_LIBRARY和#define LOAD_SDFAT_LIBRARY都註釋掉,如該文件摘錄所示:
//#define LOAD_SD_LIBRARY // Default SD Card library
//#define LOAD_SDFAT_LIBRARY // Use SdFat library instead, so SD Card SPI can be bit bashed
打開範例,”Files” -> “Examples” -> “TensorFlowLite_Ameba” -> “person_detection”。
用戶可以使用板上的任何 GPIO 引腳來定義 LED 引腳。
上傳代碼並在上傳完成後按Ameba上的重置按鈕。
一旦運行,您應該會看到藍色LED每隔幾秒鐘閃爍一次,表明它已完成圖像處理。 如果確定在先前拍攝的圖像中沒有人,則紅色LED會亮起,如果確定有人,則綠色LED會亮起。
推理結果也將輸出到Arduino串行監視器,其顯示如下:
程式碼說明
有關TensorFlow Lite for Microcontrollers的更多信息,請參考以下網址: https://www.tensorflow.org/lite/microcontrollers