project marker corners to screenspace

Hello!

I’m trying to project the corners of a marker into the screen. The code below is working fine with a mockup scene without AR in the editor but it does’t work on device. Am I missing something really basic here?

var m = Matrix4x4.TRS(MarkerTransform.position, MarkerTransform.rotation, Vector3.one);

var upperLeft = ARCamera.WorldToScreenPoint( m.MultiplyPoint(new Vector3(-hWidth,0,  hHeight)));
var upperRight = ARCamera.WorldToScreenPoint(m.MultiplyPoint(new Vector3(hWidth,  0, hHeight)));
var lowerRight = ARCamera.WorldToScreenPoint(m.MultiplyPoint(new Vector3(hWidth, 0,-hHeight)));
var lowerLeft = ARCamera.WorldToScreenPoint(m.MultiplyPoint(new Vector3(-hWidth,  0,-hHeight)));

Thanks so much for any pointers!

seb

Could you provide more info as to what isn’t working?
My first guess would be that your ARCamera isn’t updated with the proper matrix yet.
Check the ARCameraBackground.OnCameraFrameReceived-Method. This is where the Projection-Matrix from the Device-Camera is set to your ARCamera. Your code should run after this function.
Thus, you’ll want your code to run after the ARCameraManager.frameReceived-Event, either by adding your own listener to that event, or by running your code in LateUpdate (the event is fired from Update)

Hi. Any success with this?