-
Notifications
You must be signed in to change notification settings - Fork 15
Unity AR demo using ViSP
-
Using ViSP Unity wrapper in Unity engine
-
Unity demonstrations using ViSP
2.1. AprilTag Augmented Reality demo
2.2. Generic Model-based Tracking demo
-
Tips & Tricks
3.1. Unity crashes on MacOS
3.2. DllNotFoundException: ViSPUnity
This project contains in unityProject
folder 2 demos that illustrate ViSP Unity wrapper usage. From here we suppose that you followed the previous tutorial that shows how to build ViSPUnity
plugin that was installed in $VISP_WS/visp_unity/unityProject/Assets/
folder if you are under Linux/MacOS or in %VISP_WS%\visp_unity\unityProject\Assets\
folder if you are under Windows.
- Start Unity engine and open
$VISP_WS/unityProject
- The generated
ViSPUnity
plugin should be visible in the Assets folder
- 36h11 AprilTag can be downloaded from here.
- In
Assets > Scenes
window you should see 2 scenes corresponding to AprilTag Augmented Reality demo and Generic Model-Based Tracking demo respectively
Return to table of content.
For the first project, go to the folder Assets/Scenes
and open scene_ar
by double click.
- You should have a similar Unity window opened, as shown below:
- Click on the
Plane
GameObject in hierarchy and in the inspector window modify some demo settings:- The
Tag_size
value according to you printed tag size. This value corresponds to the dimension of the black square in meters. - Optionally you can also modify the values of your camera parameters obtained after camera calibration.
- If you have more than one camera attached to your computer, use
Camera_id
to select the camera to use. In theConsole
panel there are some logs that may help to identify each camera id. - Note also the
Debug_display
option that is disabled by default. If enabled it will open a windows in which the current image is displayed with computer vision results that may be useful to understand the low level processing achieved with ViSP.
- The
-
Notice that the gameObject
Cube
is a child of gameObjectCube_pivot
. This is done to make sure that the cube rotates around the center of one of the faces. -
The current implementation takes care of position, scaling and rotation of the cube. A small YouTube Video demonstration is also available here.
Return to table of content.
For the second project, go to the folder Assets/Scenes
and open scene_mbt
by double click.
- You should have a similar Unity window opened, as shown below:
- For this demonstration, we are using a 7cm x 7cm x 7cm cube made from cardboard. A 36h11 AprilTag (4.8cm x 4.8cm) is pasted on one of its faces for tracker initialisation. We strongly recommend to put texture on the other cube faces so that the tracker benefits from keypoint features. Here is a picture for reference:
- Click on the
Plane
GameObject in hierarchy and in the inspector window modify some demo settings:- The
Tag_size
value according to you printed tag size glued on one cube face. This value corresponds to the dimension of the black square in meters. - The
Cube_size
value according to your cube. - Optionally you can also modify the values of your camera parameters obtained after camera calibration.
- If you have more than one camera attached to your computer, use
Camera_id
to select the camera to use. In theConsole
panel there are some logs that may help to identify each camera id. - Note also the
Debug_display
option that is disabled by default. If enabled it will open a windows in which the current image is displayed with computer vision results that may be useful to understand the low level processing achieved with ViSP.
- The
- Now, click play button to start. A small YouTube Video demonstration is also available here.
Return to table of content.
This issue comes from MacOS camera authorization requested before usage in Unity.
The work around is to quit Unity Hub and launch it from a terminal:
$ /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub
If this is not enough, try to quit properly your opened applications and restart your computer.
Return to table of content.
- Check if in
$VISP_WS/visp_unity/unityProject/Assets/
there is theViSPUnity
plugin namedViSPUnity.dll
under Windows,ViSPUnity.so
under Ubuntu andViSPUnity.bundle
if you are on OSX. - If the file is missing, it means that you forget to call
make install
after buildingvispWrapper
project as explained in the previous tutorial. - If the file is present, quit Unity, start Unity and try to run again
unityProject
.
When you change the code in vispWrapper
project and do a fresh installation using make install
that copies the bundle in the unityProject/Assets
folder, you should quit and restart Unity to reload the modified plugin.