public IList <RoI> DetectFaces(Image image, EnumDetectionType detectionType, double scale, int minNeighbors, Size minSize)
        {
            IList <RoI> rois = new List <RoI>();

            // convert to openCV format
            HAAR_DETECTION_TYPE detectionTypeOpenCV = EnumHelper.StringToEnum <HAAR_DETECTION_TYPE>(detectionType.ToString());

            try
            {
                Image <Gray, byte> gray = new Image <Gray, byte>(new Bitmap(image));

                //Face Detector
                MCvAvgComp[][] facesDetected = gray.DetectHaarCascade(
                    face,
                    scale,
                    minNeighbors,
                    detectionTypeOpenCV,
                    minSize
                    );


                // create a RoI object for every detected face
                foreach (MCvAvgComp f in facesDetected[0])
                {
                    RoI roi = new RoI();
                    roi.X      = f.rect.X;
                    roi.Y      = f.rect.Y;
                    roi.Width  = f.rect.Width;
                    roi.Height = f.rect.Height;
                    rois.Add(roi);
                }
            }
            catch
            {
                throw new FaceDetectionException("Error while detecting faces!");
            }
            return(rois);
        }
        public IList<RoI> DetectFaces(Image image, EnumDetectionType detectionType, double scale, int minNeighbors, Size minSize)
        {
            IList<RoI> rois = new List<RoI>();

            // convert to openCV format
            HAAR_DETECTION_TYPE detectionTypeOpenCV = EnumHelper.StringToEnum<HAAR_DETECTION_TYPE>(detectionType.ToString());

            try
            {
                Image<Gray, byte> gray = new Image<Gray, byte>(new Bitmap(image));

                //Face Detector
                MCvAvgComp[][] facesDetected = gray.DetectHaarCascade(
                    face,
                    scale,
                    minNeighbors,
                    detectionTypeOpenCV,
                    minSize
                    );


                // create a RoI object for every detected face
                foreach (MCvAvgComp f in facesDetected[0])
                {
                    RoI roi = new RoI();
                    roi.X = f.rect.X;
                    roi.Y = f.rect.Y;
                    roi.Width = f.rect.Width;
                    roi.Height = f.rect.Height;
                    rois.Add(roi);
                }
            }
            catch 
            {
                throw new FaceDetectionException("Error while detecting faces!");
            }
            return rois;
        }