Beispiel #1
0
        /// <summary>
        /// create a new dpm detector with the specified files and classes
        /// </summary>
        /// <param name="files"></param>
        /// <param name="classes"></param>
        public DpmDetector(string[] files, string[] classes)
        {
            CvString[] cfiles = new CvString[files.Length];
            for (int i = 0; i < files.Length; i++)
            {
                cfiles[i] = new CvString(files[i]);
            }

            CvString[] cclasses = new CvString[classes.Length];
            for (int i = 0; i < classes.Length; i++)
            {
                cclasses[i] = new CvString(classes[i]);
            }

            try
            {
                using (var vfiles = new Util.VectorOfCvString(cfiles))
                    using (var vclasses = new Util.VectorOfCvString(cclasses))
                        _ptr = DpmInvoke.cveDPMDetectorCreate(vfiles, vclasses, ref _sharedPtr);
            }
            finally
            {
                foreach (var c in cfiles)
                {
                    c.Dispose();
                }
                foreach (var c in cclasses)
                {
                    c.Dispose();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// create a new dpm detector with the specified files and classes
        /// </summary>
        /// <param name="files"></param>
        /// <param name="classes"></param>
        /// <returns></returns>
        public static DpmDetector Create(string[] files, string[] classes)
        {
            CvString[] cfiles = new CvString[files.Length];
            for (int i = 0; i < files.Length; i++)
            {
                cfiles[i] = new CvString(files[i]);
            }

            CvString[] cclasses = new CvString[classes.Length];
            for (int i = 0; i < classes.Length; i++)
            {
                cclasses[i] = new CvString(classes[i]);
            }

            IntPtr dpm;

            using (var vfiles = new Util.VectorOfCvString(cfiles))
                using (var vclasses = new Util.VectorOfCvString(cclasses))
                    dpm = DpmInvoke.cveDPMDetectorCreate(vfiles, vclasses);

            foreach (var c in cfiles)
            {
                c.Dispose();
            }
            foreach (var c in cclasses)
            {
                c.Dispose();
            }

            return(new DpmDetector(dpm));
        }