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

[Solved] ARToolkit + Avpro decklink not working well together

Discussion in 'AR/VR (XR) Discussion' started by houta97, Feb 17, 2017.

  1. houta97

    houta97

    Joined:
    Jan 8, 2017
    Posts:
    5
    Hi,
    I m new to artoolkit/unity and i am trying to send the augmented reality scene to a capture/output card (blackmagic decklink) without success, on the pc screen it works but on the decklink card output i have a strange behaviour : as i move the marker the entire image move with it

    video:

    download vidéo: http://uptobox.com/x1rd27p43sqd
    I use the avpro decklink package to manage the blackmagic decklink.
    config: Windows 7 SP1/ unity 5.4.3f1/ artoolkit 5.3.2/ avpro for decklink 1.3.0/blackmagic desktop video 10.8
    can you please help me on that, how can i send the scene properly to the decklink card?
    Thanks in advance
     
    Last edited: May 19, 2017
  2. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Hi, we are the authors of AVPro DeckLink
    Did you manage to solve this issue, or would you like us to investigate?
    Thanks,
     
  3. houta97

    houta97

    Joined:
    Jan 8, 2017
    Posts:
    5
    Hi,
    I couldn't find a solution to this problem yet, if you could investigate it would be great!
     
  4. SunriseRH

    SunriseRH

    Joined:
    Aug 5, 2016
    Posts:
    107
    Hi Houta,

    I remember this email. When running your project, I found that the camera clear settings were being changed to "Don't Clear" during runtime, which will result in what you are seeing.

    Looking closer at the issue, this is being caused by the script AR Camera, which manually sets the clear flags. This makes sense in the context of ARToolkit as it has a non-trivial camera setup, where one camera is responsible for clearing and the other cameras render on top of the cleared frame buffer. Because of this, the standard approach of having a single separate camera for DeckLink output isn't really viable here, as it is only good for rendering scenes that can be rendered with a single camera.

    The most straightforward way to get the two working together is to, instead of using a single separate camera, manually assign the InputTexture of the DeckLinkOutput component to the target texture of all the cameras in the scene. The downside to this method is that you won't see anything in unity as all of your cameras will be rendering to a separate RenderTexture (the output will however be correct on the DeckLink side). If you wish to see the output within Unity as well, there are two things you can do:
    -Duplicate all of the scene cameras, and assign the DeckLinkOutput's texture to those duplicated cameras only
    -Have a component that grabs the texture from the DeckLinkOutput component, and then display that with something such as uGUI inside a separate camera.

    If you are still experiencing issues, just email me and I'll be happy to elaborate
     
  5. houta97

    houta97

    Joined:
    Jan 8, 2017
    Posts:
    5
    Hi Sunrise,
    Sorry for late response i was working on other aspects of the app, i have found the line that sets the clear flag in ARCamera, do i have to disable it?
    Can you please elaborate on these points:
    how can i manually assign the InputTexture of the DeckLinkOutput component to the target texture of all the cameras in the scene?
    Please explain how to work with DeckLinkOutput texture ?
    Thanks a lot for your help
     
  6. SunriseRH

    SunriseRH

    Joined:
    Aug 5, 2016
    Posts:
    107
    Hi Houta,

    You shouldn't disable the clear flag setting code, as I believe that might mess with ARToolkit.

    I don't have the project anymore so I can't give exact instructions, however, the general idea is that instead of using a separate camera to render the output, what you should instead do is obtain the InputTexture property of the DeckLinkOutput component, and then assign that texture to all your ARToolkit cameras.
    The code will look something like:

    foreach(var camera in cameras){
    camera.targetTexture = outputDecklink.InputTexture;
    }

    You should also only do this after you started the decklink plugin, as it only creates the texture when playback has started (you can also just assign the textures every frame, shouldn't matter much).

    The downside to doing things this way is that you won't be able to see the render in unity. If you wish still see the output in unity, you will need to duplicate all your cameras, and then assign the DeckLinkOutput's InputTexture component to the targetTexture of these cameras instead (this will however be more expensive, since you are effectively rendering everything twice).