Exemplo n.º 1
0
 void ComputeRenderedVsDetectedError()
 {
     // The "reprojection" error between the rendered world points and the detected ones. We use a simple average
     // of the diviation because it is more intuitive to interpret than Root Mean Square (RMS).
     _extrinsicsErrorAvgM = 0;
     for (int i = 0; i < _circlePatternPointCount; i++)
     {
         Vector3 renderedWorldPoint = _circlePointsRenderedWorldMat.ReadVector3(i);
         Vector3 detectedWorldPoint = _circlePointsDetectedWorldMat.ReadVector3(i);
         _extrinsicsErrorAvgM += Vector3.Distance(renderedWorldPoint, detectedWorldPoint);
     }
     _extrinsicsErrorAvgM /= _circlePatternPointCount;
 }
Exemplo n.º 2
0
        void UpdateCirclePatternInProjectorImage()
        {
            // We will be raycasting from the projector camera. In the editor, the aspect can change depending on the main game view, so we have to ensure that it matches.
            _projectorCamera.targetTexture = _arTexture;

            // Use the circle pattern transform from last update frame, because it is more likely that it will match the detected reality.
            TrackingToolsHelper.UpdateWorldSpacePatternPoints(_circlePatternSize, _circlePatternToWorldPrevFrame, TrackingToolsHelper.PatternType.AsymmetricCircleGrid, _circlePatternBorderSizeUV, ref _circlePointsRenderedWorldMat);
            for (int p = 0; p < _circlePatternPointCount; p++)
            {
                Vector3 worldPoint    = _circlePointsRenderedWorldMat.ReadVector3(p);
                Vector3 viewportPoint = _projectorCamera.WorldToViewportPoint(worldPoint);
                Vector2 imagePoint    = new Vector2(viewportPoint.x * _cameraTexture.width, (1 - viewportPoint.y) * _cameraTexture.height);                  // Viewport space has zero at bottom-left, image space (opencv) has zero at top-left. So flip y.
                _circlePointsProjectorRenderImageMat.WriteVector2(imagePoint, p);
            }
            //TrackingToolsHelper.DrawFoundPattern( _camTexGrayUndistortMat, circlesPatternSize, _circlePointsProjectorRenderImageMat ); // Testing

            // Reset render target.
            _projectorCamera.targetTexture = null;
        }
Exemplo n.º 3
0
        void OnDrawGizmos()
        {
            if (_chessCornersWorldMat == null)
            {
                return;
            }

            float pointRadius = (_chessPatternTransform.localScale.y / (float)_chessPatternSize.y) * 0.2f;

            Gizmos.color = Color.red;
            for (int i = 0; i < _chessCornersWorldMat.total(); i++)
            {
                Vector3 p = _chessCornersWorldMat.ReadVector3(i);
                Gizmos.DrawSphere(p, pointRadius);
            }
        }