TensorFlow Lite - 人物偵測

材料準備

  • AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1

  • Arducam Mini 2MP Plus OV2640 SPI Camera Module x 1

  • LED x 3

範例説明

步驟

AMB21 / AMB22 Wiring Diagram: Connect the camera and LEDs to the RTL8722 board following the diagram.

../../../../_images/image173.png

AMB23 接線圖:

../../../../_images/image1-15.png

BW16 接線圖:

../../../../_images/image1-25.png

BW16-TypeC Wiring Diagram:

../../../../_images/image1-37.png

從以下網址下載TensorFlow Lite for Microcontrollers的Ameba版本https://github.com/ambiot/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库。

還需要安裝TensorFlow Lite庫與Ameba_ArduCAM庫。在Arduino IDE中,安裝JPEGDecoder庫。 此範例已經通過測試1.8.0版的JPEGDecoder庫。

安裝庫後,您需要對其進行配置,以禁用一些與AMB23不兼容的可選組件。 打開以下文件:

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

Open the example, "Files" "Examples" “TensorFlowLite_Ameba” “person_detection”.

../../../../_images/image267.png

User can define the LED pins by using any GPIO pins on the boards. Upload the code and press the reset button on Ameba once the upload is finished.

一旦運行,您應該會看到藍色LED每隔幾秒鐘閃爍一次,表明它已完成圖像處理。 如果確定在先前拍攝的圖像中沒有人,則紅色LED會亮起,如果確定有人,則綠色LED會亮起。

推理結果也將輸出到Arduino串行監視器,其顯示如下:

../../../../_images/image344.png

程式碼説明

有關TensorFlow Lite for Microcontrollers的更多信息,請參考以下網址: https://www.tensorflow.org/lite/microcontrollers