Video test GStreamer issue

I’m getting this problem what could be?

capture.open(“videotestsrc ! videoconvert ! appsink”, Videoio.CAP_GSTREAMER);

the error:
mat.isContinuous() must be true.

there is no such error here

are you sure it is from that line of code ?
is this the complete error msg ?
can you show some more ?
opencv / gstreamer version ?

Hi @berak thank you for the reply.

I’m using UnityCVFor Android:

void Update()
    {
        capture.retrieve(rgbMat);

        Imgproc.cvtColor(rgbMat, rgbMat, Imgproc.COLOR_BGR2RGB);

        if (fpsMonitor != null)
        {
            fpsMonitor.Add("CAP_PROP_POS_MSEC", capture.get(Videoio.CAP_PROP_POS_MSEC).ToString());
            fpsMonitor.Add("CAP_PROP_POS_FRAMES", capture.get(Videoio.CAP_PROP_POS_FRAMES).ToString());
            fpsMonitor.Add("CAP_PROP_POS_AVI_RATIO", capture.get(Videoio.CAP_PROP_POS_AVI_RATIO).ToString());
            fpsMonitor.Add("CAP_PROP_FRAME_COUNT", capture.get(Videoio.CAP_PROP_FRAME_COUNT).ToString());
            int msec = (int)Math.Round(1000.0 * (currentFrameTickCount - prevFrameTickCount) / Core.getTickFrequency());
            int fps = (int)Math.Round(1000.0 / msec);
            fpsMonitor.Add("STATE", msec + "ms (" + fps + "fps)");            
    }

        Utils.fastMatToTexture2D(rgbMat, texture);
        var tmp = seekBarSlider.onValueChanged;
        seekBarSlider.onValueChanged = defaultSliderEvent;
        seekBarSlider.value = (float)capture.get(Videoio.CAP_PROP_POS_AVI_RATIO);
        seekBarSlider.onValueChanged = tmp;
    }

the line that gives the error is:
Utils.fastMatToTexture2D(rgbMat, texture);

I saw that the rgbMat.rows() and rgbMat.cols() return 0 should be becuase of that.
The program is not able to read the rtbMat from the video test for some reason.

opencv 4.5.2 (compiled for android)

most likely the cause of it.
please check, if the capture even opened, if retrieve() returned something valid.
also check Core.getBuildInformation() to see if there is any support for gstreamer builtin

You’re right, the video is not even opened:

this return false: capture.isOpened()

so I think the compiled DLL (.so on android) isn’t well compiled or there are incompatibilities on the unity side.

I was able to play it with the windows version on Unity.

the Core.getBuildInformation()
says that I’m using the static one and gstreamer is not included:

C/C++:
    Built as dynamic libs?:      NO
    C++ standard:                11
    C++ Compiler:                C:/Users/felipe.chaves/AppData/Local/Android/Sdk/ndk/19.2.5345600/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe  (ver 8.0)
    C++ flags (Release):         -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mfpu=vfpv3-d16 -fno-addrsig -march=armv7-a -mthumb -mfpu=neon -Wa,--noexecstack -Wformat -Werror=format-security -stdlib=libc++    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments  -fvisibility=hidden -fvisibility-inlines-hidden  -Oz -DNDEBUG   -DNDEBUG
    C++ flags (Debug):           -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mfpu=vfpv3-d16 -fno-addrsig -march=armv7-a -mthumb -mfpu=neon -Wa,--noexecstack -Wformat -Werror=format-security -stdlib=libc++    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments  -fvisibility=hidden -fvisibility-inlines-hidden  -O0 -fno-limit-debug-info   -DDEBUG -D_DEBUG -g
    C Compiler:                  C:/Users/felipe.chaves/AppData/Local/Android/Sdk/ndk/19.2.5345600/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
    C flags (Release):           -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mfpu=vfpv3-d16 -fno-addrsig -march=armv7-a -mthumb -mfpu=neon -Wa,--noexecstack -Wformat -Werror=format-security    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments  -fvisibility=hidden -fvisibility-inlines-hidden  -Oz -DNDEBUG   -DNDEBUG
    C flags (Debug):             -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mfpu=vfpv3-d16 -fno-addrsig -march=armv7-a -mthumb -mfpu=neon -Wa,--noexecstack -Wformat -Werror=format-security    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments  -fvisibility=hidden -fvisibility-inlines-hidden  -O0 -fno-limit-debug-info   -DDEBUG -D_DEBUG -g
    Linker flags (Release):      -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now   -Wl,--as-needed  
    Linker flags (Debug):        -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now   -Wl,--as-needed  
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:          freetype harfbuzz dl m log
    3rdparty dependencies:       libcpufeatures ittnotify libprotobuf ade tbb libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf zlib quirc tegra_hal

  OpenCV modules:
    To be built:                 aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform java line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 alphamat cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv hdf julia matlab ovis python2 python3 sfm ts viz
    Applications:                -
    Documentation:               NO
    Non-free algorithms:         NO

  Android NDK:                   C:/Users/felipe.chaves/AppData/Local/Android/Sdk/ndk/19.2.5345600 (ver 19.2.5345600)
    Android ABI:                 armeabi-v7a
    NDK toolchain:               arm-linux-androideabi-clang
    STL type:                    c++_static
    Native API level:            28
  Android SDK:                   C:/Users/felipe.chaves/AppData/Local/Android/Sdk (tools: 26.1.1 build tools: 30.0.2)

  GUI: 

  Media I/O: 
    ZLib:                        build (ver 1.2.11)
    JPEG:                        build-libjpeg-turbo (ver 2.0.6-62)
    WEBP:                        build (ver encoder: 0x020f)
    PNG:                         build (ver 1.6.37)
    TIFF:                        build (ver 42 - 4.2.0)
    JPEG 2000:                   build (ver 2.4.0)
    OpenEXR:                     build (ver 2.3.0)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES
    PFM:                         YES

  Video I/O:

  Parallel framework:            TBB (ver 2020.2 interface 11102)

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Custom HAL:                  YES (carotene (ver 0.0.1))
    Protobuf:                    build (3.5.1)

  Python (for build):            C:/Users/felipe.chaves/AppData/Local/Microsoft/WindowsApps/python3.exe

  Java:                          export all functions
    ant:                         NO
    Java wrappers:               YES
    Java tests:                  NO

  Install to:                    C:/Users/felipe.chaves/Downloads/opencv4.5.2/buildandroid/o4a/install
-----------------------------------------------------------------

that’s what i thought.
to use gstreamer on android, you’d need gstreamer crosscompiled for your android arch,
and rebuild the opencv android libs with that

The command said on the ReadMe.pdf is enough to include gstreamer on the android version?

python …/opencv/platforms/android/build_sdk.py …/build …/opencv
–ndk_path=C://android-ndk --sdk_path=C://android-sdk
–extra_modules_path=…/opencv_contrib/modules --use_android_buildtools