EnoxSoftware / OpenCVForUnity

OpenCV for Unity (Untiy Asset Plugin)
https://assetstore.unity.com/packages/tools/integration/opencv-for-unity-21088
550 stars 172 forks source link

CharUco camera calibration error #164

Open RafaDdS opened 1 year ago

RafaDdS commented 1 year ago

I'm currently using the version 2.5.4 and the example CharUco Camera calibration is not working. Most of the code for it was commented with some indications that it currently gives error. After trying to run it anyway unity crashes with the following error:

Obtained 29 stack frames
0x00007ffae211cb4e (opencvforunity) tracking_legacy_1TrackerTLD_create_10
0x00007ffae211cfb7 (opencvforunity) tracking_legacy_1TrackerTLD_create_10
0x00007ffae20dffaa (opencvforunity) aruco_Aruco_calibrateCameraCharuco_11
0x000001ee7016503e (Mono JIT Code) (wrapper managed-to-native) OpenCVForUnity.ArucoModule.Aruco:aruco_Aruco_calibrateCameraCharuco_11 (intptr,intptr,intptr,double,double,intptr,intptr,intptr,intptr,int)
0x000001ee70164e7b (Mono JIT Code) [Aruco.cs:1185] OpenCVForUnity.ArucoModule.Aruco:calibrateCameraCharuco (System.Collections.Generic.List`1<OpenCVForUnity.CoreModule.Mat>,System.Collections.Generic.List`1<OpenCVForUnity.CoreModule.Mat>,OpenCVForUnity.ObjdetectModule.CharucoBoard,OpenCVForUnity.CoreModule.Size,OpenCVForUnity.CoreModule.Mat,OpenCVForUnity.CoreModule.Mat,System.Collections.Generic.List`1<OpenCVForUnity.CoreModule.Mat>,System.Collections.Generic.List`1<OpenCVForUnity.CoreModule.Mat>,int) 
0x000001ee70164c43 (Mono JIT Code) [CameraCalibration.cs:837] CameraCalibration:CalibrateCameraCharuco (System.Collections.Generic.List`1<System.Collections.Generic.List`1<OpenCVForUnity.CoreModule.Mat>>,System.Collections.Generic.List`1<OpenCVForUnity.CoreModule.Mat>,OpenCVForUnity.ObjdetectModule.CharucoBoard,OpenCVForUnity.CoreModule.Size,OpenCVForUnity.CoreModule.Mat,OpenCVForUnity.CoreModule.Mat,System.Collections.Generic.List`1<OpenCVForUnity.CoreModule.Mat>,System.Collections.Generic.List`1<OpenCVForUnity.CoreModule.Mat>,int,int) 
0x000001ee70163b2b (Mono JIT Code) [CameraCalibration.cs:783] CameraCalibration:CaptureFrame (OpenCVForUnity.CoreModule.Mat) 
0x000001ee6aedd56b (Mono JIT Code) [CameraCalibration.cs:337] CameraCalibration:Update () 
0x000001ee702142f8 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007ffac057feb4 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke 
0x00007ffac04be764 (mono-2.0-bdwgc) [object.c:3066] do_runtime_invoke 
0x00007ffac04be8fc (mono-2.0-bdwgc) [object.c:3113] mono_runtime_invoke 
0x00007ff68c7ff644 (Unity) scripting_method_invoke
0x00007ff68c7deee4 (Unity) ScriptingInvocation::Invoke
0x00007ff68c7c7ff4 (Unity) MonoBehaviour::CallMethodIfAvailable
0x00007ff68c7c80e2 (Unity) MonoBehaviour::CallUpdateMethod
0x00007ff68c2b5ce8 (Unity) BaseBehaviourManager::CommonUpdate<BehaviourManager>
0x00007ff68c2bd2da (Unity) BehaviourManager::Update
0x00007ff68c4cfadd (Unity) `InitPlayerLoopCallbacks'::`2'::UpdateScriptRunBehaviourUpdateRegistrator::Forward
0x00007ff68c4b614a (Unity) ExecutePlayerLoop
0x00007ff68c4b62d6 (Unity) ExecutePlayerLoop
0x00007ff68c4bc389 (Unity) PlayerLoop
0x00007ff68d4005a9 (Unity) PlayerLoopController::UpdateScene
0x00007ff68d3fe7ab (Unity) Application::TickTimer
0x00007ff68d84ea3a (Unity) MainMessageLoop
0x00007ff68d8532fb (Unity) WinMain
0x00007ff68ebf4fbe (Unity) __scrt_common_main_seh
0x00007ffb35be26ad (KERNEL32) BaseThreadInitThunk
0x00007ffb3762a9f8 (ntdll) RtlUserThreadStart

Is there an older version where the charUco calibration is working?

hummlj commented 8 months ago

Same issue with 2.5.6. (Sept. 2023 update). Any idea how to fix the Charuco camera calibration?

EnoxSoftware commented 8 months ago

As mentioned in the comments here, there seems to be an unresolved bug in aruco's ChAruco board-related methods, including calibrateCameraCharuco. https://github.com/opencv/opencv/issues/23493#issuecomment-1510536940 The opencv aruco class has had some destructive fixes over the last year and this year, but still does not seem to have been validated with sufficient test code or sample code.

hummlj commented 8 months ago

I see. Thank you for the immediate response!