Beispiel #1
0
            public override void Draw(int cameraId, Aruco.Dictionary dictionary, Cv.Mat image)
            {
                foreach (var arucoCharucoBoard in arucoTracker.GetArucoObjects <ArucoCharucoBoard>(dictionary))
                {
                    if (arucoCharucoBoard.DetectedIds.Size() > 0)
                    {
                        if (arucoTracker.DrawDetectedCharucoMarkers)
                        {
                            Aruco.DrawDetectedCornersCharuco(image, arucoCharucoBoard.DetectedCorners, arucoCharucoBoard.DetectedIds);
                        }

                        if (arucoTracker.DrawAxes && cameraParameters != null && arucoCharucoBoard.Rvec != null)
                        {
                            Aruco.DrawAxis(image, cameraParameters.CameraMatrices[cameraId], cameraParameters.DistCoeffs[cameraId],
                                           arucoCharucoBoard.Rvec, arucoCharucoBoard.Tvec, arucoCharucoBoard.AxisLength);
                        }
                    }
                }
            }
            /// <summary>
            /// <see cref="ArucoObjectTracker.Draw(int, Dictionary, HashSet{ArucoObject})"/>
            /// </summary>
            public override void Draw(int cameraId, Aruco.Dictionary dictionary)
            {
                if (!IsActivated || arucoTracker.MarkerTracker.DetectedMarkers[cameraId][dictionary] <= 0)
                {
                    return;
                }

                bool updatedCameraImage = false;

                Cv.Core.Mat[]    cameraImages     = arucoTracker.ArucoCamera.Images;
                CameraParameters cameraParameters = arucoTracker.ArucoCamera.CameraParameters;

                foreach (var arucoCharucoBoard in arucoTracker.GetArucoObjects <ArucoCharucoBoard>(dictionary))
                {
                    if (arucoCharucoBoard.InterpolatedCorners > 0 && arucoCharucoBoard.Rvec != null)
                    {
                        if (arucoTracker.DrawDetectedCharucoMarkers)
                        {
                            Aruco.DrawDetectedCornersCharuco(cameraImages[cameraId], arucoCharucoBoard.DetectedCorners, arucoCharucoBoard.DetectedIds);
                            updatedCameraImage = true;
                        }

                        if (arucoTracker.DrawAxes && cameraParameters != null && arucoCharucoBoard.ValidTransform)
                        {
                            Aruco.DrawAxis(cameraImages[cameraId], cameraParameters.CamerasMatrix[cameraId], cameraParameters.DistCoeffs[cameraId],
                                           arucoCharucoBoard.Rvec, arucoCharucoBoard.Tvec, arucoCharucoBoard.AxisLength);
                            updatedCameraImage = true;
                        }
                    }
                }

                if (updatedCameraImage)
                {
                    arucoTracker.ArucoCamera.Images = cameraImages;
                }
            }