This tutorial describes the basic process of dealing with the 3D model with the NyARToolkit for Unity.
There are 4 steps.
- Preparlation of the environment
- Require hardware and data
- Modify SimpleNFT code.
- Test program
- How to make NFT dataset
Preparlation of the environment
There are preparation before development.
- Create a new Unity project
- Import NyARToolkit for Unity package
- Import SDUnityChan package
Create a new Unity project
Create an empty new Unity project. (Require Unity 5.3.4 or later.)
Import NyARToolkit for Unity package
Download NyARToolkit for Unity, and drag and drop it to Unity IDE.
Import SDUnityChan package
Download SDUnityChan, and drag and drop it to Unity IDE.
Require hardware and data
A list of required things other than computer.
- A paper that is printed Unity licence logo.
- Nft dataset that made from Unity licence ligo.
Must be connected a webcam to the computer. It is not nesseccary if your computer has internal camera device.
A paper that is printed Unity licence logo, and the NftDatset
These can also be made from the Unity logo image. Howeber for simplity, please download zip file that containe set the necessary data on this tutorial.
Print UCLlogo180mm.pdf to A4 paper. It is Unity licence logo in 180mm width.
The NftDataset is unitychan.nftdataset. It is contained with same zipfile.
Check “Neft dataset that made from Unity licence logo” paragraph if you want to make a dataset.
From here is the main.
Modify sample/SimpleNft scine to display Unity-chan on the captured image.
Edit Object tree
Open SimpleNft scene. Next, expand MarkerObject node and delete cube object.
In UnityChan/SD_unitychan/Prefab, drag SD_unitychan_humanoid prefab and drop in MarkerObject. MarkerObject is updated automaticary by marker transform matrix. The objects placed under MarkerObject is displayed on Nft target.
Copy NFT dataset file
NFT data is unitychan.nftdataset that is in the unitychan-demodata.zip.
unitychan.nftdataset is NFT data set file made from 180mm width Unity license logo.
Replaced it if you have your own data.
First, change file extention to .bytes from .nftdataset. It is necessary in order to read binary file by Unity.
Next, drag unitychan.bytes and drop to Asser/Resource directory. It is able to read file from Unity.
Setting for Unity
In NyARToolkit for Unity, the scale unit of Markerobject is treated as 1mm.
In addition, the coordinates is expressed in the XY direction. And the origin is the lower left corner of the image.
Adjust the position and size of the Unity-chan to center of logo.
Remove the SpringManager check because it does not work correctly.
Edit source code
Finally, change two point on sourcecode.
In SimpleNFT directory, open NftCameraBehaviour.cs file.
Change NFT dataset
Change nftdataset name to infinitycat from unitychan. And change the image width to 180[mm] from 160.
Remove Cube related line
Remove a cuble related line.
After complete, press the play button of Unity. Capture Unity logo image into the camera. Since the unity license logo is a little difficult to recognize. Hold the camera so that the entire logo captured.
How to make NFT dataset
You can NFT dataset from general image by tool program.
The tool is NftFileGenerator.jar. It is placed in Data/tool directory.
Open Assert directory by Explorer etc.
wp-image-1764″ src=”http://nyatla.jp/nyartoolkit/wp/wp-content/uploads/12.png” alt=”12″ width=”635″ height=”165″ />
In windows, click .bat file. other environment, open the terminal and type a command below.
java -jar NftFileGenerator.jar
After run the tool, Open a source image. Select Import from menu, and select LoadImage.
Next, push MakeFeatureSet button.
Dataset generation takes a few minutes.
When complete, feature points are displayedu
Finally, save dataset file. Select Export -> NyARTK NFT dataset file from menu. (NyARToolkit for Unity can not handle files that wrote by “Save Feature Set File”.)
- SourceDPI – This is main image DPI. Normally, do not need to change.
- Iset DPIs – Set of pyramid image resolutions. AUTO means auto caluclation from SourceDPI. Custom means manual setting which wrote in lower CSV. Normally, do not need to change.
- FSET parametor – Parametor of tracking feature points detection.(red square）In proportion to the size of lv, feature points detected is incremented. Adjust when the feature points is too much / too little.
Should be restrict a size of image under VGA size. Large image will take a long time.
If you want to use a large image, use from shrinking.
High contrast image such as Unity licence logo is poor for detection.
Neture image are more good for NFT.