TensorFlow Lite - 人物侦测

材料准备

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

  • Arducam Mini 2MP Plus OV2640 SPI 摄像机模组 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/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

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