Example #1
0
 /// <summary>
 /// Returns a training set of descriptors.
 /// </summary>
 /// <returns></returns>
 public Mat[] GetDescriptors()
 {
     using (var descriptors = new VectorOfMat())
     {
         NativeMethods.features2d_BOWTrainer_getDescriptors(ptr, descriptors.CvPtr);
         return(descriptors.ToArray());
     }
 }
 /// <summary>
 /// Get train descriptors collection.
 /// </summary>
 /// <returns></returns>
 public Mat[] GetTrainDescriptors()
 {
     ThrowIfDisposed();
     using (var matVec = new VectorOfMat())
     {
         NativeMethods.features2d_DescriptorMatcher_getTrainDescriptors(ptr, matVec.CvPtr);
         return(matVec.ToArray());
     }
 }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pyr"></param>
        /// <returns></returns>
        public Mat[] BuildDoGPyramid(IEnumerable <Mat> pyr)
        {
            ThrowIfDisposed();
            if (pyr == null)
            {
                throw new ArgumentNullException("pyr");
            }

            IntPtr[] pyrPtrs = EnumerableEx.SelectPtrs(pyr);
            using (VectorOfMat dogPyrVec = new VectorOfMat())
            {
                NativeMethods.nonfree_SIFT_buildDoGPyramid(ptr, pyrPtrs, pyrPtrs.Length, dogPyrVec.CvPtr);
                return(dogPyrVec.ToArray());
            }
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="baseMat"></param>
        /// <param name="nOctaves"></param>
        /// <returns></returns>
        public Mat[] BuildGaussianPyramid(Mat baseMat, int nOctaves)
        {
            ThrowIfDisposed();
            if (baseMat == null)
            {
                throw new ArgumentNullException("baseMat");
            }
            baseMat.ThrowIfDisposed();

            using (VectorOfMat pyrVec = new VectorOfMat())
            {
                NativeMethods.nonfree_SIFT_buildGaussianPyramid(ptr, baseMat.CvPtr, pyrVec.CvPtr, nOctaves);
                return(pyrVec.ToArray());
            }
        }
        /// <summary>
        ///
        /// </summary>
        public override void AssignResult()
        {
            if (!IsReady())
            {
                throw new NotSupportedException();
            }

            // Matで結果取得
            using (var vectorOfMat = new VectorOfMat())
            {
                NativeMethods.core_OutputArray_getVectorOfMat(ptr, vectorOfMat.CvPtr);
                list.Clear();
                list.AddRange(vectorOfMat.ToArray());
            }
        }
Example #6
0
        /// <summary>
        /// Constructs a pyramid which can be used as input for calcOpticalFlowPyrLK
        /// </summary>
        /// <param name="img">8-bit input image.</param>
        /// <param name="pyramid">output pyramid.</param>
        /// <param name="winSize">window size of optical flow algorithm.
        /// Must be not less than winSize argument of calcOpticalFlowPyrLK().
        /// It is needed to calculate required padding for pyramid levels.</param>
        /// <param name="maxLevel">0-based maximal pyramid level number.</param>
        /// <param name="withDerivatives">set to precompute gradients for the every pyramid level.
        /// If pyramid is constructed without the gradients then calcOpticalFlowPyrLK() will
        /// calculate them internally.</param>
        /// <param name="pyrBorder">the border mode for pyramid layers.</param>
        /// <param name="derivBorder">the border mode for gradients.</param>
        /// <param name="tryReuseInputImage">put ROI of input image into the pyramid if possible.
        /// You can pass false to force data copying.</param>
        /// <returns>number of levels in constructed pyramid. Can be less than maxLevel.</returns>
        public static int BuildOpticalFlowPyramid(
            InputArray img, out Mat[] pyramid,
            Size winSize, int maxLevel,
            bool withDerivatives    = true,
            BorderType pyrBorder    = BorderType.Reflect101,
            BorderType derivBorder  = BorderType.Constant,
            bool tryReuseInputImage = true)
        {
            if (img == null)
            {
                throw new ArgumentNullException(nameof(img));
            }
            img.ThrowIfDisposed();

            using (var pyramidVec = new VectorOfMat())
            {
                int result = NativeMethods.video_buildOpticalFlowPyramid1(
                    img.CvPtr, pyramidVec.CvPtr, winSize, maxLevel, withDerivatives ? 1 : 0,
                    (int)pyrBorder, (int)derivBorder, tryReuseInputImage ? 1 : 0);
                pyramid = pyramidVec.ToArray();
                return(result);
            }
        }