Skip to content

Namburger/edgetpu-detection-camera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EdgeTpu Detection Camera

License made-with-coral made-with-bash made-with-c++ made-with-opencv made-with-tflite made-with-cmake ai-with-ai made-with-code-hoodies test-coverage

Demo

This is an example of using AI to AI AIs so you can AI.

Requirements:

  • Coding hoodies
  • A linux machine, I tested this build on x86_64, armv7l, and aarch64 architecture.
  • A camera to take inputs and a monitor to show frames.
  • [Optional] An edgetpu device for speedup inference.

Dependencies Installation:

$ sudo apt install libgtk2.0-dev
$ sudo apt search libgtk2.0-dev
[Optional] install cmake-3.17 if needed
$ bash scripts/install_cmake.sh

Build

$ mkdir build && cd build
$ cmake ..
$ make

Notes:

  • Since this builds libopencv*, libtensorflow-lite.a, libabsl*, and libglog, before building the project. It requires about ~7GB of storage, so you'll need an sdcard for the dev board. It will takes about two hours on the devboard and the rpi4 on the first build.
  • If you encouter OOM killer, some swapspace (necesssary for devboard and rpi4):
$ bash scripts/make2gbswap.sh

Example Run

  • CPU:
$ bin/{CPU}/edge --model_path test_data/mobilenet_ssd_v2_coco_quant_postprocess.tflite --label_path test_data/coco_labels.txt --height 480 --width 640
  • EdgeTpu:
$ export LD_LIBRARY_PATH=libedgetpu/direct/{CPU}
$ bin/{CPU}/edge --model_path test_data/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite --label_path test_data/coco_labels.txt --edgetpu --height 480 --width 640

Here are the list of options:

An example of using opencv with tflite/edgetpu in c++.
Usage:
  edge [OPTION...]

      --model_path arg    Path to .tflite model_file
      --label_path arg    Path to label file.
      --video_source arg  Video source. (default: 0)
      --threshold arg     Minimum confidence threshold. (default: .5)
      --verbose           To run in verbose mode.
      --edgetpu           To run with EdgeTPU.
      --height arg        Camera image height. (default: 480)
      --width arg         Camera image width. (default: 640)
      --help              Print Usage

Python

In case you didn't know, you can write this entire project in python with 71 lines of python... Notes: Requires installation of tflite_runtime-2.1.0.post1

  • Run with CPU:
$ python3 scripts/camera_detector.py --model test_data/mobilenet_ssd_v2_coco_quant_postprocess.tflite --labels test_data/coco_labels.txt
  • Run with TPU:
$ export LD_LIBRARY_PATH=libedgetpu/direct/{CPU}
$ python3 scripts/camera_detector.py --model test_data/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite --labels test_data/coco_labels.txt --edgetpu True

Credits

Huge thanks to the following repos:

Because a wise man once told me: "Best documentation are code examples".

About

Detection Camera with EdgeTpu

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published