From: jy1210.jung Date: Wed, 11 Jul 2018 07:07:52 +0000 (+0900) Subject: [Example] update document for example X-Git-Tag: v0.0.1~60 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d6846c346187db0d1ba26809299f29d3fe8a5c5;p=platform%2Fupstream%2Fnnstreamer.git [Example] update document for example 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 --- diff --git a/Documentation/how-to-run-examples.md b/Documentation/how-to-run-examples.md new file mode 100644 index 0000000..44f9e4d --- /dev/null +++ b/Documentation/how-to-run-examples.md @@ -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 +``` diff --git a/nnstreamer_example/example_cam/nnstreamer_example_cam.c b/nnstreamer_example/example_cam/nnstreamer_example_cam.c index 5b63268..d499fbe 100644 --- a/nnstreamer_example/example_cam/nnstreamer_example_cam.c +++ b/nnstreamer_example/example_cam/nnstreamer_example_cam.c @@ -16,7 +16,6 @@ #include #include -#include /** * @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 */ diff --git a/nnstreamer_example/example_sink/nnstreamer_sink_example_play.c b/nnstreamer_example/example_sink/nnstreamer_sink_example_play.c index e3b2c14..3d11506 100644 --- a/nnstreamer_example/example_sink/nnstreamer_sink_example_play.c +++ b/nnstreamer_example/example_sink/nnstreamer_sink_example_play.c @@ -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] *