Coder Social home page Coder Social logo

sainttelant / edgetpu-detection-camera Goto Github PK

View Code? Open in Web Editor NEW

This project forked from namburger/edgetpu-detection-camera

0.0 0.0 0.0 32.16 MB

Detection Camera with EdgeTpu

License: Apache License 2.0

CMake 17.48% C++ 71.68% Starlark 0.74% Shell 1.10% Python 9.00%

edgetpu-detection-camera's Introduction

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".

edgetpu-detection-camera's People

Contributors

namburger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.