NormandErwan / ArucoUnity

Bring augmented reality to Unity by tracking Aruco markers in real time.
https://normanderwan.github.io/ArucoUnity/
BSD 3-Clause "New" or "Revised" License
204 stars 38 forks source link

Exception: OpenCV(3.4.2) when in ArucoObjectDisplayer.Update () #30

Open Domihk opened 4 years ago

Domihk commented 4 years ago

The following error happens when trying to create my own marker following the tutorial, opening the scene CreateMarkers and clicking play:

Exception: OpenCV(3.4.2) c:\projects\arucounityplugin\build\opencv\opencvcontrib-prefix\src\opencvcontrib\modules\aruco\src\dictionary.cpp:169: error: (-215:Assertion failed) id < bytesList.rows in function 'cv::aruco::Dictionary::drawMarker'

ArucoUnity.Plugin.Cv+Exception.Check () (at Assets/ArucoUnity/Scripts/Plugin/Cv/Exception.cs:64)
ArucoUnity.Plugin.Aruco+Dictionary.DrawMarker (System.Int32 id, System.Int32 sidePixels, ArucoUnity.Plugin.Cv+Mat& img, System.Int32 borderBits) (at Assets/ArucoUnity/Scripts/Plugin/Aruco/Dictionary.cs:126)
ArucoUnity.Objects.ArucoMarker.Draw () (at Assets/ArucoUnity/Scripts/Objects/ArucoMarker.cs:44)
ArucoUnity.Objects.Displayers.ArucoObjectDisplayer.CreateImage () (at Assets/ArucoUnity/Scripts/Objects/Displayers/ArucoObjectDisplayer.cs:155)
ArucoUnity.Objects.Displayers.ArucoObjectDisplayer.UpdateImage () (at Assets/ArucoUnity/Scripts/Objects/Displayers/ArucoObjectDisplayer.cs:207)
ArucoUnity.Objects.Displayers.ArucoObjectCreator.UpdateImage () (at Assets/ArucoUnity/Scripts/Objects/Displayers/ArucoObjectCreator.cs:63)
ArucoUnity.Objects.Displayers.ArucoObjectDisplayer.Update () (at Assets/ArucoUnity/Scripts/Objects/Displayers/ArucoObjectDisplayer.cs:112)
Domihk commented 4 years ago

I think the error might be due to an Aruco ID not being on the dictionary. At least for me solved. Maybe we could display a custom error message in that case since I think it could be a very common scenario.