Repository: opencv
Issue: In Galaxy S22 and Android Version12, VideoCapture::bool read Crash erupt
Labels: bug,category: videoio,platform: android

<!--
If you have a question rather than reporting a bug please go to https://forum.opencv.org where you get much faster responses.
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).

This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
-->

##### System information (version)
<!-- Example
- OpenCV => 4.2
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2017
-->

- OpenCV => :grey_question: 4.5.5
- Operating System / Platform => :grey_question: Android 12 / Samsung Galaxy S22
- Compiler => :grey_question: Android Studio

##### Detailed description

In Android Version 12, I use
```
public boolean read(Mat image) {
        return read_0(nativeObj, image.nativeObj);
    }
    
```

but it's not working some video and crash erupt in my device
I couldn't find anything in common about video.
If anyone know about this situation, plz help me.

It look similar to #21149 but below log about buffer size The buffer size is larger than the result of 
```
width * height * 3 / 2 = 1280 * 736 = 1413120
```

In my opinion, it's not the same problem.

- add some log when My code try read function
```

D/CCodecConfig: c2 config diff is   c2::u32 raw.color.matrix = 3
      c2::u32 raw.color.primaries = 3
      c2::u32 raw.color.range = 2
      c2::u32 raw.color.transfer = 3
      c2::u32 raw.crop.height = 736
      c2::u32 raw.crop.left = 0
      c2::u32 raw.crop.top = 0
      c2::u32 raw.crop.width = 1280
D/CCodecBuffers: [c2.qti.avc.decoder#40:2D-BB-Output] popFromStashAndRegister: at 0us, output format changed to AMessage(what = 0x00000000) = {
      int32_t android._color-format = 2141391876
      int32_t android._video-scaling = 1
      int32_t android._dataspace = 258
      int32_t color-standard = 2
      int32_t color-range = 2
      int32_t color-transfer = 3
      int32_t sar-height = 1
      int32_t rotation-degrees = 90
      Buffer hdr-static-info = {
        00000000:  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
        00000010:  00 00 00 00 00 00 00 00  00                       .........
      }
      int32_t sar-width = 1
      Rect crop(0, 0, 1279, 735)
      int32_t width = 1280
      int32_t feature-secure-playback = 0
      int32_t frame-rate = 30
      int32_t height = 736
      int32_t max-height = 4320
      int32_t max-width = 8192
      string mime = "video/raw"
      int32_t priority = 0
      int32_t vendor.qti-ext-dec-timestamp-reorder.value = 1
      int32_t color-format = 21
    }
V/NativeCodec: no output buffer right now
E/QC2Interface: Failed to query parameters
V/NativeCodec: input buffer 3
D/CCodecBuffers: [c2.qti.avc.decoder#40:2D-BB-Output] updating image-data
D/CCodecBuffers: [c2.qti.avc.decoder#40:2D-BB-Output] updating stride = 1280, width: 1280, height: 736
D/CCodecBuffers: [c2.qti.avc.decoder#40:2D-BB-Output] updating vstride = 736
V/NativeCodec: format changed to: android._color-format: int32(2141391876), android._video-scaling: int32(1), android._dataspace: int32(258), color-standard: int32(2), color-range: int32(2), color-transfer: int32(3), sar-height: int32(1), rotation-degrees: int32(90), hdr-static-info: data, sar-width: int32(1), crop: Rect(0, 0, 1279, 735), width: int32(1280), feature-secure-playback: int32(0), frame-rate: int32(30), height: int32(736), max-height: int32(4320), max-width: int32(8192), mime: string(video/raw), priority: int32(0), vendor.qti-ext-dec-timestamp-reorder.value: int32(1), color-format: int32(21), image-data: data, stride: int32(1280), slice-height: int32(736)}
V/NativeCodec: input buffer 0
D/CCodecBuffers: [c2.qti.avc.decoder#40:Output[N]] updating image-data
D/CCodecBuffers: [c2.qti.avc.decoder#40:Output[N]] updating stride = 1280, width: 1280, height: 736
D/CCodecBuffers: [c2.qti.avc.decoder#40:Output[N]] updating vstride = 736
V/NativeCodec: colorFormat: 21
V/NativeCodec: buffer size: 1413121
V/NativeCodec: width (frame): 1280
V/NativeCodec: height (frame): 736
```

- add error log
```
A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
A/DEBUG: Build fingerprint: 'samsung/r0qksx/r0q:12/SP1A.210812.016/S901NKSS1AVDC:user/release-keys'
A/DEBUG: Revision: '15'
A/DEBUG: ABI: 'arm64'
A/DEBUG: Processor: '7'
A/DEBUG: Timestamp: 2022-05-19 18:11:16.505985309+0900
A/DEBUG: Process uptime: 109s
A/DEBUG: Cmdline: My Application pakcage name
A/DEBUG: pid: 19768, tid: 19861, name: DefaultDispatch  >>>  My Application pakcage name <<<
A/DEBUG: uid: 10516
A/DEBUG: tagged_addr_ctrl: 0000000000000001
A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x74851a0000
A/DEBUG:     x0  b40000747a482fe0  x1  00000074851a0001  x2  0000000000000001  x3  0000000000000000
A/DEBUG:     x4  0000000000000000  x5  0000000000000000  x6  b40000747a5dbfe0  x7  7f7f7f7f7f7f7f7f
A/DEBUG:     x8  00000000000000b4  x9  0000000000000000  x10 00000000f2e690fe  x11 000000007a5dbfe1
A/DEBUG:     x12 0000ffff00000eff  x13 000000009165e844  x14 0000000010991116  x15 0000164cd1d6177d
A/DEBUG:     x16 00000074e0e250e8  x17 0000007873dbc8c0  x18 0000000000001400  x19 b4000075ddd64378
A/DEBUG:     x20 b40000759ddd5210  x21 0000000000000001  x22 b4000075ddd643a4  x23 b4000075ddd643a8
A/DEBUG:     x24 b40000747a482fe0  x25 0000007485047000  x26 0000000000159001  x27 b40000759ddd5218
A/DEBUG:     x28 b40000747a5dbfe1  x29 00000074b308f540
A/DEBUG:     lr  00000074e05dd4fc  sp  00000074b308f4a0  pc  0000007873dbc918  pst 0000000000001000
A/DEBUG: backtrace:
A/DEBUG:       #00 pc 000000000004d918  /apex/com.android.runtime/lib64/bionic/libc.so (memcpy_opt+88) (BuildId: 0f39fc790debeef5bc191987ab30a3f5)
A/DEBUG:       #01 pc 00000000009004f8  /data/app/~~HsvIqVEdiMP4jUexYvXesw==/My Application pakcage name-pCvRQ7eZXGLVeoUeowKdrQ==/lib/arm64/libopencv_java4.so (BuildId: c8878ceac156e5497229fce79b3031bf63336356)
A/DEBUG:       #02 pc 00000000008e3580  /data/app/~~HsvIqVEdiMP4jUexYvXesw==/My Application pakcage name-pCvRQ7eZXGLVeoUeowKdrQ==/lib/arm64/libopencv_java4.so (cv::VideoCapture::grab()+64) (BuildId: c8878ceac156e5497229fce79b3031bf63336356)
A/DEBUG:       #03 pc 00000000008e37bc  /data/app/~~HsvIqVEdiMP4jUexYvXesw==/My Application pakcage name-pCvRQ7eZXGLVeoUeowKdrQ==/lib/arm64/libopencv_java4.so (cv::VideoCapture::read(cv::_OutputArray const&)+68) (BuildId: c8878ceac156e5497229fce79b3031bf63336356)
A/DEBUG:       #04 pc 0000000000218e8c  /data/app/~~HsvIqVEdiMP4jUexYvXesw==/My Application pakcage name-pCvRQ7eZXGLVeoUeowKdrQ==/lib/arm64/libopencv_java4.so (Java_org_opencv_videoio_VideoCapture_read_10+64) (BuildId: c8878ceac156e5497229fce79b3031bf63336356)
A/DEBUG:       #05 pc 00000000002d4044  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #06 pc 00000000002ca9e8  /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #07 pc 00000000002ee6b8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+320) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #08 pc 000000000040ade4  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+820) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #09 pc 000000000076d4b8  /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+3812) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #10 pc 00000000002c5014  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #11 pc 00000000001fef3c  [anon:dalvik-classes4.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes4.dex] (org.opencv.videoio.VideoCapture.read+8)
A/DEBUG:       #12 pc 000000000027d840  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.3351068054637636664)+644) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #13 pc 000000000035a9e4  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+148) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #14 pc 000000000040b05c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1452) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #15 pc 00000000002c0ea4  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+5380) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #16 pc 00000000002c4e94  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #17 pc 00000000004b6648  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes3.dex] (kr.co.moais.golffix.modules.video.VideoRetriever.retrieveOriginals+232)
A/DEBUG:       #18 pc 000000000027d840  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.3351068054637636664)+644) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #19 pc 000000000035a9e4  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+148) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #20 pc 000000000040b05c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1452) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #21 pc 00000000002c0ea4  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+5380) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #22 pc 00000000002c4e94  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #23 pc 00000000004b44fa  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes3.dex] (kr.co.moais.golffix.modules.video.LoadVideoEstimateAndAnalysis$readyForLoadSwingVideo$2.invokeSuspend+38)
A/DEBUG:       #24 pc 000000000027d840  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.3351068054637636664)+644) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #25 pc 000000000035a9e4  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+148) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #26 pc 000000000040b05c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1452) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #27 pc 00000000002c0ea4  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+5380) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #28 pc 00000000002c4e94  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #29 pc 00000000004b44b8  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes3.dex] (kr.co.moais.golffix.modules.video.LoadVideoEstimateAndAnalysis$readyForLoadSwingVideo$2.invoke+20)
A/DEBUG:       #30 pc 000000000027d840  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.3351068054637636664)+644) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #31 pc 000000000035a9e4  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+148) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #32 pc 000000000040b05c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1452) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #33 pc 00000000003d537c  /apex/com.android.art/lib64/libart.so (MterpInvokeInterface+4912) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #34 pc 00000000002c5094  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #35 pc 0000000000420ce2  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes3.dex] (kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn+38)
A/DEBUG:       #36 pc 000000000076ce1c  /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+2120) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #37 pc 00000000002c5014  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #38 pc 00000000003cdd3c  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes3.dex] (kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext+136)
A/DEBUG:       #39 pc 000000000076ce1c  /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+2120) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #40 pc 00000000002c5014  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #41 pc 00000000003cdf38  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes3.dex] (kotlinx.coroutines.BuildersKt.withContext+0)
A/DEBUG:       #42 pc 000000000027d840  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.3351068054637636664)+644) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #43 pc 000000000027c9e8  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+1176) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #44 pc 00000000002d4178  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #45 pc 0000000000209188  /apex/com.android.art/lib64/libart.so (nterp_helper+152) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #46 pc 00000000004b47be  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes3.dex] (kr.co.moais.golffix.modules.video.LoadVideoEstimateAndAnalysis.readyForLoadSwingVideo+166)
A/DEBUG:       #47 pc 000000000020a044  /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #48 pc 00000000004ff68c  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes3.dex] (kr.co.moais.golffix.view.generateswing.loadswing.loadswingvideopreview.LoadSwingVideoPreviewViewModel$doEstimateAndAnalysis$1$1.invokeSuspend+296)
A/DEBUG:       #49 pc 000000000020a044  /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #50 pc 000000000039b7e0  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes3.dex] (kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith+40)
A/DEBUG:       #51 pc 00000000020a8570  /memfd:jit-cache (deleted) (kotlinx.coroutines.DispatchedTask.run+1824)
A/DEBUG:       #52 pc 000000000020a0a0  /apex/com.android.art/lib64/libart.so (nterp_helper+4016) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #53 pc 0000000000422fae  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes3.dex] (kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely+2)
A/DEBUG:       #54 pc 000000000020a044  /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #55 pc 0000000000421ba6  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes3.dex] (kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask+34)
A/DEBUG:       #56 pc 000000000020a044  /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #57 pc 0000000000421cd8  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes3.dex] (kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker+56)
A/DEBUG:       #58 pc 000000000020a044  /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #59 pc 0000000000421c88  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~HsvIqVEdiMP4jUexYvXesw==/kr.co.moais.golffix-pCvRQ7eZXGLVeoUeowKdrQ==/base.apk!classes3.dex] (kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run+0)
A/DEBUG:       #60 pc 00000000002ca764  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #61 pc 000000000030e980  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+156) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #62 pc 00000000003c1db4  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*)+380) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #63 pc 00000000004578ec  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+992) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb)
A/DEBUG:       #64 pc 00000000000b6e94  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+264) (BuildId: 0f39fc790debeef5bc191987ab30a3f5)
A/DEBUG:       #65 pc 00000000000534b0  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68) (BuildId: 0f39fc790debeef5bc191987ab30a3f5)
```


##### Steps to reproduce
```
val videoCapture = VideoCapture(videoPath)
        try {
            while (videoCapture.isOpened){
                val mat = Mat()
                videoCapture.grab()
                val isRetrieved = videoCapture.retrieve(mat)
                if(isRetrieved){
                    val src = Bitmap.createBitmap(mat.cols(), mat.rows(), Bitmap.Config.ARGB_8888)
                    Utils.matToBitmap(mat, src)
                    //use src Bitmap
                }
            }
        }catch (e:Exception){
            //catch exception
            Log.d("TAG_ERROR", "exception! : $e")
        }finally {
            videoCapture.release()
        }
```
or

```
val videoCapture = VideoCapture(videoPath)
        try {
            while (videoCapture.isOpened){
                val mat = Mat()
                if(videoCapture.read(mat)){
                    val src = Bitmap.createBitmap(mat.cols(), mat.rows(), Bitmap.Config.ARGB_8888)
                    Utils.matToBitmap(mat, src)
                    //use src Bitmap
                }
            }
        }catch (e:Exception){
            //catch exception
            Log.d("TAG_ERROR", "exception! : $e")
        }finally {
            videoCapture.release()
        }
```
but both code not working same.
Couldn't catch exception .





##### Issue submission checklist

 - [x] I report the issue, it's not a question
   <!--
   OpenCV team works with forum.opencv.org, Stack Overflow and other communities
   to discuss problems. Tickets with questions without a real issue statement will be
   closed.
   -->
 - [x] I checked the problem with documentation, FAQ, open issues,
       forum.opencv.org, Stack Overflow, etc and have not found any solution
   <!--
   Places to check:
   * OpenCV documentation: https://docs.opencv.org
   * FAQ page: https://github.com/opencv/opencv/wiki/FAQ
   * OpenCV forum: https://forum.opencv.org
   * OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
   * Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
   -->
 - [x] I updated to the latest OpenCV version and the issue is still there
   <!--
   master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
   OpenCV team supports only the latest release for each branch.
   The ticket is closed if the problem is not reproduced with the modern version.
   -->
 - [x] There is reproducer code and related data files: videos, images, onnx, etc
   <!--
   The best reproducer -- test case for OpenCV that we can add to the library.
   Recommendations for media files and binary files:
   * Try to reproduce the issue with images and videos in opencv_extra repository
     to reduce attachment size
   * Use PNG for images, if you report some CV related bug, but not image reader
     issue
   * Attach the image as an archive to the ticket, if you report some reader issue.
     Image hosting services compress images and it breaks the repro code.
   * Provide ONNX file for some public model or ONNX file with random weights,
     if you report ONNX parsing or handling issue. Architecture details diagram
     from netron tool can be very useful too. See https://lutzroeder.github.io/netron/
   -->