Log in or register to post comments

QCARRuntimeUtilities.ScreenSpaceToCameraFrameCoordinates is return 0, 0

March 14, 2016 - 12:07am #1

Unity Version 4.6.9p4

Vuforia Version 4.2.3

 

 

QCARRuntimeUtilities.ScreenSpaceToCameraFrameCoordinates is return 0,0

 

 

    private UnityEngine.Rect viewportRectangle;
    private bool videoBackGroundMirrored;
    private CameraDevice.VideoModeData videoMode;

 

void Start() {

behaviour = (QCARAbstractBehaviour)UnityEngine.Object.FindObjectOfType(typeof(QCARAbstractBehaviour));
videoMode = CameraDevice.Instance.GetVideoMode(behaviour.CameraDeviceMode);
CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
}
 
 
 
 
        CameraDevice cam = CameraDevice.Instance;
        cam.SetFrameFormat(Image.PIXEL_FORMAT.RGB565, true);
 
        while (cam.GetCameraImage(Image.PIXEL_FORMAT.RGB565) == null)
        {
            yield return null;
        }
 
        // Warping
        videoBackGroundMirrored = behaviour.VideoBackGroundMirrored;
        viewportRectangle = behaviour.GetViewportRectangle();
 
        // Image Target BoundingBox Screen Coords -> Camera Coords
        Vector2[] srcCorner = targets[targetFlag].GetComponent<TargetScreenCoords3>().GetScreenCoords(); -> Get ScreenCoordinate( In Object Collider Position )
        // ex ) TL, TR, DL, DR
        System.Collections.Generic.List<Point> srcCornerPointList = new System.Collections.Generic.List<Point>();
 
        labelTest.text = targetFlag.ToString() + '\n';
        labelTest.text += "r : " + viewportRectangle.ToString()+ '\n';
        labelTest.text += "m : " + videoBackGroundMirrored.ToString() + '\n';
        labelTest.text += "v : " + videoMode.ToString()+ '\n';
 
        // TL, TR, DL, DR
        for ( int i = 0; i < srcCorner.Length; ++i ) {
            QCARRenderer.Vec2I vec2I = Vuforia.QCARRuntimeUtilities.ScreenSpaceToCameraFrameCoordinates(srcCorner [i], viewportRectangle, videoBackGroundMirrored, videoMode);
srcCornerPointList.Add(new Point(vec2I.x, vec2I.y));
            labelTest.text += vec2I.x + ", " + vec2I.y + '\n';
}
 
 
-> srcCorner is Vector2( Object Collider position to screen coordinate in Unity )
this Vector2 is not null( It is well executed.)
 
 
Use the same in other project.
But other project is not return 0,0
 
what's problem..?
 
please help me
Log in or register to post comments