Search Unity

Unified Coordinate System for String and QCAR

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

  1. Dover8

    Dover8

    Joined:
    Aug 20, 2010
    Posts:
    94
    Would be good to still support 3.5 for those of us who haven't paid for the jump to 4. Developing on Win8 for Android deployment, though any final implementation will inevitably end up on iOS.
     
  2. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    @gringofxs
    I had a look at your project and I see that you are getting a black screen because all the variables in the scripts are null. I have seen this one time before with someone and are not sure why this happens. In order to solve this issue, I need you to tell me exactly step by step what you are doing when you are installing UCS. Please make a new project and follow the installation manual carefully. Then give me an exact description of what you are doing.

    @Dover8
    I tried installing UCS by extracting the package in Unity 4 and then copying the files to Unity 3.5 and you are right that it doesn't work. I suppose that even the scenes are not backwards compatible. I think I can get it to work by exporting UCS from within Unity 3. But this is going to be a lot of work because I need to build all the scenes from scratch, set the variables on the scripts, etc. Let me try to find a way to make the backwards compatibility issue to work first.

    Edit:
    It seems to be impossible to make a Unity 4 project backwards compatible with Unity 3.5. I am not sure if I will make a port which is compatible with Unity 3.5 due to the large amount of effort required... You can always do it yourself though. Maybe if you need to have just one scene up and running, it is not too much work. Load the scene in Unity 4 at a different PC. Make a new project in Unity 3.5 and create everything from scratch, using the 4.0 installation as a reference. The scripts and shaders should work without too much modifications. You need to create all the prefabs (I think), scenes, public variable settings etc from scratch.
     
    Last edited: Feb 28, 2013
  3. Dover8

    Dover8

    Joined:
    Aug 20, 2010
    Posts:
    94
    Do you not have an old backup version that worked in 3.5? (Sorry for sounding like a lecturer, "Always keep a backup!")
     
  4. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    The only backup I have is an old version which doesn't work with Vuforia 2.0 so that is of no good.
     
  5. gringofxs

    gringofxs

    Joined:
    Oct 14, 2012
    Posts:
    240
    @Elecman

    Ok, the manual says.

    1 Open QCARBehaviour.cs (in Qualcomm Augmented Reality/Scripts folder). Go to the beginning of the
    Update() function and change it so it looks like this:

    you said to chage all this from the original QCARBehaviour.cs script?

     
  6. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    Yes. To be more precise, the entire function should look like this:

    Code (csharp):
    1.  
    2. // Updates the scene with new tracking data. Calls registered
    3. // ITrackerEventHandlers
    4. void Update()
    5. {
    6.     Camera.main.transform.position = Vector3.zero;
    7.     Camera.main.transform.rotation = Quaternion.identity;
    8.  
    9.     if (QCARManager.Instance.Initialized)
    10.     {
    11.         // Get the current orientation of the surface:
    12.         ScreenOrientation surfaceOrientation = (ScreenOrientation)QCARWrapper.Instance.GetSurfaceOrientation();
    13.  
    14.         // Check if we need to update the video background configuration and projection matrix:
    15.         CameraDeviceImpl cameraDeviceImpl = (CameraDeviceImpl)CameraDevice.Instance;
    16.         if (cameraDeviceImpl.CameraReady  
    17.            (QCARUnity.IsRendererDirty() || mProjectionOrientation != surfaceOrientation))
    18.         {
    19.             ConfigureVideoBackground(false);
    20.             UpdateProjection(surfaceOrientation);
    21.             cameraDeviceImpl.ResetDirtyFlag();
    22.         }
    23.  
    24.         // Bind a simple material to clear the OpenGL state
    25.         mClearMaterial.SetPass(0);
    26.  
    27.         // QCARManager renders the camera image and updates the trackables
    28.         ((QCARManagerImpl)QCARManager.Instance).Update(mProjectionOrientation);
    29.  
    30.         // Tell Unity that we may have changed the OpenGL state behind the scenes
    31.         GL.InvalidateState();
    32.  
    33.         // Update the camera clear flags
    34.         UpdateCameraClearFlags();
    35.  
    36.         // Let the trackable event handlers know that all trackables have been updated
    37.         foreach (ITrackerEventHandler handler in mTrackerEventHandlers)
    38.         {
    39.             handler.OnTrackablesUpdated();
    40.         }
    41.     }
    42.     else if (QCARRuntimeUtilities.IsPlayMode())
    43.     {
    44.         // in some rare occasions, Unity re-compiles the scripts shortly after starting play mode
    45.         // this invalidates the internal state, so we have to restart play mode in order to ensure correct execution.
    46.         Debug.LogWarning("Scripts have been recompiled during Play mode, need to restart!");
    47.         // re-establish wrapper:
    48.         QCARWrapper.Create();
    49.         // stop and restart play mode
    50.         QCARRuntimeUtilities.RestartPlayMode();
    51.     }
    52. }
    53.  
     
    Last edited: Feb 28, 2013
  7. gringofxs

    gringofxs

    Joined:
    Oct 14, 2012
    Posts:
    240
    there some how to avoid the 3D sphre flashing? Im doing something wrong?

    here's the link with the video.

     
  8. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    Try to switch off the pose filter.

    There are some other ways to get rid of the filtering as well, but I have to make some changes to the code, which I will.
     
    Last edited: Feb 28, 2013
  9. gringofxs

    gringofxs

    Joined:
    Oct 14, 2012
    Posts:
    240
    is in the manual, how to turn off the pose filter? and other ways to get rid of the filtering as well?
     
  10. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    You can switch the pose filter on and off in the settings menu on a mobile device. Go to Home menu -> Settings. Make sure you turn it on during recording though.
     
    Last edited: Mar 1, 2013
  11. gringofxs

    gringofxs

    Joined:
    Oct 14, 2012
    Posts:
    240
    I think that this 3D object flikering, is because i need to put a black box Outline, as you did with your image target, Rigth??
     
    Last edited: Mar 2, 2013
  12. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    I am not sure what you mean. But the reason for the filter is in the manual in the "Pose filter" chapter.
     
  13. gringofxs

    gringofxs

    Joined:
    Oct 14, 2012
    Posts:
    240
    This is what i mean, put a black outline around the image to prevent this intense 3d object flickering.
    $LIKE.jpg
     
    Last edited: Mar 2, 2013
  14. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    The black outline is for the String engine. Vuforia doesn't need it but I added the black outline anyway so the marker is compatible with both String and Vuforia. It has nothing to do with pose filtering or flickering.
     
  15. gringofxs

    gringofxs

    Joined:
    Oct 14, 2012
    Posts:
    240
    String have a better performace in order of flickering the 3D object than vuforia?
    This UCS is a very powerfull tool, but it has to be stable, the next UCS update gonna be?
     
  16. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    String does have better performance regarding flickering but it doesn't come cheap. If you want to reduce flickering with UCS, you have to turn off the pose filter.

    The next UCS update will be in a few months.

    By the way, if you switch off the pose filter and you still get flickering, you did something wrong with the installation. Make sure you set the QCAR script execution order and the script modification correctly as per the manual.
     
    Last edited: Mar 4, 2013
  17. gringofxs

    gringofxs

    Joined:
    Oct 14, 2012
    Posts:
    240
    when I turn off the pose filter, the flickering stops. But I loss the jittering performance too, rigth?
     
  18. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    That is correct. In the next version I will fix this issue, or if you want I can send you a beta version now.
     
  19. gringofxs

    gringofxs

    Joined:
    Oct 14, 2012
    Posts:
    240
  20. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    Ok, I send you the new version. Let me know if you have any problems.
     
  21. tinmegali

    tinmegali

    Joined:
    May 16, 2013
    Posts:
    1
    Hello Elecman. This is a nice initiative, although I'm getting a lot of errors.

    I bought all appointed extensions, vectrosity, objreader, etc, but unfortunately isn't working. I confess that the whole process is a little confusing and maybe somebody could help me.

    I'm using Vuforia. I follow the installation instructions, but I had to ignore the step 14
    - 14: When using Vectrosity: Open VisibilityControl.cs and replace
    Apparently the script "VisibilityControl.cs" doesn't exists or is protected by a .dll
    As a solution I went back on step 09 and disabled vectrosity

    I still got errors:
    Assets/Scripts/FileIO.cs(172,33): error CS0246: The type or namespace name `Result' could not be found. Are you missing a using directive or an assembly reference? Assets/Scripts/FileIO.cs(220,25): error CS0246: The type or namespace name `Result' could not be found. Are you missing a using directive or an assembly reference?

    Those errors seams to be related to OBJREADER, so I went back on step 10 and disable OBJREADER. Then the errors disappeared.


    I loaded one of you samples scenes and followed the instructions for the setup. But when I'm testing I got numerous errors and warnings.
    - Some behavior are missing in the ARCameraUCS
    - Some behavior are missing in the ObjLoad
    -NullReferenceException: Object reference not set to an instance of an object MarkerRecorder.Start () (at Assets/Scripts/MarkerRecorder.cs:468)
    -NullReferenceException: Object reference not set to an instance of an object
    Vuforia.DisableMeshRenderers (UnityEngine.GameObject[] markerObjects) (at Assets/Scripts/Vuforia.cs:727)
    Vuforia.Update () (at Assets/Scripts/Vuforia.cs:72)


    I really don't know what to do anymore. Can you help me?
     
  22. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    Working on it. Stay tuned.

    Edit:
    -Remove the ObjReader.dll file from the Plugins->ObjReader folder. Only the cs or dll file can be present, not both.
    -Disable ObjReader 2.0 or ask Eric for the previous version. Version 2.0 is not compatible with UCS. I will fix this in the next release.

    -If you want to run UCS in the Editor using Vuforia, you have to select PC/MAC as a build platform:
    File->Build Settings->PC , Mac Standalone->Switch Platform.
    Change it back to your target platform if you are exporting your app to your mobile device.

    This is how to fix the errors:

    -Close Unity
    -Remove QCARWrappe.dll from the plugins folder.
    -Start Unity.
    -Import vuforia-unity-android-ios-2-0-32.unitypackage again.
    -Make the changes to QCARBehaviour.cs according to the UCS manual again. Also check the script execution order.
    -Now it shouldn't restart by itself again if you press Run.
    -Open MarkerRecorder.cs and comment out this line:
    Code (csharp):
    1. lineManagerOBJDot.ChangeDotSelection(0, true);
    The problems are caused by an updated version of Vuforia, ObjReader, and Vectrosity, which breaks some things in UCS. I will make future UCS versions more robust to 3rd party code changes.
     
    Last edited: May 19, 2013
  23. petak_core

    petak_core

    Joined:
    Nov 19, 2012
    Posts:
    57
    Hi Elecman,

    I have some troubles wih UCS.. I'm not using any of "optional" addons as the Vectorsity, UniFileBrowser and ObjReader... I follow the step in your complex Manual, but I'm not research my goal :(

    Im using my Android phone and targeting on your markers the markers only blinking and dont show my 3d content, if I switched off POS fileter and again targets on your imageMarkers than image will covered with gray plane (not 3d object)...

    but in Settings I can not choose from FrameMakers or ImageTarget (in your outdated app I can) and your outdated app work great on my Android phone..

    I make this from your manual:
    Vuforia installation (IOS and Android)
    Single Scene Setup >> (Create parrent empty Object and add to them my 3d content and then add deactivatin empty Parrent and attached to "Scene Object" )

    What Im doing wrog ? Why my 3d content is not show..
    thnx and sorry for my English ;)
     
  24. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    If you don't use Vectrosity then UCS isn't really going to work for you. You don't need ObjReader and UniFileBrowser though.

    If the markers are blinking you probably didn't make the appropriate modifications to the QCARBehaviour.cs script and the script execution order in Unity.

    There are some other known bugs which might cause some problems. I am releasing a new version soon.
     
  25. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    double post deleted.
     
  26. Nguyen Huy Thach

    Nguyen Huy Thach

    Joined:
    Jan 14, 2013
    Posts:
    26
    Hi Elecman,

    Please help me,
    I have followed step by step your manual, but when I run on my iPad, I always get a black plane above marker, please see the attached file.

    UCS version I am using is 1.0, downloaded from http://pilotpage.monosock.org/fileadmin/files/UCS1.0.rar
    I do not use Vectrosity, UniFileBrowser or ObjReader, because they are not free. But I think the problem is not from here.

    In page 5 of your manual, step 8.1, one thing is quite strange with if clause

    Camera.main.transform.position = Vector3.zero;
    Camera.main.transform.rotation = Quaternion.identity;
    if (!mIsInitialized)

    before
    if (QCARManager.Instance.Initialized)

    The screen of the program becomes black. If I change
    if (!mIsInitialized)
    to
    if (!mIsInitialized)
    return;

    There is one black plane above each marker as the attached file.

    I am programming in Mac OS X 10.7.5 with Vuforia and Unity 4.1.5f1 Basic version which supports iOS and Android now.

    Thanks in advance!

    $IMG_0141.jpg
     
  27. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    Most likely that problem is caused by the absence of Vectrosity. The black square is caused by a missing material on a game object. If the whole screen is black that is because the game object blocks the whole view because the steps in the manual are not followed.

    There are too many people having problems because Vectrosity is not installed. You could do without, but you will have to write your own line drawing library. Since nobody has done this so far, I am going to make Vectrosity a mandatory addon for UCS 1.1
     
  28. Nguyen Huy Thach

    Nguyen Huy Thach

    Joined:
    Jan 14, 2013
    Posts:
    26
    Thank Elecman,
    I am waiting for your UCS 1.1 and I will try to write a line drawing library.
     
  29. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    On second thought, I will make a replacement for Vectrosity for everything except geometry related functions. This shouldn't be too hard. That doesn't apply for SLAM though.
     
  30. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    Hey man,
    I just found your tool!
    Seems really cool, but I can't get it to work!

    I'm using UCS with Vuforia-Android-2.0.31

    I ran each 3 of vuforia examples you included in the package, my webcam light is green and one shot is taken from it and I can see it in the material preview but all I get is a black screen with buttons and a message saying "Markers are not initialized!" Any ideas?

    Tnx in advance
     
  31. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    UCS 1.0 is broken by all the addons: Vuforia, UniFileBrowser, and ObjRader. I am working on fixing it.
    Should be ready in a few days.
     
  32. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    Oh, I see! No wonder I can't even run the examples then!

    But thanks for all the effort you put into this, I really appreciate it :)
     
  33. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    Hi there,
    Any news? Updates? Can't wait to try this out! I'm new to this :)
     
  34. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    Yes, just released a new version.

    Changelog:
    -The interface to all AR engines is now handled via an AR Engine wrapper called ARwrapper.
    -Added support for PC and MAC standalone if a static camera and marker is used.
    -The marker size is loaded from a file instead of being hard coded.
    -Pose filter is now enabled automatically while recording and certain elements disabled when not recording in order to reduce flickering during game or geometry mode and improve accuracy during recording.
    -Recording can now be continued and the playfield expanded in Game or Geometry mode.
    -The pose filter can now be enabled for other AR engines as well.
    -Reduced flickering with high framerates when the pose filter is enabled with Vuforia.
    -Only one scene is used for all AR engines.
    -Only resources are loaded for the maximum amount of markers in view instead of the total amount of markers.
    -Added 3d content toggle button in Geometry mode.
    -The transform of each individual marker can now be readily accessed.
    -Geometry markers can now be used in Game Mode.
    -Vectrosity is not needed anymore if Geometry mode or SLAM tracking is not used.
    -The plane geometry object now has selectable region lines.
    -Discontinued support for the Vuforia FrameMarkerManual scene. Only runtime created markers are now supported.
    -Vectrosity, ObjReader and UniFileBrowser are now disabled by default.
    -Fixed a compatibility issue with ObjReader.
    -Fixed a bug which caused a compile error with PointCloud.
    -Fixed a bug which sometimes caused corruption of rotation when multiple markers were in view.
    -Fixed a bug with PointCloud whereby selected SLAM points changed location when the point cloud was regenerated.
    -Fixed a bug which caused some of the merged scenes not to load.
    -Fixed a bug which caused the plane geometry outline to have the wrong scale.
     
  35. Nguyen Huy Thach

    Nguyen Huy Thach

    Joined:
    Jan 14, 2013
    Posts:
    26
    Elecman,
    Thank you very much for the update,
    Want to try the new update immediately.
     
  36. gringofxs

    gringofxs

    Joined:
    Oct 14, 2012
    Posts:
    240
    Hi Elecman, Did you have a new version os UCS, for the new Vuforia 2.5 ? for Unity
     
  37. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    Yes. Check the first page of this thread. There is a download link.
     
  38. smtabatabaie

    smtabatabaie

    Joined:
    May 6, 2013
    Posts:
    45
    Hi Elecman , thanks for UCS . I wanted to get the current color of my image target , and somehow make my image targets dynamic and just have the Camera Patch of it . I asked in this thread https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/analysing-colors-image-target and they guided me to this thread where you have explained the use of Camera Patch in unity https://developer.vuforia.com/forum/general-discussion/camera-pstch-unity-3d I read the codes but didn't get how and where to run these codes for the purpose I want . and where image target is saved to analyse it later . I'll appreciate if you can help me with this .
    thanks
     
  39. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    In that Vuforia forum example the render texture is stored in renderTexture but this is in GPU memory. If you want read the average color of that, you need to use ReadPixels but this is a VERY slow operation. Aside from that, the entire webcam texture is used, not just the area of the marker. The UV mapping is done in a vertex shader so you would have to do that on the CPU which makes it even slower.

    Maybe it is possible to use a RenderTexture of the webcam, use a shader to calculate the average color between the marker corners, and then output a single color in the RenderTexture which you can then access by reading only one pixel. But you are best to ask about that in the shader forum.
     
  40. smtabatabaie

    smtabatabaie

    Joined:
    May 6, 2013
    Posts:
    45
    I basically want to have the cropped image of image target from camera feed and somehow be able to analyse the bitmap pixel by pixel and somehow make my image target dynamic . the reason for this question is the app I saw called colAR Mix which obviously analyses the image target colors and map it to the material of 3d model .
     
  41. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    Wow, that colAR app looks really interesting.
    http://www.youtube.com/watch?feature=player_embedded&v=tmfXgvT9h3s
    Thanks for the heads up.

    If you want to do something similar then you don't need to do any texture analysis or use ReadPixels. That effect can be achieved using "simple" texture mapping of a RenderTexture from the camera image.

    You need to create a 3d model and make a texture/UV map for it. Then you print out the texture map (or parts of it) so the user can draw on that. When the drawing is finished then you take a single snapshot of the camera image using a RenderTexture and use that texture to wrap around your 3d object.
     
  42. smtabatabaie

    smtabatabaie

    Joined:
    May 6, 2013
    Posts:
    45
    so you're saying that using another "Camera" besides ARCamera ,pointing directly at image target will provide us un-warped image of current color of our image target?
    I think the process is more like taking a screenshot from camera , cropping the screenshot so we have only image target , de-warping the image target and make it normal and then map it to the UV texture of our 3d model . what do you think about this process?
    thanks
     
    Last edited: Jul 27, 2013
  43. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    No.

    -You don't need to crop the image to the marker area as this can be done by UV mapping.
    -You don't need to do normal mapping.
    -De-warping is done using UV mapping as well.

    Anyway, this is not related to UCS so maybe you better ask for some help at the Unity shader forum. I am no expert in this subject either.
     
  44. TheCwal

    TheCwal

    Joined:
    Nov 12, 2012
    Posts:
    12
    Is it possible to use the camera patch recognition without the rest of the UCS so that I do not have to completely rebuild the scenes I already have built?
     
  45. smtabatabaie

    smtabatabaie

    Joined:
    May 6, 2013
    Posts:
    45
    this image can be the UV map of the model

    $colAR-Mix-Bear-colouring-page-ipad-02-e1369868852682.png $c870e57e853f4aeb9b3cf559a17fdb49.jpg



    but in other cases such as this image , is it possible that these are UV maps ?

    $shoe_page-background-graffitifont-ipad-02-e1369825783768.png $f5f9e318f3452621c31643227b97eebf.jpg


    sorry for bothering you but this app has just blown my mind , I think of every way but I can't get to work out how it's done .
     
  46. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    @ TheCwal,
    I am not sure what you mean with "camera patch recognition". If you mean the camera patch special effect that comes with UCS then the answer is yes. That special effect is just a shader which requires some alignment info, supplied by the "specialEffect.cs" file. You don`t need the entire UCS project for that. In case you are referring to what smtabatabaie is talking about, then the answer is: UCS does not support that in the first place.

    @ smtabatabaie,
    Yes, I am sure that can be done. But again, I am not an export on that subject. Try googling "UV mapping" to get an understanding what it is and how to apply it to your project. If you can`t figure out how to apply it to use it, try this forum section:
    http://forum.unity3d.com/forums/22-External-Tools
     
  47. TheCwal

    TheCwal

    Joined:
    Nov 12, 2012
    Posts:
    12
    I do mean the special effect, as I need to access the specific image being captured of the target. I am having a difficult time using the functionality though, I can't seem to get it working on it's own, as it has so many dependencies with other functionality.

    Specifically, I am using Vuforia, and need to access the screen image of the target I am scanning, due to some missing functionality within Vuforia.

    What you've linked here seems to no longer be up to date with the current version of UCS, as I can't find the functions mentioned as being in Vuforia.cs.
     
    Last edited: Aug 12, 2013
  48. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    I moved the logic from Vuforia.cs to SpecialEffect.cs. It shouldn't have too many dependencies. I don`t have access to my computer for a week but from memory there should be a prefab with the effect in the prefabs folder. Copy that one and scroll through SpecialEffect.cs to see how it works.

    Let me know if you have any problems.
     
  49. shlomif

    shlomif

    Joined:
    Jul 23, 2013
    Posts:
    1
    Hi Elecman,

    I'm using Unity 4.1, UCS 1.1, Vuforia 2.6.7 and Vectorsity 2.3. I'm running the app on an Android device.

    I try to get the sphere scene work with four frame markers. After I record the scene, I go to game mode. I can see the sphere but it moves around very fast, and in a few seconds it goes out of the view.

    Do you know what may wrong?

    Thanks,
    Hlomi
     
  50. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    Make sure that the QCARBehaviour.cs file is modified and that the script execution order is set correctly as per the manual.
     
    Last edited: Sep 8, 2013