Search Unity

Unified Coordinate System for String and QCAR

Discussion in 'Scripting' started by Elecman, Oct 15, 2011.

  1. francesco_ini

    francesco_ini

    Joined:
    Sep 17, 2012
    Posts:
    9
    Hi Elecman,
    thanks for your system.

    we are testing the UCS basic scene you provided in the package. (with latest version of Vuforia)

    - I follow your Documentation, and i build the UCS scene provided on my Ipad/Android Tablet but when it starts we see the camera view flipped and zoomed.

    - If i try the same scene in my laptop in game mode the camera view goes correctly but the VidTextPatch and VidTexDeform (with the default marker provided) show me not only the marker but also much space around.

    - We want to figure out how to use the VidTextPatch and grab what we have on the plane to be saved as a texture to be used later.

    Thanks

    Francesco
     
  2. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    It sounds like something went wrong with the UV mapping of the effect.

    -Did you use Landscape mode on the mobile device?
    -Does ShouldFitWidth() in ARWrapper.cs return true?
    -Try to revert the direction in the shader if the video feed appears flipped:
    Code (csharp):
    1.  o.uv.x = (0.5f*screenSpacePos.x) + 0.5f;
    change to:
    Code (csharp):
    1.  o.uv.x = -(0.5f*screenSpacePos.x) + 0.5f;
    -The UV mapping is calculated in ARWrapper.cs in a function called CalculateShaderUVMapping(). Have a look if it makes sense.

    I didn't try the latest Vuforia version yet but I will have a look.

    Let me know if you get it to work. Sorry for the late reply. Post me a mail at bitbarrelmedia at g mail. c(0)m for a faster response.

    Edit:
    I just tried Vuforia 2.6.7 and it works on my Asus TF201. Which android are you using?
     
    Last edited: Nov 14, 2013
  3. bitbarrel

    bitbarrel

    Joined:
    Nov 14, 2013
    Posts:
    2
    subscribing
     
  4. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    Hi Elecman, I read that I can use UCS without marker. ( no markers need to be stitched together a universal coordinate system is not needed )
    I is possible for me to use, this Universal Coordinete system, that an can turn around a 3D obj, placed in the middle of a room without a marker?
     
  5. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    How can I initializing a SLAM map? can u help me.
     
  6. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    Yes, that can be done using PointCloud (uses SLAM technology) but you don't need UCS for that. UCS supports PointCloud though by placing the scene in the correct orientation.

    Have a look here:
    http://pointcloud.io/

    Then download UCS and read through the manual on how to set up PointCloud and how to initialize the SLAM map. Let me know if you have any problems.
     
    Last edited: Nov 21, 2013
  7. francesco_ini

    francesco_ini

    Joined:
    Sep 17, 2012
    Posts:
    9

    Hi Elecman,

    "on my Ipad/Android Tablet but when it starts we see the camera view flipped and zoomed. " - i solved it using autorotation and select landscape right and left ... do i use portrait?

    "If i try the same scene in my laptop in game mode the camera view goes correctly but the VidTextPatch and VidTexDeform (with the default marker provided) show me not only the marker but also much space around."
    -->We have tried your scene in play editor and everything is fine only if i select Free Aspect in the Game View. If i change for example to 4:3 (ipad landscape) it show me not only the marker but also much space around.

    so how can i set it to go with this proportion?

    Thanks a lot

    Francesco
     
    Last edited: Nov 21, 2013
  8. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    Select File->Build Settings -> Player Settings-> Resolution and Presentation -> Default Orientation: set to Landscape Left. Any orientation other then Landscape Left is not supported. I forgot to put that in the manual. Auto rotation is not supported as well. Portrait is not supported either.

    Changing the aspect ratio (by dragging the window with the mouse or setting a fixed aspect ratio) once the Editor is in Play mode is not supported. First quit Play mode, then change the aspect ratio (either standard or non-standard), then enter Play mode again.
     
    Last edited: Nov 22, 2013
  9. francesco_ini

    francesco_ini

    Joined:
    Sep 17, 2012
    Posts:
    9
    Ok Elecman, thanks for your reply but we also have problem with VidTexPatch.

    You told us to verify if ShouldFitWidth() in ARWrapper.cs return true.

    We have tested it and we notice that:

    - the only cases this boolean value became true is when the aspect ratio ( screenAspect) is more than 1.75
    [ Screen.width/Screen.height > 1.75]


    Results on devices:

    Iphone5 - 1136x640 (Aspect Ratio = 1.77) - VidTextPatch works correctly

    Iphone4 - 960x640 (Aspect Ratio = 1.5) - VidTextPatch not works correctly

    Ipads - 1024x768 / 2048x1536 (Aspect Ratio = 1.3333) - VidTextPatch not works correctly

    Samsung Galaxy tab plus - 1024x600 (Aspect Ratio = 1.70) - In this case it works correctly (even if the aspect ratio is < 1.75) because when the app start there's also the Android bar so the application goes on 1024x552 (Aspect Ratio = 1.85)

    So we're asking if ShouldFitWidth() is false that means the VidTextPatch will work in a wrong way?

    If it works with you when " ShouldFitWidth()==false " so maybe we have installed UCS not correctly??


    Thanks a lot for support
     
  10. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    Ok, thanks for letting me know. I didn't know this is actually a problem with certain devices.

    I will fix it but it will take some time as I am very busy at the moment. You can have a look at the original Vuforia scripts (from the Vuforia Unity SDK) to see how they deal with this problem. They also use a function called ShouldFitWidth and scale the video texture accordingly. See if you can reproduce that. I will have a look at it in a few weeks time.

    The reason it doesn't work at the moment if ShouldFitWidth returns false is that the video texture will be clipped from the side instead of the top (if memory serves me correctly, or maybe the other way around) and this is not taken into account in the shader.

    Can you tell me what the imageSize and textureSize is in SetupVideoBackground() (called from Vuforia.cs) on the iPad?
     
    Last edited: Nov 23, 2013
  11. francesco_ini

    francesco_ini

    Joined:
    Sep 17, 2012
    Posts:
    9
    Ok Elecman,

    thanks a lot for your continuous support.

    We have installed it again and test again on Ipad retina,Ipad non retina and android tablet. now everything goes correctly.

    We noticed again that if we are using Unity PlayMode with the computer camera, we should use "free aspect" in the game view and any other ratios give us a wrong results. Infact in the playMode the imageSize and textureSize remains fixed with all ratios.

    To check (for example) 4:3 aspect ratio you have to build it on the device, here the textureSize changes.

    Thanks a lot

    F.
     
  12. albertoGanAvi

    albertoGanAvi

    Joined:
    Oct 25, 2013
    Posts:
    2

    Sorry, where can I find the file where the recording process write the tarjets' data?

    Must be in my device in text file??

    I look for this in the foro but i dont find a specific answer

    I am working with android,

    thank you
     
  13. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    @francesco_ini:
    Can you tell me in detail (reproducible) how you get the incorrect mapping in Play mode? If you start Play mode and then change the aspect ratio (by dragging the window or selecting a fixed aspect) then you will get incorrect mapping. This is because the program sets the parameters at start up only and if you change the aspect ratio in mid-game, you will get errors. So the way it is supposed to work is:

    -Do not use full screen.
    -Stop Play mode (if not already stopped)
    -Set the aspect ratio by dragging the window or selecting a fixed aspect ratio.
    -Enter Play mode
    -Check mapping
    -Stop Play mode
    -Change aspect ratio
    -Start Play mode
    -Check mapping
    -Etc.

    @albertoGanAvi:
    Where you can find the file depends on the platform you are running on. It is also different if you run in the Editor or as a standalone app. On the PC or MAC the easiest way to find the file is just doing a search for a *.ucs file (on every partition you have). For all other platforms, try looking up what Unity uses as "persistentdatapath". Trying to extract the file on IOS can be eh... interesting due to Apple's obsession with control. Or maybe try the documents folder.

    Edit:
    On Android the path is /data/data/com.mycompany.myapp/files or mnt/android/data/application-bundle-identifier/ Maybe do a file search as well.
     
    Last edited: Nov 27, 2013
  14. gringofxs

    gringofxs

    Joined:
    Oct 14, 2012
    Posts:
    240
    Elecman. It is possible to do, Image Recognition and 3D Tracking (SLAM)

    So in addition to SLAM, which tracks 3D spaces, we also recognise and track 2D images. Can be done with UCS-Vuforia for Unity?
     
  15. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    SLAM and image recognition cannot be mixed at the moment unfortunately.
     
  16. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    New version uploaded: v1.2

    Changelog v1.2:
    -Fixed compatibility issue with Vuforia 2.8
    -Simplified Vuforia installation.
    -Added support for the StudierStube Tracker AR engine.
    -Fixed bug which caused a crash if an image target dataset contains more markers then specified.
     
  17. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    Can I set up the targets manually? I know all the measurements and have built the room as a 3D object and put know where all the targets are?

    I am trying to make it work like USC. I also then want end users to be able to modify where the targets are on the walls so it is important I can place them in the app.
     
  18. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    Not out of the box. I get this feature request a couple of times already but personally I don't see the benefit of that. All the rotations are stored as a quaternion and that is not easily dealt with manually. Also, you will have to figure out which marker links to which, since the marker space can be big (like with the Valve VR demo, UCS can do that as well). Doing this manually is not reliable since you will have to solve for the camera transform beforehand.

    What would be a better approach though is record the scene first and then edit the stored position and orientation of the markers to iron out small recording inaccuracies. The variables are stored in plain text but with no header to say which marker is which. I will add that to the to-do list.

    Modifying marker positions on the fly is already supported via the "merged scenes" feature. You can have only one (or more) marker act like a separate scene, which acts like an individual marker. This can be used to have a Valve-style room full of markers, and some (or one) marker(s) on a moving door in the room as well.

    Let me know if that helps anything.
     
  19. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    Thanks for the reply. Is this something I could do out of the box or do I need to use a system like yours?

    I guess I was hoping there was a simpler way since I knew where everything was and the room is a box.
     
  20. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    what is Valve VR demo?
     
  21. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
  22. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    Looks awesome, shame there is no video on the link. Searching for it on youtube doesn't help either.

    I will try using UCS to setup the room.

    I am making a game where I want someone to be able to build/sculpt something in a room. So all I need it for the world to use a certain coordinate system I can code in and then the AR camera to display this so you can explore and walk around and in it.
     
  23. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    UCS will work great for that. Also, if you don't want the user to record a scene, you can ship the app with a pre-recorded scene. But of course that will only work if you provide the markers which are locked in place.
     
  24. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    Okay I have followed all the instructions but I am kind of a bit lost.

    For a test I just laid down 4 targets on the floor (they are 60cm by 60cm 5 star vuforia) I hit record (used a hd web cam attached to my laptop) and got each of the targets to get a blue box appear above them and also clicked on one to make it world centre.

    Now I hit save scene but I don't know where to go now.

    What I really want is to be able to open the scene in unity and build my game around it. It is a reasonably complex building game so I wanted to just set the scene up and then develop inside it. Is this possible?


    This will have a physical space people can use it, but I want them to be able to move the targets around the walls they are on for a home setup(but this is a nice to have and I just need to get the actual thing working first).

    It sounds like this would be ideal but I am not sure how to set it up properly and distribute it.
     
  25. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    After you have saved a recorded scene, press Load Scene -> Select the scene you saved -> then press Game Mode.

    If you want to use your own scene instead of one of the example scenes, you will have to follow the instructions in the chapter "Scene Setup", so yes, that is definitely possible.

    Let me know if you have any problems.
     
  26. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    Thanks for the help, but I must be doing something wrong because I can't get even the simplest thing to work. I put 4 targets on the floor and hit record and the blue squares don't even really appear close to being on the targets (i put the targets next to each other so I don't know if that makes any difference). Then when I play back with the cube is doesn't stick to a point and just floats around.
     
  27. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    If the blue squares don't stick to the targets then the UCS installation is done incorrectly. Be sure to use Vuforia 2.8.7 and UCS 1.2

    Can you tell me step by step what you did to install it?
     
  28. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    I just followed the steps in the guide I think. I looked back and I don't think I did anything extra.

    Also all of the code changes for USC that were needed in the guide appeared to be done.
     
  29. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    -Can you confirm that the "Main Camera" game object is disabled, and the "AR Camera" is enabled?
    -Is the "ResetCam.cs" script attached to AR Camera?

    If this doesn't work, please send me your entire project and I will have a look. Post me a mail at schouten underscore tjeerd at hotmail dot com with the link.
     
  30. PhilMurray111

    PhilMurray111

    Joined:
    May 19, 2013
    Posts:
    1
    hey I'm having a problem, I followed the UCS setup document for Unity and Vuforia, my game object renders but not to scale. The 3D augmented object doesnt scale when i move the camera around. for example when i move the camera close to the image targetsthe 3D object does not get bigger and if i move away it does not get smaller it just stays the same dimensions and scale and as a result it just looks like the 3D object is just imposed onto the screen and not augmented into the scene. I dont understand how to get this working could anyone give me some help or provide a video tutorial on how to get this up and running using Unity and Vuforia ?
     
  31. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    Did you try a demo scene such as a cube?

    If that does work then perhaps your game object is in the wrong location. Be sure to to set the transform to 0. Default scale might also be an issue. But try to get the demo to work first.
     
  32. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    Is it possible to make vuforia treat every target as 0,0,0 in world space?
     
  33. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    I am not sure what you mean. If every object is at position 0,0,0 in world space, they would occupy the same space (if the rotation would be the same as well). According to the Pauli exclusion principle this is impossible although I haven't managed to blow up my PC in doing so.
     
  34. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    I am just trying to figure a way to set up a scene manually and moving the object depending on which target is in view. Or forcing the targets to appear in a certain space so I can set it up manually.
     
  35. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    What I really want to be able to do is for when I look at a target for it to keep the xyz coords that I set in unity.

    Is that possible with vuforia?
     
  36. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    Yes, that is possible with Vuforia but you don't need UCS for that. Just offset your content to the marker. That should do the trick.
     
  37. smtabatabaie

    smtabatabaie

    Joined:
    May 6, 2013
    Posts:
    45
    Hello Elecman , when I try to test VidTexPatch scene after playing animation I get this result which I think is wrong in my device(Nexus 5) . I'm using UCS 1.2 and vuforia 2.8.7 and unity pro 4.3.4 . Is this something wrong with my result or it should be like this?
    thanks very much

    $UCS-screenshot.jpg
     
  38. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    That doesn't look right.
    -Do you get that result with the un-modified demo scene?
    -Does it display the same result in the Editor?
    -If you get this only with your own modified project, can you get the UCS demo scene to work?
     
  39. smtabatabaie

    smtabatabaie

    Joined:
    May 6, 2013
    Posts:
    45
    Thanks Elecman.
    -No I haven't modified the project.
    -Yes I get the same result in the editor
    thanks very much
     
  40. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    Ok, I have the same problem. Will fix it.
     
  41. smtabatabaie

    smtabatabaie

    Joined:
    May 6, 2013
    Posts:
    45
    Thanks very much, maybe I it will also solve the shader problem of camera patch in unity.
     
  42. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    I just did a quick test and it does work with UCS 1.1 and Vuforia 2.6.7. Something changed and I am not sure what. Still looking...

    Edit,
    I fixed it. The problem was caused by a new way of resetting the camera which was needed for Vuforia 2.8.7. Get the fix here:
    http://pilotpage.monosock.org/fileadmin/files/UCS12bugfix.rar
    Replace the two scripts in the Scripts folder.

    Let me know if it works.
     
    Last edited: Mar 8, 2014
  43. Tuxxo

    Tuxxo

    Joined:
    Sep 4, 2013
    Posts:
    15
    Hi Elecman, i am studing UFC system-

    it's very useful!! but i have a question..

    Should I save a marker modified and assign the texture at 3D model ..

    how can I do in the UFC?

    sorry for my bad english---




    I
     
  44. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    With UCS you cannot save textures unfortunately. Using Vuforia you can make a snapshot of a texture and use that as a marker, but this is not supported by UCS.
     
  45. Tuxxo

    Tuxxo

    Joined:
    Sep 4, 2013
    Posts:
    15
    Hi, I'm using Vuforia with the UFC, in fact I created the marker that is detected by the UFC (in blue)

    in the example of VidTexPatch, I see that as a texture is applied to the image recorded by the UFC, in fact I saved that image would be enough (only the marker that I edited later)

    how can I use this method to keep only the marker identified by your system?

    thanks
     
  46. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    Hi Tuxxo,

    Sorry for the later reply. If you want to save the texture UCS created in the VidTexPatch example, you either have to take a screenshot, or go to SpecialEffects.cs and convert the Texture2D (or RenderTexture if you have pro) to a JPG or PNG like so:
    http://docs.unity3d.com/ScriptReference/Texture2D.EncodeToPNG.html
     
  47. gersoncunha

    gersoncunha

    Joined:
    Apr 9, 2014
    Posts:
    1
    Elecman i have a problem. Im using the demo scene but i changed the dataset, but when recording the scene, I cant see the blue square when i have more than 1 image target in view. Could you tell me what im doing wrong?
     
  48. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    Perhaps "total marker amount" is set incorrectly on ARwrapper.cs. Also make sure the markers appear is sequential like: 0,1,2,3, and not 0,1,3,2 in the xml file.

    Have a look at the UCS manual, at the "Changing Markers" chapter and make sure all issues are taken into account.
     
  49. Tuxxo

    Tuxxo

    Joined:
    Sep 4, 2013
    Posts:
    15

    Hi Elecman, thanks!! i converted the Texture2D in PNG format, but the screenshoot is all camera, how do I print only the blue area identified by your system?

    thank!!
     
  50. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,373
    First you have to place the marker object (which contains the frozen video texture) directly in front of the camera so it fits perfectly in the camera view frustum. Then take a screenshot and convert it to png. This way your screenshot is automatically stretched, cropped, and geometry corrected.