/// <summary> /// Compute the descriptor given the image and the point location /// </summary> /// <param name="image">The image where the descriptor will be computed from</param> /// <param name="mask">The optional mask, can be null if not needed</param> /// <param name="keyPoints">The keypoint where the descriptor will be computed from. Keypoints for which a descriptor cannot be computed are removed.</param> /// <returns>The descriptors founded on the keypoint location</returns> private Matrix <byte> ComputeDescriptorsRawHelper(CvArray <Byte> image, Image <Gray, byte> mask, VectorOfKeyPoint keyPoints) { if (mask != null) { keyPoints.FilterByPixelsMask(mask); } int count = keyPoints.Size; if (count == 0) { return(null); } Matrix <byte> descriptors = new Matrix <byte>(count, DescriptorSize * image.NumberOfChannels, 1); CvInvoke.CvOrbDetectorComputeDescriptors(_ptr, image, keyPoints, descriptors); return(descriptors); }
/// <summary> /// Compute the descriptor given the image and the point location /// </summary> /// <param name="image">The image where the descriptor will be computed from</param> /// <param name="mask">The optional mask, can be null if not needed</param> /// <param name="keyPoints">The keypoint where the descriptor will be computed from. Keypoints for which a descriptor cannot be computed are removed.</param> /// <returns>The descriptors founded on the keypoint location</returns> private Matrix <Byte> ComputeDescriptorsRawHelper(CvArray <Byte> image, Image <Gray, byte> mask, VectorOfKeyPoint keyPoints) { const float epsilon = 1.192092896e-07f; // smallest such that 1.0+epsilon != 1.0 keyPoints.FilterByImageBorder(image.Size, 48 / 2 + 9 / 2); //this value comes from opencv's BriefDescriptorExtractor::computeImpl implementation keyPoints.FilterByKeypointSize(epsilon, float.MaxValue); if (mask != null) { keyPoints.FilterByPixelsMask(mask); } int count = keyPoints.Size; if (count == 0) { return(null); } Matrix <Byte> descriptors = new Matrix <Byte>(count, DescriptorSize * image.NumberOfChannels, 1); CvInvoke.CvBriefDescriptorComputeDescriptors(_ptr, image, keyPoints, descriptors); Debug.Assert(keyPoints.Size == descriptors.Rows); return(descriptors); }