OpenCV(4.9.0) Error: Requested object was not found (could not open directory: /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!/lib/x86_64) in glob_rec, file /home/ci/opencv/modules/core/src/glob.cpp

I followed the instructions on opencv docs, as well as this website Android Studio: Step-by-Step Guide to Download and Install OpenCV for Android | by D I N E S H | ProAndroidDev.

So the only open CV codes i have running in my projects are
in MainActivity.kt, because i understand from the docs we need to init first

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        if (OpenCVLoader.initLocal()) {
            Log.i(TAG, "OpenCV initLocal() successfully")
        } else {
            Log.e(TAG, "OpenCV initialization failed!")
            Toast.makeText(this, "OpenCV initialization failed!", Toast.LENGTH_LONG).show()
        }

and in my HomeFragment.kt

private fun openCVgetFrames(streamAddress : String) {
        Log.i("HomeFragment.kt-OpenCV", "entered into openCVgetframes function ")

        /*
        // test variables for reading a file saved locally on the android emulator
        val file = File(Environment.getExternalStorageDirectory(), "downloads/DJI_0525_T.MP4")
        val uri = Uri.fromFile(file)
        val auxFile = File(uri.path).toString()
        Log.i("HomeFragment-OpenCV", "auxFile $auxFile ")
        */
        var fullGStreamerCommand = "gst-launch-1.0 " + streamAddress // gst-launch-1.0 souphttpsrc etc etc....
        //actual code meant for reading from the gstreamer lib
        lifecycleScope.launch {
            var videoCapturing = VideoCapture(fullGStreamerCommand, CAP_GSTREAMER)
            videoCapturing.open(fullGStreamerCommand, CAP_GSTREAMER)
            Log.i("HomeFragment.kt-OpenCV", "videoCapturing opening:  $fullGStreamerCommand ")
            Log.i("HomeFragment.kt-OpenCV", "videoCapturing isOpened:  ${videoCapturing.isOpened} ")
            Log.i("HomeFragment.kt-OpenCV", "videoCapturing isOpened():  ${videoCapturing.isOpened()} ")

            try {
                if (videoCapturing.isOpened) {
                    var frame = Mat()
                    Log.i("HomeFragment-OpenCV", "Video capture is successful, proceed with frame grabbing ")
                    while (videoCapturing.read(frame)) {
                        // Process the frame (e.g., display or analyze it)
                        val height = frame.rows()
                        val width = frame.cols()
                        Log.i("HomeFragment-OpenCV", "Frame height: $height, Frame width: $width")
                    }
                } else {
                    Log.i("HomeFragment-OpenCV", "Video capture failed, no frames obtained. videoCapturing.isOpened returned false.  ")
                }
            } catch (e: Exception) {
                Log.e("HomeFragment-OpenCV", "An error occurred during video capture: ${e.message}")
            }
            finally {
                videoCapturing.release()
                Log.i("HomeFragment-OpenCV", "video capture releasing!  ")
            }
        }
    }

i get these errors in my logs. The main error seems to be 2024-04-29 11:01:43.244 4754-4754 cv::error() com.htx.streamplayer E OpenCV(4.9.0) Error: Requested object was not found (could not open directory: /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!/lib/x86_64) in glob_rec, file /home/ci/opencv/modules/core/src/glob.cpp, line 279

2024-04-29 11:01:43.244  4754-4754  cv::error()             com.htx.streamplayer                 E  OpenCV(4.9.0) Error: Requested object was not found (could not open directory: /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!/lib/x86_64) in glob_rec, file /home/ci/opencv/modules/core/src/glob.cpp, line 279
2024-04-29 11:01:43.245  4754-4754  libc                    com.htx.streamplayer                 A  Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 4754 (tx.streamplayer), pid 4754 (tx.streamplayer)
2024-04-29 11:01:43.440  4793-4793  DEBUG                   pid-4793                             A  Cmdline: com.htx.streamplayer
2024-04-29 11:01:43.441  4793-4793  DEBUG                   pid-4793                             A  pid: 4754, tid: 4754, name: tx.streamplayer  >>> com.htx.streamplayer <<<
2024-04-29 11:01:43.442  4793-4793  DEBUG                   pid-4793                             A        #01 pc 00000000000bbdf1  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libc++_shared.so (BuildId: 0516d55561abea9d0a07bd4694edf00e363f9880)
2024-04-29 11:01:43.442  4793-4793  DEBUG                   pid-4793                             A        #02 pc 00000000000bb28d  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libc++_shared.so (BuildId: 0516d55561abea9d0a07bd4694edf00e363f9880)
2024-04-29 11:01:43.442  4793-4793  DEBUG                   pid-4793                             A        #03 pc 00000000000bb07b  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libc++_shared.so (__gxx_personality_v0+123) (BuildId: 0516d55561abea9d0a07bd4694edf00e363f9880)
2024-04-29 11:01:43.442  4793-4793  DEBUG                   pid-4793                             A        #04 pc 00000000032f9a54  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libopencv_java4.so (BuildId: b78a53b5805b03b23636da3514d6d70581d18b68)
2024-04-29 11:01:43.443  4793-4793  DEBUG                   pid-4793                             A        #05 pc 00000000032f9aee  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libopencv_java4.so (BuildId: b78a53b5805b03b23636da3514d6d70581d18b68)
2024-04-29 11:01:43.443  4793-4793  DEBUG                   pid-4793                             A        #06 pc 0000000000d715fa  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libopencv_java4.so (cv::error(int, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, char const*, char const*, int)+506) (BuildId: b78a53b5805b03b23636da3514d6d70581d18b68)
2024-04-29 11:01:43.443  4793-4793  DEBUG                   pid-4793                             A        #07 pc 0000000000c297b8  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libopencv_java4.so (BuildId: b78a53b5805b03b23636da3514d6d70581d18b68)
2024-04-29 11:01:43.443  4793-4793  DEBUG                   pid-4793                             A        #08 pc 0000000000c2927a  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libopencv_java4.so (cv::glob(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, std::__ndk1::vector<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, std::__ndk1::allocator<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > > >&, bool)+538) (BuildId: b78a53b5805b03b23636da3514d6d70581d18b68)
2024-04-29 11:01:43.444  4793-4793  DEBUG                   pid-4793                             A        #09 pc 00000000017aa105  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libopencv_java4.so (BuildId: b78a53b5805b03b23636da3514d6d70581d18b68)
2024-04-29 11:01:43.444  4793-4793  DEBUG                   pid-4793                             A        #10 pc 00000000017afd85  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libopencv_java4.so (BuildId: b78a53b5805b03b23636da3514d6d70581d18b68)
2024-04-29 11:01:43.444  4793-4793  DEBUG                   pid-4793                             A        #11 pc 00000000017b2c7c  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libopencv_java4.so (BuildId: b78a53b5805b03b23636da3514d6d70581d18b68)
2024-04-29 11:01:43.444  4793-4793  DEBUG                   pid-4793                             A        #12 pc 0000000001798f07  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libopencv_java4.so (cv::VideoCapture::open(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, int, std::__ndk1::vector<int, std::__ndk1::allocator<int> > const&)+1495) (BuildId: b78a53b5805b03b23636da3514d6d70581d18b68)
2024-04-29 11:01:43.444  4793-4793  DEBUG                   pid-4793                             A        #13 pc 00000000017988db  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libopencv_java4.so (cv::VideoCapture::open(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, int)+43) (BuildId: b78a53b5805b03b23636da3514d6d70581d18b68)
2024-04-29 11:01:43.444  4793-4793  DEBUG                   pid-4793                             A        #14 pc 000000000179841b  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libopencv_java4.so (cv::VideoCapture::VideoCapture(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, int)+91) (BuildId: b78a53b5805b03b23636da3514d6d70581d18b68)
2024-04-29 11:01:43.444  4793-4793  DEBUG                   pid-4793                             A        #15 pc 0000000000b2c56e  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk!libopencv_java4.so (Java_org_opencv_videoio_VideoCapture_VideoCapture_11+254) (BuildId: b78a53b5805b03b23636da3514d6d70581d18b68)
2024-04-29 11:01:43.445  4793-4793  DEBUG                   pid-4793                             A        #23 pc 0000000000002af6  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.446  4793-4793  DEBUG                   pid-4793                             A        #29 pc 00000000000035bc  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.446  4793-4793  DEBUG                   pid-4793                             A        #35 pc 000000000046297e  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.447  4793-4793  DEBUG                   pid-4793                             A        #41 pc 00000000004da4a8  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.448  4793-4793  DEBUG                   pid-4793                             A        #44 pc 00000000004e102e  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.448  4793-4793  DEBUG                   pid-4793                             A        #47 pc 00000000004e0f3e  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.449  4793-4793  DEBUG                   pid-4793                             A        #50 pc 00000000004a5818  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.450  4793-4793  DEBUG                   pid-4793                             A        #56 pc 00000000004a0fda  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.451  4793-4793  DEBUG                   pid-4793                             A        #62 pc 00000000004a1e7e  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.451  4793-4793  DEBUG                   pid-4793                             A        #65 pc 00000000004a1f60  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.451  4793-4793  DEBUG                   pid-4793                             A        #68 pc 00000000004a1e30  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.452  4793-4793  DEBUG                   pid-4793                             A        #71 pc 00000000004a1f44  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.452  4793-4793  DEBUG                   pid-4793                             A        #74 pc 00000000000047b2  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.453  4793-4793  DEBUG                   pid-4793                             A        #80 pc 0000000000003f04  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.453  4793-4793  DEBUG                   pid-4793                             A        #83 pc 0000000000003368  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.454  4793-4793  DEBUG                   pid-4793                             A        #89 pc 000000000000330e  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.456  4793-4793  DEBUG                   pid-4793                             A        #95 pc 0000000000003ab8  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.457  4793-4793  DEBUG                   pid-4793                             A        #101 pc 00000000002ced82  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.457  4793-4793  DEBUG                   pid-4793                             A        #107 pc 00000000002cedf4  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.458  4793-4793  DEBUG                   pid-4793                             A        #113 pc 00000000002cf066  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.458  4793-4793  DEBUG                   pid-4793                             A        #119 pc 00000000002cf38c  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.459  4793-4793  DEBUG                   pid-4793                             A        #125 pc 00000000002ce828  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.460  4793-4793  DEBUG                   pid-4793                             A        #131 pc 00000000002ce7a0  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.460  4793-4793  DEBUG                   pid-4793                             A        #137 pc 00000000002ce774  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.461  4793-4793  DEBUG                   pid-4793                             A        #143 pc 00000000004e107c  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.461  4793-4793  DEBUG                   pid-4793                             A        #146 pc 00000000004a1d18  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.462  4793-4793  DEBUG                   pid-4793                             A        #149 pc 00000000004a1ef0  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.462  4793-4793  DEBUG                   pid-4793                             A        #152 pc 00000000002ce9ec  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.464  4793-4793  DEBUG                   pid-4793                             A        #158 pc 00000000002cbb30  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.465  4793-4793  DEBUG                   pid-4793                             A        #164 pc 00000000004d8aa4  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.467  4793-4793  DEBUG                   pid-4793                             A        #170 pc 00000000004d8a88  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.467  4793-4793  DEBUG                   pid-4793                             A        #176 pc 00000000004d8f12  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.468  4793-4793  DEBUG                   pid-4793                             A        #182 pc 00000000004d8e72  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.469  4793-4793  DEBUG                   pid-4793                             A        #188 pc 00000000004c420a  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.469  4793-4793  DEBUG                   pid-4793                             A        #191 pc 00000000004c4048  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.469  4793-4793  DEBUG                   pid-4793                             A        #194 pc 00000000004c4014  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.470  4793-4793  DEBUG                   pid-4793                             A        #200 pc 000000000046297e  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk
2024-04-29 11:01:43.471  4793-4793  DEBUG                   pid-4793                             A        #206 pc 00000000004a6f68  /data/app/~~CNaTFolEeFbMZ8d7z1Lt2g==/com.htx.streamplayer-gqHB_XWS9dRvrkxH85M8ag==/base.apk

Any idea what these problems are?

Hi! I am having the same issue, where you able to resolve it?

Iā€™d strongly recommend seeking assistance from the author of the article, ā€œD I N E S Hā€

this tries to invoke the gstreamer backend, which is usually not available on android (unless you explicitly cross-compile gstreamer for android & rebuild the opencv sdk with it)