示例#1
0
        /// <summary>
        /// Computes an image descriptor using the set visual vocabulary.
        /// </summary>
        /// <param name="image">Image, for which the descriptor is computed.</param>
        /// <param name="keypoints">Keypoints detected in the input image.</param>
        /// <param name="imgDescriptor">Computed output image descriptor.</param>
        /// <param name="pointIdxsOfClusters">pointIdxsOfClusters Indices of keypoints that belong to the cluster.
        /// This means that pointIdxsOfClusters[i] are keypoint indices that belong to the i -th cluster(word of vocabulary) returned if it is non-zero.</param>
        /// <param name="descriptors">Descriptors of the image keypoints that are returned if they are non-zero.</param>
        public void Compute(InputArray image, ref KeyPoint[] keypoints, OutputArray imgDescriptor,
                            out int[][] pointIdxsOfClusters, Mat?descriptors = null)
        {
            ThrowIfDisposed();
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (imgDescriptor == null)
            {
                throw new ArgumentNullException(nameof(imgDescriptor));
            }

            using (var keypointsVec = new VectorOfKeyPoint(keypoints))
                using (var pointIdxsOfClustersVec = new VectorOfVectorInt32())
                {
                    NativeMethods.HandleException(
                        NativeMethods.features2d_BOWImgDescriptorExtractor_compute11(ptr, image.CvPtr, keypointsVec.CvPtr,
                                                                                     imgDescriptor.CvPtr, pointIdxsOfClustersVec.CvPtr, Cv2.ToPtr(descriptors)));
                    keypoints           = keypointsVec.ToArray();
                    pointIdxsOfClusters = pointIdxsOfClustersVec.ToArray();
                }
            GC.KeepAlive(this);
            GC.KeepAlive(image);
            GC.KeepAlive(imgDescriptor);
            GC.KeepAlive(descriptors);
        }
示例#2
0
        /// <summary>
        /// Computes an image descriptor using the set visual vocabulary.
        /// </summary>
        /// <param name="keypointDescriptors">Computed descriptors to match with vocabulary.</param>
        /// <param name="imgDescriptor">Computed output image descriptor.</param>
        /// <param name="pointIdxsOfClusters">Indices of keypoints that belong to the cluster.
        /// This means that pointIdxsOfClusters[i] are keypoint indices that belong to the i -th cluster(word of vocabulary) returned if it is non-zero.</param>
        public void Compute(InputArray keypointDescriptors, OutputArray imgDescriptor, out int[][] pointIdxsOfClusters)
        {
            ThrowIfDisposed();
            if (keypointDescriptors == null)
            {
                throw new ArgumentNullException(nameof(keypointDescriptors));
            }
            if (imgDescriptor == null)
            {
                throw new ArgumentNullException(nameof(imgDescriptor));
            }

            using (var pointIdxsOfClustersVec = new VectorOfVectorInt32())
            {
                NativeMethods.HandleException(
                    NativeMethods.features2d_BOWImgDescriptorExtractor_compute12(
                        ptr, keypointDescriptors.CvPtr, imgDescriptor.CvPtr, pointIdxsOfClustersVec.CvPtr));
                pointIdxsOfClusters = pointIdxsOfClustersVec.ToArray();
            }
            GC.KeepAlive(this);
            GC.KeepAlive(keypointDescriptors);
            GC.KeepAlive(imgDescriptor);
        }