[Example] update document for example
authorjy1210.jung <jy1210.jung@samsung.com>
Wed, 11 Jul 2018 07:07:52 +0000 (16:07 +0900)
committer함명주/동작제어Lab(SR)/Principal Engineer/삼성전자 <myungjoo.ham@samsung.com>
Thu, 12 Jul 2018 02:52:32 +0000 (11:52 +0900)
1. add videoscale example (example_cam)
2. remove unnecessary header-include (example_cam)
3. update document to build and run examples

Related issue #255.

**Self evaluation:**
1. Build test: [*]Passed [ ]Failed [ ]Skipped
2. Run test: [*]Passed [ ]Failed [ ]Skipped

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
Documentation/how-to-run-examples.md [new file with mode: 0644]
nnstreamer_example/example_cam/nnstreamer_example_cam.c
nnstreamer_example/example_sink/nnstreamer_sink_example_play.c

diff --git a/Documentation/how-to-run-examples.md b/Documentation/how-to-run-examples.md
new file mode 100644 (file)
index 0000000..44f9e4d
--- /dev/null
@@ -0,0 +1,72 @@
+# How to run examples
+
+## Build examples (Ubuntu)
+
+Use Cmake.
+
+See [Getting started](getting-started.md) : **Approach 2.** Build with Cmake
+
+Build example (DEV_ROOT=/dev, and gst plugin path is ```/dev/lib```)
+
+```
+$ mkdir -p build  # We recommend to build in a "build" directory
+$ cd build
+$ rm -rf *        # Ensure the build directory is empty
+$ cmake -DCMAKE_INSTALL_PREFIX=${DEV_ROOT} -DINCLUDE_INSTALL_DIR=${DEV_ROOT}/include ..
+$ make install    # Install nnstreamer plugin libraries into /dev/lib
+$ cd ..
+``` 
+
+## Example : cam
+
+```
+v4l2src -- tee ------------------------------------------ videomixer -- videoconvert -- xvimagesink
+            |                                                 |
+            --- tensor_converter -- tensordec -- videoscale ---
+            |
+            --- videoconvert -- xvimagesink
+```
+
+Displays two video sinks,
+1. Original from cam (640 x 480)
+2. Mixed : original + scaled (tensor_converter-tensor_dec-videoscale)
+
+```
+$ cd build/nnstreamer_example/example_cam
+$ ./nnstreamer_example_cam --gst-plugin-path=/dev/lib 
+```
+
+## Example : tensor sink
+
+Two simple examples to use tensor sink.
+
+#### 1. 100 buffers passed to tensor sink
+
+```
+videotestsrc -- tensor_converter -- tensor_sink
+```
+
+Displays nothing, this sample code shows how to get buffer from tensor sink.
+
+```
+$ cd build/nnstreamer_example/example_sink
+$ ./nnstreamer_sink_example --gst-plugin-path=/dev/lib 
+```
+
+#### 2. launch two pipelines
+
+```
+videotestsrc -- tensor_converter -- tensor_sink
+[push buffer from tensor_sink to appsrc]
+appsrc -- tensordec -- videoconvert -- xvimagesink
+```
+
+Displays video sink.
+
+Tensor_sink receives buffer and pushes it into 2nd pipeline.
+```
+$ cd build/nnstreamer_example/example_sink
+$ ./nnstreamer_sink_example_play --gst-plugin-path=/dev/lib 
+```
index 5b63268..d499fbe 100644 (file)
@@ -16,7 +16,6 @@
 #include <unistd.h>
 
 #include <gst/gst.h>
-#include <gst/app/gstappsrc.h>
 
 /**
  * @brief Macro for debug mode.
@@ -205,14 +204,13 @@ main (int argc, char **argv)
       ("v4l2src name=cam_src ! "
       "video/x-raw,width=%d,height=%d,format=RGB,framerate=30/1 ! tee name=t_raw "
       "videomixer name=mix "
-      "sink_0::xpos=0 sink_0::ypos=0 sink_0::zorder=0 sink_0::alpha=0.7 "
-      "sink_1::xpos=50 sink_1::ypos=50 sink_1::zorder=1 sink_1::alpha=0.5 ! "
+      "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 ! xvimagesink name=img_mixed "
-      "t_raw. ! queue ! tensor_converter ! tensordec ! tee name=t_tensor "
       "t_raw. ! queue ! mix.sink_0 "
-      "t_tensor. ! queue ! mix.sink_1 "
-      "t_tensor. ! queue ! videoconvert ! xvimagesink name=img_tensor",
-      width, height);
+      "t_raw. ! queue ! tensor_converter ! tensordec ! videoscale ! video/x-raw,width=%d,height=%d ! mix.sink_1 "
+      "t_raw. ! queue ! videoconvert ! xvimagesink name=img_origin",
+      width, height, width / 2, height / 2);
   g_app.pipeline = gst_parse_launch (str_pipeline, NULL);
   g_free (str_pipeline);
   _check_cond_err (g_app.pipeline != NULL);
@@ -234,8 +232,8 @@ main (int argc, char **argv)
   _set_window_title (element, "Mixed");
   gst_object_unref (element);
 
-  element = gst_bin_get_by_name (GST_BIN (g_app.pipeline), "img_tensor");
-  _set_window_title (element, "Tensor");
+  element = gst_bin_get_by_name (GST_BIN (g_app.pipeline), "img_origin");
+  _set_window_title (element, "Original");
   gst_object_unref (element);
 
   /* run main loop */
index e3b2c14..3d11506 100644 (file)
@@ -8,7 +8,7 @@
  *
  * This sample app shows video frame using two pipelines.
  *
- * [1st pipeline : videotestsrc-videoconvert-tensor_converter-tensor_sink]
+ * [1st pipeline : videotestsrc-tensor_converter-tensor_sink]
  * push buffer to appsrc
  * [2nd pipeline : appsrc-tensordec-videoconvert-xvimagesink]
  *