Search Unity

Resolved AR Raycast from point on XRCpuImage?

Discussion in 'AR' started by vl4dimir, Dec 2, 2020.

  1. vl4dimir

    vl4dimir

    Joined:
    Jun 28, 2012
    Posts:
    21
    I'm processing an XRCpuImage using OpenCV and detecting a number of points of interest on its texture. Then I want to take those points and perform camera.ScreenPointToRay(...) raycasts through them, but I'm trying to figure out the exact transform from XRCpuImage's coordinate space back into screen coordinates (as the phone camera's aspect ratio is rarely exactly the same as the screen's).

    Is there a standard way to do this, perhaps using ARCameraManager or ARCameraBackground? I can cook up a transform myself but I'm worried that it might be slightly off on some phones, as I don't know exactly what algorithm ARCameraBackground uses to stretch the camera texture across the screen. I'm guessing it's "stretch to fill"?
     
  2. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,144
  3. vl4dimir

    vl4dimir

    Joined:
    Jun 28, 2012
    Posts:
    21
    Cheers, I'll look into that!
     
    KyryloKuzyk likes this.