From a0339eb049e6f1ad461f4be3379ea59623081a97 Mon Sep 17 00:00:00 2001 From: Parichay Kapoor Date: Fri, 5 Apr 2019 15:44:00 +0900 Subject: [PATCH] [Test] checking opencv availability at runtime Added option to check opencv availability at runtime. This simplify meson.build in nnstreamer_example. Also added verification of the model before running the test. Resolves #1332 Signed-off-by: Parichay Kapoor --- nnstreamer_example/meson.build | 11 ---------- tests/nnstreamer_filter_custom/runTest.sh | 34 ++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/nnstreamer_example/meson.build b/nnstreamer_example/meson.build index 5a6ea52..aa64117 100644 --- a/nnstreamer_example/meson.build +++ b/nnstreamer_example/meson.build @@ -3,17 +3,6 @@ subdir('custom_example_scaler') subdir('custom_example_average') if get_option('enable-opencv-test') subdir('custom_example_opencv') - sed=find_program('sed') - r = run_command(sed,'-i', 's|^TEST_OPENCV=.*|TEST_OPENCV=\"YES\"|g', meson.source_root()+'/tests/nnstreamer_filter_custom/runTest.sh') - if r.returncode() != 0 - message('ERROR: Cannot Convert ${TEST_OEPNCV} to "YES"') - endif -else - sed=find_program('sed') - r = run_command(sed,'-i', 's|^TEST_OPENCV=.*|TEST_OPENCV=\"NO\"|g', meson.source_root()+'/tests/nnstreamer_filter_custom/runTest.sh') - if r.returncode() != 0 - message('ERROR: Cannot Convert ${TEST_OEPNCV} to "NO"') - endif endif subdir('custom_example_RNN') subdir('custom_example_LSTM') diff --git a/tests/nnstreamer_filter_custom/runTest.sh b/tests/nnstreamer_filter_custom/runTest.sh index 3c30932..2d47113 100644 --- a/tests/nnstreamer_filter_custom/runTest.sh +++ b/tests/nnstreamer_filter_custom/runTest.sh @@ -20,7 +20,13 @@ testInit $1 PATH_TO_PLUGIN="../../build" +# Test for opencv installed, enable OPENCV test if opencv is found TEST_OPENCV="NO" +ldconfig -p | grep opencv > /dev/null 2>&1 +if [[ "$?" == 0 ]] +then + TEST_OPENCV="YES" +fi if [ "$SKIPGEN" == "YES" ] then @@ -133,16 +139,21 @@ then PATH_TO_MODEL="${CUSTOMLIB_DIR}/libnnstreamer_customfilter_opencv_scaler.so" fi - gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=640,height=480,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! tensor_converter ! tee name=t ! queue ! tensor_filter framework=\"custom\" model=\"${PATH_TO_MODEL}\" custom=\"640x480\" ! filesink location=\"testcase12.passthrough.log\" sync=true t. ! queue ! filesink location=\"testcase12.direct.log\" sync=true" 12 0 0 $PERFORMANCE - callCompareTest testcase12.direct.log testcase12.passthrough.log 12 "Compare 12" 0 0 + # Verify that opencv tests were build before running them + if [ -e $PATH_TO_MODEL ] + then + echo "Running OPENCV" + gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=640,height=480,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! tensor_converter ! tee name=t ! queue ! tensor_filter framework=\"custom\" model=\"${PATH_TO_MODEL}\" custom=\"640x480\" ! filesink location=\"testcase12.passthrough.log\" sync=true t. ! queue ! filesink location=\"testcase12.direct.log\" sync=true" 12 0 0 $PERFORMANCE + callCompareTest testcase12.direct.log testcase12.passthrough.log 12 "Compare 12" 0 0 - gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=640,height=480,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! tensor_converter ! tee name=t ! queue ! tensor_filter framework=\"custom\" model=\"${PATH_TO_MODEL}\" custom=\"320x240\" ! filesink location=\"testcase13.scaled.log\" sync=true t. ! queue ! filesink location=\"testcase13.direct.log\" sync=true" 13 0 0 $PERFORMANCE - python checkScaledTensor.py testcase13.direct.log 640 480 testcase13.scaled.log 320 240 3 - testResult $? 13 "Golden test comparison" 0 1 + gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=640,height=480,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! tensor_converter ! tee name=t ! queue ! tensor_filter framework=\"custom\" model=\"${PATH_TO_MODEL}\" custom=\"320x240\" ! filesink location=\"testcase13.scaled.log\" sync=true t. ! queue ! filesink location=\"testcase13.direct.log\" sync=true" 13 0 0 $PERFORMANCE + python checkScaledTensor.py testcase13.direct.log 640 480 testcase13.scaled.log 320 240 3 + testResult $? 13 "Golden test comparison" 0 1 - gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=640,height=480,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! tensor_converter ! tee name=t ! queue ! tensor_filter framework=\"custom\" model=\"${PATH_TO_MODEL}\" custom=\"1920x1080\" ! filesink location=\"testcase14.scaled.log\" sync=true t. ! queue ! filesink location=\"testcase14.direct.log\" sync=true" 14 0 0 $PERFORMANCE - python checkScaledTensor.py testcase14.direct.log 640 480 testcase14.scaled.log 1920 1080 3 - testResult $? 14 "Golden test comparison" 0 1 + gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=640,height=480,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! tensor_converter ! tee name=t ! queue ! tensor_filter framework=\"custom\" model=\"${PATH_TO_MODEL}\" custom=\"1920x1080\" ! filesink location=\"testcase14.scaled.log\" sync=true t. ! queue ! filesink location=\"testcase14.direct.log\" sync=true" 14 0 0 $PERFORMANCE + python checkScaledTensor.py testcase14.direct.log 640 480 testcase14.scaled.log 1920 1080 3 + testResult $? 14 "Golden test comparison" 0 1 + fi # Test average using OpenCV (15) # custom version @@ -162,9 +173,12 @@ then PATH_TO_MODEL_A="${CUSTOMLIB_DIR}/libnnstreamer_customfilter_opencv_average.so" fi - gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=640,height=480,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! tensor_converter ! tensor_filter framework=\"custom\" model=\"${PATH_TO_MODEL_A}\" ! filesink location=\"testcase15.opencv.average.log\" sync=true" 15 0 0 $PERFORMANCE + if [ -e $PATH_TO_MODEL_A ] + then + gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=640,height=480,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! tensor_converter ! tensor_filter framework=\"custom\" model=\"${PATH_TO_MODEL_A}\" ! filesink location=\"testcase15.opencv.average.log\" sync=true" 15 0 0 $PERFORMANCE - callCompareTest testcase15.opencv.average.log testcase15.average.log 15 "Compare 15" 0 0 + callCompareTest testcase15.opencv.average.log testcase15.average.log 15 "Compare 15" 0 0 + fi fi report -- 2.7.4