Tensorflow_lite hello_world示例运行在Arduino/Devkit

原链接:

https://www.youtube.com/watch?v=B_DcpRzkAiM

视频中项目GitHub地址(如下) 并不是Arduino项目,因此,建议使用Arduino IDE 完成本项目,而不是VS Code。

Arduino IDE

The easiest way to install this library is through the Arduino's library manager. In the menus, go to Sketch->Include Library->Manage Libraries. This will pull the latest stable version.

GitHub

If you want to install an in-development version of this library, you can use the latest version directly from this GitHub repository. This requires you clone the repo into the folder that holds libraries for the Arduino IDE. The location for this folder varies by operating system, but typically it's in ~/Arduino/libraries on Linux, ~/Documents/Arduino/libraries/ on MacOS, and My Documents\Arduino\Libraries on Windows.

Once you're in that folder in the terminal, you can then grab the code using the git command line tool:

git clone https://github.com/tensorflow/tflite-micro-arduino-examples Arduino_TensorFlowLite

https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/examples/hello_world

我安装的tensorflow lite 1.5版本,自动下载examples程序。采用如下图方式打开hello_world项目。

https://github.com/tensorflow/tflite-micro-arduino-examples/blob/main/docs/hello_world_screenshot.png

Hello World

 需要在.ino文件最上方添加宏定义。

#undef min
#undef max

还可以在arduino_output_handler.cpp中找到对应行修改如下代码

// The pin of the Arduino's built-in LED
int led = RGB_R;
//int led = LED_BUILTIN;

然后使用Arduino IDE的菜单“项目”——“上传”即可烧写到Arduino(或devkit)。

附加

 也可以在通过VS Code开发本项目,打开Arduino Libraries Manager后,搜索并安装tensorflowlite。Arduino examples程序,默认存放在这个目录(如果通过Arduino: Examples命令找不到):

C:\Users\Administrator\Documents\Arduino\libraries\Arduino_TensorFlowLite\examples

如视频中所讲,VSCode需要在.vscode目录的arduino.json中添加设置,其中port端口根据自己情况填写

{
    "sketch": "hello_world.ino",
    "board": "AZ3166:stm32f4:MXCHIP_AZ3166",
    "configuration": "upload_method=OpenOCDMethod",
    "output": "./build",
    "port": "COM4"
}

如果编译报如下Problems

在 browse.path 中未找到包含文件。

原因是无法找到库文件所在路径,请把tflite库地址添加到c_cpp_properties.json配置文件includePath下。

C:/Administrator/Documents/Arduino/libraries

然后编译。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值