wooksong / contributon2019-nns

7 stars 6 forks source link

How to run nnstreamer-examples (native) #5

Open wooksong opened 4 years ago

wooksong commented 4 years ago

Prerequisites

If you've already done some of the following steps in #1 and #2, just skip those steps.

$ sudo apt-add-repository ppa:nnstreamer
$ sudo apt install git meson ninja-build cmake
$ sudo apt install nnstreamer-*
$ sudo apt install libglib2.0-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good,
$ sudo apt install tensorflow-c-dev tensorflow-c-dev protobuf-dev libcairo2-dev libopencv-dev

$ git clone https://github.com/nnsuite/nnstreamer-example.git
$ cd nnstreamer-example

Build

$ meson build
The Meson build system
Version: 0.50.1
Source dir: /home/wook/Work/nnstreamer-example
Build dir: /home/wook/Work/nnstreamer-example/build
Build type: native build
Project name: nnstreamer-example
Project version: 0.1.0
Native C compiler: cc (gcc 7.4.0 "cc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0")
Native C++ compiler: c++ (gcc 7.4.0 "c++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (0.29.1)
Dependency glib-2.0 found: YES 2.56.4
Dependency gstreamer-1.0 found: YES 1.14.5
Dependency gstreamer-base-1.0 found: YES 1.14.5
Dependency gstreamer-video-1.0 found: YES 1.14.5
Dependency gstreamer-audio-1.0 found: YES 1.14.5
Dependency gstreamer-app-1.0 found: YES 1.14.5
Dependency cairo found: YES 1.15.10
Library m found: YES
Library dl found: YES
Dependency threads found: YES 
Dependency nnstreamer found: YES 0.3.0
Dependency tensorflow found: YES 1.13.1
Dependency protobuf found: YES 3.6.1
Dependency tensorflow-lite found: YES 1.13.1
Dependency caffe2 found: YES 1.1.0
Has header "nnstreamer/tensor_filter_custom.h" : YES
Build targets in project: 12
$ ninja -C build

Run

$ cd build/native
$ ls -1
example_cam
example_decoder_image_labelling
example_filter_performance_profile
example_image_classification_caffe2
example_image_classification_tflite
example_object_detection_tensorflow
example_object_detection_tensorflow_lite
example_sink
example_speech_command_tensorflow_lite
example_two_tensor_stream
  1. Basic examples

    • example_cam
      $ pushd example_cam
      $ ./nnstreamer_example_cam 
      $ popd
    • example_sink
      $ pushd example_sink
      $ ./nnstreamer_sink_example_play 
      $ popd
  2. Object detection examples

    • example_object_detection_tensorflow
      $ pushd example_object_detection_tensorflow
      $ bash ../../../bash_script/example_models/get-model-object-detection-tf.sh 
      $ ./nnstreamer_example_object_detection_tf
      $ popd
  1. Image classification examples
    • example_image_classification_tflite
      $ pushd example_image_classification_tflite
      $ bash ../../../bash_script/example_models/get-model-image-classification-tflite.sh 
      $ ./nnstreamer_example_image_classification_tflite 
      $ popd
    • example_image_classification_caffe2: skipped
jaimeenahn commented 4 years ago

Just like the case in #3, when using cam I should add decodebin in pipeline

str_pipeline =
      g_strdup_printf
      ("v4l2src name=cam_src ! decodebin ! videoconvert ! videoscale ! "
      "video/x-raw,width=%d,height=%d,format=RGB ! tee name=t_raw "
      "videomixer name=mix "
      "sink_0::xpos=0 sink_0::ypos=0 sink_0::zorder=0 "
      "sink_1::xpos=0 sink_1::ypos=0 sink_1::zorder=1 sink_1::alpha=0.7 ! "
      "videoconvert ! ximagesink name=img_mixed "
      "t_raw. ! queue ! mix.sink_0 "
      "t_raw. ! queue ! tensor_converter ! tensor_decoder mode=direct_video ! videoscale ! video/x-raw,width=%d,height=%d ! mix.sink_1 "
      "t_raw. ! queue ! videoconvert ! ximagesink name=img_origin",
      width, height, width / 2, height / 2);