How do I create an AR marker for Vuforia / Unity?

2020-02-06 04:04发布

问题:

This is a horribly basic question I know (!) but how do I create and import an AR marker into Unity? I know I am meant to do it through the Vuforia Marker Manager page. I have created a Target Database and I have downloaded the database, but how do I get the marker to display in Unity?

Also: what exactly is a Target Database? Is that another name for 'marker'?

回答1:

To answer your question specifically, yes your Marker is your Target.

So what you need to do is:

  • Go to License Manager. Add a License Key choosing None as your License plan.

  • Now go to Target Manager. Create a Database and add the license for it from the drop down.

  • Add Target, and select from your computer the Image that you want to be the Marker, and upload it.

  • Once the status of the Target changes to active you can click Download Database and make sure you click For UnityEditor. This downloads a .unitypackage

  • Now inside Unity, go to Assets>Import New Assets... and locate to the .unitypackage you downloaded

This is how you import your database.

If you haven't Imported the Vuforia package Unity Extension then you simply need to download it from the Downloads section and Import it through the Assets>Import Package> Custom Package

  • Now ideally to work with AR, you would use the AR Camera, which is located in your Assets Bar in Qualcomm Augmented Reality>Prefabs. Drag ARCamera onto your scene.

  • With the AR Camera selected in the Hierarchy look at the Inspector tab. You'll see Data Set Load Behavior. Under that you SHOULD see the name of the .unitypakage you imported ealier. Check the name as well as make it Active.

  • Now in Qualcomm Augmented Reality>Prefabs you should also see Image Target. Drag that onto the screen as well.

  • With the ImageTarget selected in Hierarchy look at the Inspectorthere should be Image Target Behaviour

Fill in as follows

Type: Predefined
Data Set: <Name of imported .unitypackage>
Image Target: <Name of Picture uploaded into the Database>

Now you may work around the Image Target as per your app requirement.

NOTE: In the License Manager, click on the Name of the License and you'll see a Alpha-numeric code. Copy that code, and within the Inspector of the AR Camera, under QCAR Behaviour>App License Key paste the code in. This must be done in order for your app to work on your > device.

Hope this helps you. Please feel free to ask me if anything.



回答2:

There are a couple things that you need to do before getting this to work.

Firstly, I noticed you mentioned creating a Target Database on the Vuforia website, but have you actually added any markers to it? Markers are the actual AR images that will be scanned. A Target Database is a collection of markers that can be used simultaneously in your Unity application.

Once you have your markers uploaded they should have a 2-4 star rating as shown in the picture

After downloading the database as a UnityPackage you have to import it into Unity along with the Vuforia Unity SDK.

If you are still having trouble getting an example scene running within Unity you can download a sample scene at the previous link.