Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UnityAR - ARToolkit Interface

Discussion in 'Made With Unity' started by Christian, Sep 22, 2009.

  1. carllooper

    carllooper

    Joined:
    Aug 8, 2009
    Posts:
    64
    Well,the 30 days has now passed and it's still working just as well.

    I installed unity 2.6.0 on 24 October 2009.
    And it is now 9 Dec 2009.

    You can download unity source files (Windows only) for this test here:

    http://members.iinet.net.au/~carllooper/unityDLL/06_UnityAccessDLL.zip

    Just open the project and press the play button. A little MessageBox will appear. If you look at the script, "MessageBoxTest.", you'll see it uses a system DLL ("user32.dll") for the MessageBox.

    Carl
     
  2. Dsgrace

    Dsgrace

    Joined:
    Jan 9, 2010
    Posts:
    1
    Have been playing with UnityAR for a week now and really like it. Would like to be able to use a multimarker setup for only one model. ARtoolkit has this ability but I can't figure out how to have UnityAR do it. Not a programmer, more of a hobbyist, but would love a "point in the right direction".

    Thanks,
    David Grace
     
  3. dart

    dart

    Joined:
    Jan 9, 2010
    Posts:
    211
    Hi
    After reading all the topic, there was an answer about the DLL NOT FOUND problem posted by @indy138. I installed the VC redistributable but it's still not working. Where's the dir these DLLs are supposed to be installed at? I will try to copy the DLL to the Plugin directory of the Demo, but if anyone has a better solution to this problem, please share.
     
  4. beayfergm

    beayfergm

    Joined:
    Feb 11, 2010
    Posts:
    14
    I´m having just the SAME error. I´ve posted here: http://forum.unity3d.com/viewtopic.php?p=288084, but at the moment I´ve not found any solution...
     
  5. Animaleante

    Animaleante

    Joined:
    Apr 3, 2009
    Posts:
    28
    Have you guys read the whole 3rd page of this topic?
    If so, give a shout, I might be able to help some more.
     
  6. ahvin2020

    ahvin2020

    Joined:
    Apr 24, 2010
    Posts:
    1
    Hi, just wanna confirmed that the method suggested by Animaleante works perfectly.

    *edit
    But when I tried to run on another machine, it does not work. I installed VC Redistributable but the same error occurs..

    *edit
    Found the problem. The webcam is incompatible. It works on other machines
     
  7. dbp

    dbp

    Joined:
    Mar 3, 2010
    Posts:
    324
    very nice work. thanks for the work and especially for the good demo file.
    the only problem i have always had with the ARToolkit is the tracking quality. it's a pretty good tool to get started in AR applications, but there's no way i'd use it for commercial applications because of the tracking quality. other tools may be a little bit more expensive but at least they track better
     
  8. yosh

    yosh

    Joined:
    Mar 13, 2009
    Posts:
    142
    Hi,
    i´ve just downloaded the UnityAR-Toolkit and it works. But only in game-mode - not in standalone. Ok, i know that plugins are only working as a standalone (not webplayer) but then i´m wondering why it doesn´t work.

    How does your project work?
    Thanks for your help
     
  9. kris

    kris

    Joined:
    May 21, 2010
    Posts:
    3
    hi there,

    currently working on a similar issue and just had a slight epiphany i'd like to share with you.
    so what you want to do is to force power of two dimensions of your Texture2D as it speeds up the Apply() call a LOT.
    another tweak is to always use TextureFormat.ARGB32 over RGB24 for example, seems to need less marshalling.

    here some results straight from my current test bed:

    new Texture2D(1023, 1023, TextureFormat.RGB24, false)
    18 fps

    new Texture2D(1023, 1023, TextureFormat.ARGB32, false)
    21 fps

    new Texture2D(1024, 1024, TextureFormat.RGB24, false)
    127 fps

    new Texture2D(1024, 1024, TextureFormat.ARGB32, false)
    140 fps

    quite a difference. now i can concentrate on speeding up the code actually setting the pixels without having to worry too much about Apply() calls.. yay!

    so as for the webcam streaming (and every other texture manipulating issues) i suppose you're better off creating the next highest power of two texture size fitting the camera image (and crop it with uv-coords maybe?).

    ah, and since i'm registered now: interesting stuff, carllooper :) your posts pushed me in the right direction.

    cheers
     
  10. pixin

    pixin

    Joined:
    Aug 10, 2009
    Posts:
    11
    so, in conclusion Unity can't run AR application in webplayer or in executable, just in unity editor ?? so any solution ???
     
  11. pixin

    pixin

    Joined:
    Aug 10, 2009
    Posts:
    11
    sorry but im new to unity, but i heard that there is a connection between Fkash and unity, so we can use unity for it's 3d capabilities and flash for its ease of use for camera and streaming.. any one got an idea or a tutorial for that?? thanks in advance ...
     
  12. pixin

    pixin

    Joined:
    Aug 10, 2009
    Posts:
    11
  13. PabloKC

    PabloKC

    Joined:
    May 29, 2010
    Posts:
    1
    Hi guys, i'm having a problem with "getDetectedTranslationRotation" when i took out the marker, the object stays in the plane, and don't go to the standard position. How do you fix that?
     
  14. strafwerk

    strafwerk

    Joined:
    Jun 1, 2010
    Posts:
    4
    I've been experimenting with UnityAr for some time now and I keep noticing the models seem to be stuck on some kind of grid.

    Does anyone know how to make the models take smaller steps when changing position, making the animation smoother?

    Now it seems like the models only can change position and rotation by 5 or more points at once.

    I really hope I can get an answer... it would really help me a lot!
     
  15. strafwerk

    strafwerk

    Joined:
    Jun 1, 2010
    Posts:
    4
    Problem solved!
    In ArDemo.cs, lines 170 171:

    Code (csharp):
    1. if(Vector3.Distance(obj[i].position, newPos) > 10f) obj[i].position = Vector3.Lerp(obj[i].position, newPos, Time.deltaTime*100);
    2.            
    3. if(Quaternion.Angle(obj[i].rotation, newRot) > 5f) obj[i].rotation = Quaternion.Slerp(obj[i].rotation, newRot, Time.deltaTime*100);
    Change 10f and 5f to lower values. I tried 1 for both and it works perfectly now!
     
  16. strafwerk

    strafwerk

    Joined:
    Jun 1, 2010
    Posts:
    4
    Another question I can't answer:
    How can I flip the camera-image?
    Now it is mirrored, but I need the image to be normal.

    I'd appreciate any help...
     
  17. strafwerk

    strafwerk

    Joined:
    Jun 1, 2010
    Posts:
    4
    And again... fixed it.

    The solution was to flip the webcamplane (set x-scale to negative value). And to make sure the position of the objects also get flipt I've changed the following code:

    ArDemo.cs lines 167 and 168:
    Code (csharp):
    1. Vector3 newPos = new Vector3(-(float)trans[0] * 1.5f, -(float)trans[1] * 1.5f, (float)trans[2]);
    2. Quaternion newRot = new Quaternion((float)rot[0], (float)rot[1], -(float)rot[2], (float)rot[3]);
    Change it to:
    Code (csharp):
    1. Vector3 newPos = new Vector3((float)trans[0] * 1.5f, -(float)trans[1] * 1.5f, (float)trans[2]);
    2. Quaternion newRot = new Quaternion(-(float)rot[0], (float)rot[1], -(float)rot[2], -(float)rot[3]);
    In the first line, I've removed "-" after the first "(", and in the second line I've added a "-" after the first "(" and one before "(float)rot[3])".

    If anyone knows a better solution please inform me. I really doubt my way is the way to go, but for now it will do.
     
  18. dan043

    dan043

    Joined:
    Jun 26, 2010
    Posts:
    1
    Hi Christian, is possible with your beta UnityAR to make something like this? http://www.youtube.com/watch?v=7JWk_JIE3Ow

    I need to do one application where I can control one 3d object, with two or more markers... then one marker is for position of object, and the others two for cover or rotate and make some function (3D object animation or effects)

    How can I control the markers with your great UnityAR plugin? to do the logical division: marker for object and this marker for functions?

    I do it this with FLARManager but I'm tired of Away/papaervision3D "face broken" problems...

    Can you help me please?
     
  19. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    read the stuff inbetween the //////////// code above and below the dashes is for placement etc..

    void LateUpdate()
    {

    for(int i=0; i<obj.Length; i++){

    double[] trans = new double[3];
    double[] rot = new double[4];

    //////////////////////////////////////

    if(getDetectedTranslationRotation(trans, rot, i)){ //
    print ("something detected");
    }
    if(getDetectedTranslationRotation(trans, rot, 0)){ //
    print ("first marker detected");

    //Instantiate or make renderer.enabled = true; on linked object etc...

    }

    if(!getDetectedTranslationRotation(trans, rot, 0)){ //
    print ("first marker not detected");

    //Destroy or make renderer.enabled = false; on linked object etc...

    }
    if(!getDetectedTranslationRotation(trans, rot, i)){ //
    print ("nothing detected");
    }

    ////////////////////////////////
    if(!getDetectedTranslationRotation(trans, rot, i)){ //
    continue;
    }

    !Justin ^-^
     
  20. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    Um.. this might be obvious but, you should take the values from the instantiated object of i/Obj. i.e transform.position.x etc and use them as values to control your AR world/interactions.

    Very, very easy once you understand this ^-^

    The rest is just your understanding of 3d and unity3d etc.
     
  21. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    RE: dan043

    That AR example is easily done. Create the 3d assets, texture them and animate them seperately. Create a null and assign it to the i/obj of the marker. i.e Hiro is 0 default. Parent the 3d animated figure to the null. then use programming for each of the markers used i.e

    if(!getDetectedTranslationRotation(trans, rot, 0)){
    animation.play ("animation 1/hiro marker animation");
    }

    done =)
     
  22. magichere

    magichere

    Joined:
    Sep 2, 2009
    Posts:
    4
    Christian ,I got the same problem . Can you teach us how to make UnityAR Demo run in standalone mode . (except webplayer)
     
  23. matrix211v1

    matrix211v1

    Joined:
    Jan 20, 2009
    Posts:
    193
    Hello all!

    I am trying to rotate my Giraffe so he is "standing" on the marker, much like his legs are touching the black square but no matter what I try, it's always a sideways view.

    And second, the Giraffe seems to stay on the screen even after I remove the paper with the marker. Is there anything I can check to see like "I don't see marker, hide all meshes"?



    Thanks!
     
  24. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    RE:matrix211v1;

    Change the orientation in your 3d package.

    i.e if it is 90degrees to much in Z, then rotate it -90 degrees in your 3d package.
     
  25. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    RE:matrix211v1

    Plz read my previous posts for to solve the "sticking on screen" problem.
     
  26. Checco-Esimple

    Checco-Esimple

    Joined:
    Feb 14, 2008
    Posts:
    82
    any hope to have it on iPhone? also if it involves unity 3.0....
     
  27. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    possibly on iphone4 (hardware issues on previous models), obviously not on ipad (no camera). I don't know enough of 3.0.
     
  28. Sypress

    Sypress

    Joined:
    Sep 15, 2010
    Posts:
    2
    First time poster, Unity newbie here. I was curious how does one actually "install" this into Unity. The website for documentation seems to be down.

    Thanks!
     
  29. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    RE Above: You don't install unityAR, its a script on the WebcamPlane. Its best if you download the demo scene and use it to create whatever you want :)
     
  30. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    You could possibly re-roll the whole bloody thing in managed code.
     
  31. Bren

    Bren

    Joined:
    Aug 28, 2008
    Posts:
    191
    Er, I was able to get this running in a Windows standalone.
     
  32. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    Its easy. Just copy and paste the second data folder with the .patt files into the data directory.

    For webplayer. I rewrote the script as a core unity C++ plug-in instead of a C# dll hence avoiding the dll export proplem with unity web-player. fixed the update () bottleneck for high end user cameras.
     
  33. yangcheng

    yangcheng

    Joined:
    Apr 29, 2009
    Posts:
    18
    HI,Christian .first,thanks for your UnityAR_v01_beta.Can I ask you a question?about UnityAR_v01_beta. i'm having a problem with "getDetectedTranslationRotation" when i took out the marker, the object stays in the plane, and don't go to the standard position. How dofix that?
     
  34. yangcheng

    yangcheng

    Joined:
    Apr 29, 2009
    Posts:
    18
    Can I ask you a question?about UnityAR_v01_beta. i'm having a problem with "getDetectedTranslationRotation" when i took out the marker, the object stays in the plane, and don't go to the standard position. How do fix that?thanks. :(
     
  35. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    }
    if(!getDetectedTranslationRotation(trans, rot, i))
    }

    ! means not equal to (marker not seen) without the ! it is true (marker seen)
    trans refers to a vector 3 displacement specify
    rot refers to a rotation you can specify
    i refers to the marker number starting at 0. (i = all, 0 = first marker)

    hence something like
    }
    if(!getDetectedTranslationRotation(trans, rot, i))
    print ("do something");
    }

    means if any marker is NOT seen do whatever is within the if statement.

    }
    if(getDetectedTranslationRotation(trans, rot, i))
    print ("do something");
    }

    means if any marker IS seen do whatever is within the if statement.

    }
    if(getDetectedTranslationRotation(trans, rot, 0))
    print ("do something");
    }

    means if the first/default (should be Hiro marker) IS seen do whatever is within the if statement. (in the above case print "do something")

    if you use the visibly attributes or destroy and instantiate you can remove the markers. (i.e if getDetectedTranslationRotation is true visibility is on if false its invisible)
     
  36. skvettn

    skvettn

    Joined:
    Jul 20, 2010
    Posts:
    1
    Hi, I have built a project with the UnityAr.dll and have encountered a problem.
    when I use Build&Run the application start and function properly, but when I restart the application it fail to connect to the camera?
    Any solutions?

    output_log:
    Player: init engine
    Direct3D:
    Version: Direct3D 9.0c [nvd3dum.dll 8.17.11.9745]
    Renderer: NVIDIA GeForce GTS 250
    Vendor: NVIDIA
    VRAM: 512 MB
    desktop: 1680x1050 59Hz; virtual: 3600x1080 at -1920,-30

    Found 2 devices.
    UnityEngine.Debug:Log(Object)
    ArDemo:Start()
    (Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 1783)
    0: Creative WebCam Live! Ultra (VFW)
    UnityEngine.Debug:Log(Object)
    ArDemo:Start()
    (Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 1783)
    1: Creative WebCam Live! Ultra #2
    UnityEngine.Debug:Log(Object)
    ArDemo:Start()
    (Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 1783)
    Error while connect to device.
    UnityEngine.Debug:Log(Object)
    ArDemo:Start()
     
  37. the_gnoblin

    the_gnoblin

    Joined:
    Jan 10, 2009
    Posts:
    722
    So you say that now AR can be used in webplayer, right?

    If yes, then could you share the code?

    thanks
     
  38. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    Hi Skvettn

    Your either didn't import the extra data folder or the camera settings are to high for streaming.
     
  39. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    @Gnoblin

    When I get time I will release a beta and installation tutorial. I've been busy till now with university.

    @Skvettn

    If that doesn't work, write a run-time loop for the camera selection variable to set at a lower setting so that it doesn't crash lower end computers and/or cameras due to insufficient specifications.
     
  40. Superflat

    Superflat

    Joined:
    Mar 19, 2009
    Posts:
    354
    Has there been any progress in further developing this middleware? Last time i tried this the detection wasn't very accurate.
     
  41. JanSietsma

    JanSietsma

    Joined:
    Nov 16, 2010
    Posts:
    31
    Just note on the SetPixels()/Apply() slowness. It is _very_ slow. Taking about 24ms for me on my MacBook with a 320x480 texture. I really wanted to run on an iPhone, so I used this solution: http://forum.unity3d.com/threads/46999-Updating-Texture-from-Plugin-using-OpenGL

    So I render the texture natively in a plugin and avoid the whole SetPixels()/Apply() thing. And now I run at 30fps on the iPhone, rather the the 30fps I was getting the MacBook.

    I also started using a GUITexture rather then a textured plane. I don't know if this is better, but it sure is easier to scale and position.

    John
     
  42. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    My thanks to the notoes, was able to get my ar app to work on my iphone. :D
     
  43. murdoch_69

    murdoch_69

    Joined:
    Nov 25, 2010
    Posts:
    12
    novacom - it would be great to see this running on the standalone web player (to make it platform inspecific) I am tired of having to boot into Windoze to play around with it!
     
  44. lordsupra

    lordsupra

    Joined:
    Oct 30, 2010
    Posts:
    2
    Hello everyone, first, thank you for your plugin, wich has been for now pretty helpful for a school project.

    But, as I was finishing some works on this very project, mainly based on marker detection , suddenly as i was trying to import some new pattfiles in the object_data file, the unity debugger launch unexpected errors arround the line of code dedicated to the generation of the webcam texture. Yeah, suddenly, my cam, wich was perfectly working before this little change is not giving the value of pixels anymore. The program crash on NullReferenceException


    NullReferenceException
    UnityEngine.Texture.get_width () (at E:/BuildAgent/work/68355d6e5d19d587/Runtime/Export/Generated/Graphics.cs:843)
    UnityEngine.Texture2D.SetPixels (UnityEngine.Color[] colors, Int32 miplevel) (at E:/BuildAgent/work/68355d6e5d19d587/Runtime/Export/Generated/Graphics.cs:955)
    UnityEngine.Texture2D.SetPixels (UnityEngine.Color[] colors) (at E:/BuildAgent/work/68355d6e5d19d587/Runtime/Export/Generated/Graphics.cs:951)
    ArDemo.Update () (at Assets/UnityAr/Scripts/ArDemo.cs:274)

    on the line

    Code (csharp):
    1.  
    2. for(int y=0; y<height; y++){
    3.             for(int x=0; x<width; x++){
    4.                 getPixel(x, y, color);
    5.                 val[y*width + x] = new Color(color[0], color[1], color[2]);
    6.             }
    7.         }
    8.        
    9.         tex.SetPixels(val); //the crash is on this line in the function update  of ArDemo
    10.  
    Is It somehow related to the fact that the creation of tex object is just after upload of markers in the Start method ?
    As anyone an idea or already encountered this kind of problem ?
    What could I've done wrong in the declaration of new Markers ? I update the number of markers in the head of the file, and follow the syntax for the declaration of each patterns ...

    Thank you for reading my mess !
     
  45. Q_B

    Q_B

    Joined:
    Nov 29, 2010
    Posts:
    14
    To novacom and notoes:

    Great to know you guys are making that awesome progress with this!

    Any chance you could share it?
     
  46. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    When its finished.
     
  47. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    *its still pretty much uneditable by a non-programmer*
     
  48. Q_B

    Q_B

    Joined:
    Nov 29, 2010
    Posts:
    14
    Well, ok, it's uneditable by a non-programmer, but is it workable? By a kind of Frankenstein-coder type? :D

    I mean, I got the notion you implemented all (core funcs + general code) in a C++ plug. That should take care of the image set bottleneck, but I still don't understand how that takes care of running on web? (bare with me, as I stated above, I'm a jack-of-all-trades, by need ;) )
     
  49. novacom

    novacom

    Joined:
    Jun 30, 2010
    Posts:
    16
    "Frankenstein-coder type" - I don't understand what u mean here, a 'coder' or 'programmer' in my opinion is someone who can write a game, application or program of definitive purpose without the help of third party software such as unity3d. Just as how I wouldn't call someone who puts out a cigarette a firefighter. If this is you, your best option is to wait until its 'user-friendly'.

    "but I still don't understand how that takes care of running on web?" - In a nutshell the main problem with dll's in relation to unity3d is that when you publish a dll in the web player certain files including the dll are excluded from the playable export. I'm not sure what I am allowed to post in this forum, so ill just say that I 'fixed the main problem'.

    I have given the project to some of my friends to tinker with and hopefully finish as I have academic obligations that draw my attention elsewhere. I'll attach in the thread once its finished. I'm working on another project right now so this will likely be my last post in this thread until its finished.
     
  50. Q_B

    Q_B

    Joined:
    Nov 29, 2010
    Posts:
    14
    Well, what I mean is that I have ... basic ... coding knowledge, and am quite adaptable to any language (given enough time and reading resources). That also means that normally (due to lack of said time and resources ;) ) I tend to skim lightly over the code, bang on it and shake it, see what falls off and what sticks, and then usually piece together some kind of working solution to the problem at hand, using a mix from my code, and others people code.

    I hope you liked my colorful explanation :D !

    Now, I absolutely agree the proper way of coding and doing things is as you described ... unfortunately, and I won't bother you with the specifics, I definitely never have the time or resources to work "the proper way".

    So I'll try to ask in a different way: with the original C# script, I could look lightly over it, understand its functionalities up to the point I could use it, and then change and implement new stuff on top / besides the existing code.
    What I was asking was if you have an equivalent implementation (C++ ? ) that you could share, unoptimized as it may be?