v-hogood / OpenCvSdk

Android and iOS .NET bindings for OpenCV SDK:
https://github.com/opencv/opencv/tree/4.x/modules/java
5 stars 2 forks source link

Unable to use OpenCvSdk.Imgcodecs.Imdecode on MAUI iOS #5

Closed nk-alex closed 1 month ago

nk-alex commented 1 month ago

I'm using OpenCvSdk.iOS version 4.10.0 on my MAUI iOS project. I'm testing this on a real iphone. I'm trying to load a byteArray into a Mat object:

byte[] image = ....
NSData conversion = Foundation.NSData.FromArray(image);
Mat matImage = OpenCvSdk.Imgcodecs.Imdecode(new Mat(1, image.Length, CvType.Cv8uc3, conversion), (int)ImreadModes.Unchanged);

But I'm not able to successfully run OpenCvSdk.Imgcodecs.Imdecode. No exception is thrown. Application just gets killed with the following message:

The app has been terminated.
INFO: 
=================================================================
    Native Crash Reporting
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
    Native stacktrace:
=================================================================
    0x10277a3fc - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1027652e8 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1028cbfac - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x102779b
INFO: ec - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1e527ae9c - /usr/lib/system/libsystem_platform.dylib : <redacted>
    0x1e5337c0c - /usr/lib/system/libsystem_pthread.dylib : pthread_kill
    0x190843ba0 - /usr/lib/system/libsystem_c.dylib : abort
    0x10244a47c - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : xamarin_find_protocol_wrapper_type
    0x10262f808 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x10262f878 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x10262f8c4 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1027622e8 - /private/var/containers/Bun
INFO: dle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x102761dc0 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1027635dc - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x102762e34 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1027615a8 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1025dae7c - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1025d99b0 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.a
INFO: pp/MyApp : AppleCryptoNative_X509ImportCollection
    0x1025efeec - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1025f0ea8 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1025e74bc - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1024149e4 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : 
    0x102788814 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1027869a0 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x10277bb5c - /private/var/containers/Bundle/Ap
INFO: Closing debug connection from device (USB)
INFO: plication/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x10274a7c4 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1026f1f04 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x102707290 - /private/var/containers/Bundle/Application/DA8AC838-B80E-4D08-87F6-3CEC11A65085/MyApp.app/MyApp : AppleCryptoNative_X509ImportCollection
    0x1e533606c - /usr/lib/system/libsystem_pthread.dylib : _pthread_start
    0x1e53310d8 - /usr/lib/system/libsystem_pthread.dylib : thread_start

=================================================================
    Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x1d15442ec):0x1d15442dc  ff 0f 5f d6 c0 03 5f d6 10 29 80 d2 01 10 00 d4  .._..._..
INFO: )......
0x1d15442ec  03 01 00 54 7f 23 03 d5 fd 7b bf a9 fd 03 00 91  ...T.#...{......
0x1d15442fc  2a ec ff 97 bf 03 00 91 fd 7b c1 a8 ff 0f 5f d6  *........{...._.
0x1d154430c  c0 03 5f d6 10 27 80 d2 01 10 00 d4 03 01 00 54  .._..'.........T

=================================================================
    Managed Stacktrace:
=================================================================
      at <unknown> <0xffffffff>
      at MyApp.Platforms.iOS.OpenCVImplementation.Contours:ExtractObject <0x00088>
      at MyApp.Platforms.OpenCVImplementation:ExtractObject <0x00020>
      at <ProcessCapturedImage>d__47:MoveNext <0x004ca>
      at AsyncStateMachineBox`1:ExecutionContextCallback <0x00030>
      at System.Threading.ExecutionContext:RunInternal <0x00136>
      at AsyncStateMachineBox`1:MoveNext <0x00110>
      at AsyncStateMachineBox`1:MoveNext <0x0001e>
      at System.Threading.Tasks.AwaitTaskContinuation:RunOrScheduleAction <0x00118>
      at System.Threading.Tasks.Task:RunContinuations <0x00190>
      at System.Threading.T
ERROR: An error occurred while writing to the debug stream. Details: Cannot access a disposed object.
Object name: 'UsbStream'.
INFO: Closing debug connection from remote debugger (TCP)
INFO: asks.Task:FinishContinuations <0x00064>
      at System.Threading.Tasks.Task`1:TrySetResult <0x0010a>
      at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetExistingTaskResult <0x0008e>
      at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult <0x00066>
      at <CreateImageAsync>d__1:MoveNext <0x00250>
      at AsyncStateMachineBox`1:ExecutionContextCallback <0x0002a>
      at System.Threading.ExecutionContext:RunInternal <0x00136>
      at AsyncStateMachineBox`1:MoveNext <0x0010a>
      at AsyncStateMachineBox`1:MoveNext <0x0001e>
      at System.Threading.Tasks.AwaitTaskContinuation:RunOrScheduleAction <0x00118>
      at System.Threading.Tasks.Task:RunContinuations <0x00190>
      at System.Threading.Tasks.Task:FinishContinuations <0x00064>
      at System.Threading.Tasks.Task:FinishStageThree <0x0007e>
      at System.Threading.Tasks.Task:FinishStageTwo <0x00340>
      at System.Threading.Tasks.Task:Finish <0x0002c>
      at System.Threading.Tasks.Task:ExecuteWithThreadLocal <0x00360>
      at System.Threading.Tasks.Task
The app has been terminated.
INFO: Disposing input and output streams...

Am I missing something?

v-hogood commented 1 month ago

Yes I can reproduce this. Should be fixed with OpenCvSdk.iOS version 4.10.0.1 let me know if it works thanks.