private AppendedMediaSequences datasetsOfInterest()
        {
            AppendedMediaSequences allMs = new AppendedMediaSequences(new List <IMediaSequences> {
                PrivateDataSet.CASIA_IRIS_DISTANCE
            });

            // AppendedMediaSequences allMs = new AppendedMediaSequences( new List<IMediaSequences> { PrivateDataSet.PUT_FACE_DATABASE, PrivateDataSet.POLYU_NIR_FACE } );
            return(allMs);
        }
        public void BinocularDetectionTest()
        {
            Settings.Instance.Processing.TrackingMode = TrackingModeEnum.Binocular;
            GazeTrackingLibrary.Detection.Eye.Eyetracker et = new GazeTrackingLibrary.Detection.Eye.Eyetracker();
            Assert.IsTrue(et.IsReady);
            List <double> rightEyeProportionalErrors = new List <double>();
            List <double> leftEyeProportionalErrors  = new List <double>();
            long          countEyesNotFound          = 0;
            long          countNoEyeCentreLandmarks  = 0;
            long          countEyesFoundCorrectly    = 0;
            long          countEyesFoundIncorrectly  = 0;
            long          imageCounter = 0;

            AppendedMediaSequences allMs = datasetsOfInterest();

            foreach (IMediaSequence ms in allMs.getMediaSequences())
            {
                foreach (IMediaFrame mf in ms.getMediaFrames())
                {
                    Image img = mf.getImage();
                    imageCounter = imageCounter + 1;
                    ILabelledFeature eyeR = mf.getLabelledFeature(DataSetEnums.FeatureName.RIGHT_EYE_CENTRE);
                    ILabelledFeature eyeL = mf.getLabelledFeature(DataSetEnums.FeatureName.LEFT_EYE_CENTRE);
                    if ((eyeR != null) && (eyeL != null))
                    {
                        Point  rightEyeCentre = eyeR.getPath().getPoints()[0];
                        Point  leftEyeCentre  = eyeL.getPath().getPoints()[0];
                        Bitmap bmp            = new Bitmap(img);

                        Image <Gray, byte> gray      = new Image <Gray, byte>(bmp);
                        TrackData          trackData = new TrackData();
                        bool eyesFound = et.DetectEyes(gray, trackData);
                        if (eyesFound)
                        {
                            // check more things about the location of the eyes that were found
                            // Record the detection information alongside the MediaFrame so that a little later we can compare the distance that the
                            // landmark eye centre is from the centre of the detected region, and the corresponding distance between the eyes for each sample
                            if (trackData.RightROI.Contains(leftEyeCentre) && trackData.LeftROI.Contains(rightEyeCentre))
                            {
                                countEyesFoundCorrectly++;
                                renderEyeDetection(imageCounter, bmp, gray, trackData, SearchResult.FOUND_OK);
                            }
                            else
                            {
                                countEyesFoundIncorrectly++;
                                renderEyeDetection(imageCounter, bmp, gray, trackData, SearchResult.FOUND_WRONG);
                            }

                            // Create a measure for the error
                            Point roiCentreLeftEye  = new Point((trackData.RightROI.Right + trackData.RightROI.Left) / 2, (trackData.RightROI.Top + trackData.RightROI.Bottom) / 2);
                            Point roiCentreRightEye = new Point((trackData.LeftROI.Right + trackData.LeftROI.Left) / 2, (trackData.LeftROI.Top + trackData.LeftROI.Bottom) / 2);
                            roiCentreRightEye.Offset(-rightEyeCentre.X, -rightEyeCentre.Y);
                            roiCentreLeftEye.Offset(-leftEyeCentre.X, -leftEyeCentre.Y);
                            rightEyeCentre.Offset(-leftEyeCentre.X, -leftEyeCentre.Y);
                            double radialProportionRight = radialDistance(roiCentreRightEye) / radialDistance(rightEyeCentre);
                            double radialProportionLeft  = radialDistance(roiCentreLeftEye) / radialDistance(rightEyeCentre);
                            rightEyeProportionalErrors.Add(radialProportionRight);
                            leftEyeProportionalErrors.Add(radialProportionLeft);
                        }
                        else
                        {
                            countEyesNotFound++;
                            renderEyeDetection(imageCounter, bmp, gray, trackData, SearchResult.NOT_FOUND);
                        }
                        bmp.Dispose();
                        gray.Dispose();
                    }
                    else
                    {
                        countNoEyeCentreLandmarks++;
                    }
                    img.Dispose();
                }
            }

            double reMean   = calculateMean(rightEyeProportionalErrors);
            double leMean   = calculateMean(leftEyeProportionalErrors);
            double reStdDev = calculateStdDev(rightEyeProportionalErrors);
            double leStdDev = calculateStdDev(leftEyeProportionalErrors);

            // For combined POLY_U NIR FACE Database & PUT Face Database
            Assert.True(reMean < 0.15D);
            Assert.True(leMean < 0.15D);
            Assert.True(( double )countEyesFoundCorrectly / (( double )countEyesFoundCorrectly + ( double )countEyesFoundIncorrectly + ( double )countEyesNotFound) > 0.6);
            Assert.True(( double )countEyesFoundCorrectly / (( double )countEyesFoundCorrectly + ( double )countEyesFoundIncorrectly) > 0.74);
            Assert.AreEqual(615, countNoEyeCentreLandmarks);

            // For POLY_U NIR FACE Database
            // Only 24.3% success at the moment (POLYU NIR FACE)
            Assert.True(reMean < 0.15D);
            Assert.True(leMean < 0.15D);
            Assert.True(( double )countEyesFoundCorrectly / (( double )countEyesFoundCorrectly + ( double )countEyesFoundIncorrectly + ( double )countEyesNotFound) > 0.2);
            Assert.True(( double )countEyesFoundCorrectly / (( double )countEyesFoundCorrectly + ( double )countEyesFoundIncorrectly) > 0.85);
            Assert.AreEqual(0, countNoEyeCentreLandmarks);

            // For PUT Face Database
            Assert.True(reMean < 0.15D);                     // actual is only slightly under this
            Assert.True(leMean < 0.14D);                     // actual is only slightly under this
            Assert.True(countEyesFoundCorrectly >= 6014);    // We get 6014 as baseline
            Assert.True(countEyesFoundIncorrectly <= 2048);  // We get 2048 as baseline
            Assert.True(countEyesNotFound <= 1199);          // We get 1199 as baseline
            Assert.True(countNoEyeCentreLandmarks <= 615);   // We get 615as baseline
            Assert.AreEqual(615, countNoEyeCentreLandmarks); // Should not suddenly be getting more landmarks!
        }