yukihiko / ThreeDPoseUnitySample

Unity sample of 3D pose estimation
363 stars 77 forks source link

On Hololens: Unable to load DLL 'OpenCvSharpExtern' OR SpringManager.cs(72,42): error CS1061: 'Type' does not contain a definition for 'GetField #4

Open juansuerogit opened 4 years ago

juansuerogit commented 4 years ago

Yukihiko,

We are able to play your sample with our own video by pressing play inside Unity 2018.4.7f1

But on the Microsoft Hololens we get DllNotFoundException: Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found.

To get your project into Hololens we click on "use WebCam" in your project. And then we build to run on the hololens which is x86 and windows universal platform as seen in the screenshot below.

We are not sure what to do. We tried copying your OpenCvSharpExtern dll to various places in the folders that were built before pushing to hololens but still doesnt work.

When we switch the scripting backends in the player settings from IL2CPP to .NET then we get a build error inside Unity when we try to build for Windows Universal

Assets\unity-chan!\Unity-chan! Model\Scripts\SpringManager.cs(72,42): error CS1061: 'Type' does not contain a definition for 'GetField' and no accessible extension method 'GetField' accepting a first argument of type 'Type' could be found (are you missing a using directive or an assembly reference?)

image

image

image

here are the build settings inside Unity in the screenshot below. image

then when export to Visual Studio image

here is the video from the hololens and the error not working https://drive.google.com/file/d/1ru2gEQUAV6cQg9XGtjbf5CoKV6tpE_Gf/view

juansuerogit commented 4 years ago

So i went to find the 32 bit versions of OpenCvSharp3

https://github.com/shimat/opencvsharp https://github.com/shimat/opencvsharp/releases stackoverflow.com/questions/44105973/opencvsharp-unable-to-load-dll-opencvsharpextern

and that other library in there https://github.com/opencv/opencv_attic/blob/master/opencv/3rdparty/ffmpeg/opencv_ffmpeg.dll

and replaced your versions which seem to be for 64 bit ( hololens is 32 bit )

image

and i see they get loaded

[0.113927 / 0.117154] - Initializing Unity runtime Loading native plugins Loading OpenCvSharpExtern.dll 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\Template3DVS.Debug_Win32.Juan.Suero\OpenCvSharpExtern.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Unloaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\Template3DVS.Debug_Win32.Juan.Suero\OpenCvSharpExtern.dll' 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\Template3DVS.Debug_Win32.Juan.Suero\OpenCvSharpExtern.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\Forwarders\user32.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\Forwarders\comdlg32.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\Forwarders\ole32.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\Forwarders\advapi32.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\execmodelproxy.dll'. Loading AudioPluginMsHRTF.dll 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\Template3DVS.Debug_Win32.Juan.Suero\AudioPluginMsHRTF.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\HrtfApo.dll'. Loading opencv_ffmpeg.dll 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\Template3DVS.Debug_Win32.Juan.Suero\opencv_ffmpeg.dll'. Module was built without symbols. 'ThreeDPoseUnitySample.exe' (Win32): Unloaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\Template3DVS.Debug_Win32.Juan.Suero\opencv_ffmpeg.dll' 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\Template3DVS.Debug_Win32.Juan.Suero\opencv_ffmpeg.dll'. Module was built without symbols.

but then i get a bunch of other errors....

but then i get bunch of errors

onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\sensorserver.cpp(46)\Windows.Devices.Sensors.dll!64DD8581: (caller: 64DD593F) ReturnHr(6) tid(e04) 80070490 Element not found. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\rometadata.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\Windows.Globalization.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\BCP47mrm.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\BCP47Langs.dll'. Uploading Crash Report UnauthorizedAccessException: Failed getting the path of a special folder: Access Denied. at System.Environment.GetWindowsFolderPath (System.Int32 folder) [0x00000] in <00000000000000000000000000000000>:0 at System.Environment.GetFolderPath (System.Environment+SpecialFolder folder, System.Environment+SpecialFolderOption option) [0x00000] in <00000000000000000000000000000000>:0 at System.Environment.GetFolderPath (System.Environment+SpecialFolder folder) [0x00000] in <00000000000000000000000000000000>:0 at OpenCvSharp.NativeMethods.LoadLibraries (System.Collections.Generic.IEnumerable`1[T] additionalPaths) [0x00000] in <00000000000000000000000000000000>:0 at OpenCvSharp.NativeMethods..cctor () [0x00000] in <00000000000000000000000000000000>:0 at OpenCvSharp.Dnn.Net.ReadNetFromONNX (System.String onnxFile) [0x00000] in <00000000000000000000000000000000>:0 at ThreeDPoseScript.InitONNX () [0x00000] in <00000000000000000000000000000000>:0 at ThreeDPoseScript.Start () [0x00000] in <00000000000000000000000000000000>:0 Rethrow as TypeInitializationException: The type initializer for 'OpenCvSharp.NativeMethods' threw an exception. at OpenCvSharp.Dnn.Net.ReadNetFromONNX (System.String onnxFile) [0x00000] in <00000000000000000000000000000000>:0 at ThreeDPoseScript.InitONNX () [0x00000] in <00000000000000000000000000000000>:0 at ThreeDPoseScript.Start () [0x00000] in <00000000000000000000000000000000>:0

(Filename: currently not available on il2cpp Line: -1)

'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\wininet.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\tokenbinding.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\OnDemandConnRouteHelper.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\winhttp.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\winnsi.dll'.

then ...

Exception thrown at 0x7784F2B2 (KernelBase.dll) in ThreeDPoseUnitySample.exe: WinRT originate error - 0xC00D36B3 : 'The stream number provided was invalid.'. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x0234E65C. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x0234E894. Exception thrown at 0x7784F2B2 (KernelBase.dll) in ThreeDPoseUnitySample.exe: WinRT originate error - 0xC00D36B3 : 'The stream number provided was invalid.'. Exception thrown at 0x7784F2B2 (KernelBase.dll) in ThreeDPoseUnitySample.exe: WinRT originate error - 0x80040111 : 'Windows.UI.WindowManagement.DisplayRegion'. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\viewpositiontrackerinternal.h(94)\Windows.Devices.Sensors.dll!64DE33ED: (caller: 64DE240F) Exception(3) tid(1250) 80040111 ClassFactory cannot supply requested class Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0234BBD0. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\sensor.cpp(179)\Windows.Devices.Sensors.dll!64DDF4AC: (caller: 64DDB61C) Exception(4) tid(1250) 80070490 Element not found. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0234BE18. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\sensorserver.cpp(46)\Windows.Devices.Sensors.dll!64DD8581: (caller: 64DD593F) ReturnHr(3) tid(1250) 80070490 Element not found. Exception thrown at 0x7784F2B2 (KernelBase.dll) in ThreeDPoseUnitySample.exe: WinRT originate error - 0x80040111 : 'Windows.UI.WindowManagement.DisplayRegion'. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\viewpositiontrackerinternal.h(94)\Windows.Devices.Sensors.dll!64DE33ED: (caller: 64DE240F) Exception(5) tid(1250) 80040111 ClassFactory cannot supply requested class Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0234BBA8. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\sensor.cpp(179)\Windows.Devices.Sensors.dll!64DDF4AC: (caller: 64DDB61C) Exception(6) tid(1250) 80070490 Element not found. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0234BDF0. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\sensorserver.cpp(46)\Windows.Devices.Sensors.dll!64DD8581: (caller: 64DD593F) ReturnHr(4) tid(1250) 80070490 Element not found. Exception thrown at 0x7784F2B2 (KernelBase.dll) in ThreeDPoseUnitySample.exe: WinRT originate error - 0x80040111 : 'Windows.UI.WindowManagement.DisplayRegion'. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\viewpositiontrackerinternal.h(94)\Windows.Devices.Sensors.dll!64DE33ED: (caller: 64DE240F) Exception(7) tid(1250) 80040111 ClassFactory cannot supply requested class Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0234BB40. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\sensor.cpp(179)\Windows.Devices.Sensors.dll!64DDF4AC: (caller: 64DDB61C) Exception(8) tid(1250) 80070490 Element not found. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0234BD88. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\sensorserver.cpp(46)\Windows.Devices.Sensors.dll!64DD8581: (caller: 64DD593F) ReturnHr(5) tid(1250) 80070490 Element not found. Exception thrown at 0x7784F2B2 (KernelBase.dll) in ThreeDPoseUnitySample.exe: WinRT originate error - 0x80040111 : 'Windows.UI.WindowManagement.DisplayRegion'. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\viewpositiontrackerinternal.h(94)\Windows.Devices.Sensors.dll!64DE33ED: (caller: 64DE240F) Exception(9) tid(1250) 80040111 ClassFactory cannot supply requested class Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0234BC10. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\sensor.cpp(179)\Windows.Devices.Sensors.dll!64DDF4AC: (caller: 64DDB61C) Exception(10) tid(1250) 80070490 Element not found. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0234BE58. Exception thrown at 0x7784F2B2 in ThreeDPoseUnitySample.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\sensorserver.cpp(46)\Windows.Devices.Sensors.dll!64DD8581: (caller: 64DD593F) ReturnHr(6) tid(1250) 80070490 Element not found. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\rometadata.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\Windows.Globalization.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\BCP47Langs.dll'. 'ThreeDPoseUnitySample.exe' (Win32): Loaded 'C:\Windows\System32\BCP47mrm.dll'. Uploading Crash Report UnauthorizedAccessException: Failed getting the path of a special folder: Access Denied. at System.Environment.GetWindowsFolderPath (System.Int32 folder) [0x00000] in <00000000000000000000000000000000>:0 at System.Environment.GetFolderPath (System.Environment+SpecialFolder folder, System.Environment+SpecialFolderOption option) [0x00000] in <00000000000000000000000000000000>:0 at System.Environment.GetFolderPath (System.Environment+SpecialFolder folder) [0x00000] in <00000000000000000000000000000000>:0 at OpenCvSharp.NativeMethods.LoadLibraries (System.Collections.Generic.IEnumerable`1[T] additionalPaths) [0x00000] in <00000000000000000000000000000000>:0 at OpenCvSharp.NativeMethods..cctor () [0x00000] in <00000000000000000000000000000000>:0 at OpenCvSharp.Dnn.Net.ReadNetFromONNX (System.String onnxFile) [0x00000] in <00000000000000000000000000000000>:0 at ThreeDPoseScript.InitONNX () [0x00000] in <00000000000000000000000000000000>:0 at ThreeDPoseScript.Start () [0x00000] in <00000000000000000000000000000000>:0 Rethrow as TypeInitializationException: The type initializer for 'OpenCvSharp.NativeMethods' threw an exception. at OpenCvSharp.Dnn.Net.ReadNetFromONNX (System.String onnxFile) [0x00000] in <00000000000000000000000000000000>:0 at ThreeDPoseScript.InitONNX () [0x00000] in <00000000000000000000000000000000>:0 at ThreeDPoseScript.Start () [0x00000] in <00000000000000000000000000000000>:0

(Filename: currently not available on il2cpp Line: -1)

then i get

NullReferenceException: Object reference not set to an instance of an object. at ThreeDPoseScript.Predict (OpenCvSharp.Mat img) [0x00000] in <00000000000000000000000000000000>:0 at ThreeDPoseScript+d__40.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.MonoBehaviour.StartCoroutineManaged (System.String methodName, System.Object value) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.MonoBehaviour.StartCoroutine (System.String methodName, System.Object value) [0x00000] in <00000000000000000000000000000000>:0 at ThreeDPoseScript.Update () [0x00000] in <00000000000000000000000000000000>:0 UnityEngine.MonoBehaviour:StartCoroutineManaged(String, Object) UnityEngine.MonoBehaviour:StartCoroutine(String, Object) ThreeDPoseScript:Update()

(Filename: currently not available on il2cpp Line: -1)

yukihiko commented 4 years ago

Hi! Is it that OpenCVSharp doesn't work with UWP? Well, I don't know that. Since OpenCV is only used to run onnx, other OpenCV implementations may be used. For example, OpenCVForUnity. But I don't know if this works with UWP(I think x86 was supported). This page uses Unity + OpenCV + Hololens. (It's in Japanese) https://qiita.com/xsmiledur/items/127abaef42c5f1126f5e

Also, since I have moved onnx with WindowsML, I think there was a Unity WindowsML environment, so I might be able to use it...

Since SpringManager is only moving the hair, it will work even if it is deleted. Even if you watch the video, there is no hair, so you may want to change it to a Dynamic Bone.