[Test] checking opencv availability at runtime
authorParichay Kapoor <pk.kapoor@samsung.com>
Fri, 5 Apr 2019 06:44:00 +0000 (15:44 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 8 Apr 2019 02:05:01 +0000 (11:05 +0900)
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 <pk.kapoor@samsung.com>
nnstreamer_example/meson.build
tests/nnstreamer_filter_custom/runTest.sh

index 5a6ea52..aa64117 100644 (file)
@@ -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')
index 3c30932..2d47113 100644 (file)
@@ -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