/// <summary> /// Create a SIFTDetector using the specific values /// </summary> /// <param name="nFeatures">The desired number of features. Use 0 for un-restricted number of features</param> /// <param name="nOctaveLayers">The number of octave layers. Use 3 for default</param> /// <param name="contrastThreshold">Contrast threshold. Use 0.04 as default</param> /// <param name="edgeThreshold">Detector parameter. Use 10.0 as default</param> /// <param name="sigma">Use 1.6 as default</param> public SIFTDetector( int nFeatures = 0, int nOctaveLayers = 3, double contrastThreshold = 0.04, double edgeThreshold = 10.0, double sigma = 1.6) { _ptr = NonfreeInvoke.CvSIFTDetectorCreate(nFeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma, ref _featureDetectorPtr, ref _descriptorExtractorPtr); }
/// <summary> /// Detect keypoints in the CudaImage /// </summary> /// <param name="img">The image where keypoints will be detected from</param> /// <param name="mask">The optional mask, can be null if not needed</param> /// <returns> /// The keypoints GpuMat that will have 1 row. /// keypoints.at<float[6]>(1, i) contains i'th keypoint /// format: (x, y, size, response, angle, octave) /// </returns> public GpuMat DetectKeyPointsRaw(GpuMat img, GpuMat mask = null) { GpuMat result = new GpuMat(); NonfreeInvoke.cudaSURFDetectorDetectKeyPoints(_ptr, img, mask, result); return(result); }
/// <summary> /// Release the unmanaged memory associated with this detector. /// </summary> protected override void DisposeObject() { if (_ptr != IntPtr.Zero) { NonfreeInvoke.CvSURFDetectorRelease(ref _ptr); } base.DisposeObject(); }
/// <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. The order of the keypoints might be changed unless the GPU_SURF detector is UP-RIGHT.</param> /// <returns>The image features founded on the keypoint location</returns> public GpuMat ComputeDescriptorsRaw(GpuMat image, GpuMat mask, GpuMat keyPoints) { //GpuMat descriptors = new GpuMat(keyPoints.Size.Height, DescriptorSize, 1); GpuMat descriptors = new GpuMat(); NonfreeInvoke.cudaSURFDetectorCompute(_ptr, image, mask, keyPoints, descriptors, true); return(descriptors); }
/* * /// <summary> * /// Create a Cuda SURF detector using the specific parameters * /// </summary> * /// <param name="detector">The surf detector where the parameters will be borrow from</param> * /// <param name="featuresRatio">Max features = featuresRatio * img.size().srea().</param> * public CudaSURFDetector(MCvSURFParams detector, float featuresRatio = 0.01f) * : this((float)detector.HessianThreshold, detector.NOctaves, detector.NOctaveLayers, (detector.Extended != 0), featuresRatio, (detector.Upright != 0)) * { * }*/ /// <summary> /// Create a Cuda SURF detector /// </summary> /// <param name="hessianThreshold">The interest operator threshold.</param> /// <param name="nOctaves">The number of octaves to process.</param> /// <param name="nOctaveLayers">The number of layers in each octave.</param> /// <param name="extended">True, if generate 128-len descriptors, false - 64-len descriptors.</param> /// <param name="featuresRatio">Max features = featuresRatio * img.size().srea().</param> /// <param name="upright">If set to true, the orientation is not computed for the keypoints</param> public CudaSURFDetector( float hessianThreshold = 100.0f, int nOctaves = 4, int nOctaveLayers = 2, bool extended = true, float featuresRatio = 0.01f, bool upright = false) { _ptr = NonfreeInvoke.cudaSURFDetectorCreate(hessianThreshold, nOctaves, nOctaveLayers, extended, featuresRatio, upright); }
/// <summary> /// Create a SURF detector using the specific values /// </summary> /// <param name="hessianThresh"> /// Only features with keypoint.hessian larger than that are extracted. /// good default value is ~300-500 (can depend on the average local contrast and sharpness of the image). /// user can further filter out some features based on their hessian values and other characteristics /// </param> /// <param name="extended"> /// false means basic descriptors (64 elements each), /// true means extended descriptors (128 elements each) /// </param> /// <param name="nOctaves"> /// The number of octaves to be used for extraction. /// With each next octave the feature size is doubled /// </param> /// <param name="nOctaveLayers"> /// The number of layers within each octave /// </param> /// <param name="upright"> /// False means that detector computes orientation of each feature. /// True means that the orientation is not computed (which is much, much faster). /// For example, if you match images from a stereo pair, or do image stitching, the matched features likely have very similar angles, and you can speed up feature extraction by setting upright=true.</param> public SURFDetector(double hessianThresh, int nOctaves = 4, int nOctaveLayers = 2, bool extended = true, bool upright = false) { _ptr = NonfreeInvoke.CvSURFDetectorCreate(hessianThresh, nOctaves, nOctaveLayers, extended, upright, ref _featureDetectorPtr, ref _descriptorExtractorPtr); }
/// <summary> /// Obtain the keypoints array from GpuMat /// </summary> /// <param name="src">The keypoints obtained from DetectKeyPointsRaw</param> /// <param name="dst">The vector of keypoints</param> public void DownloadKeypoints(GpuMat src, VectorOfKeyPoint dst) { NonfreeInvoke.cudaSURFDownloadKeypoints(_ptr, src, dst); }
/// <summary> /// Release the unmanaged resource associate to the Detector /// </summary> protected override void DisposeObject() { NonfreeInvoke.cudaSURFDetectorRelease(ref _ptr); }
/// <summary> /// Obtain a GpuMat from the keypoints array /// </summary> /// <param name="src">The keypoints array</param> /// <param name="dst">A GpuMat that represent the keypoints</param> public void UploadKeypoints(VectorOfKeyPoint src, GpuMat dst) { NonfreeInvoke.cudaSURFUploadKeypoints(_ptr, src, dst); }
/// <summary> /// Release the unmanaged resources associated with this object /// </summary> protected override void DisposeObject() { NonfreeInvoke.CvSIFTDetectorRelease(ref _ptr); base.DisposeObject(); }