用cvGoodFeaturesToTrack()函数进行角点检测

1. 函数定义

public static void cvGoodFeaturesToTrack(
	IntPtr image,
	IntPtr eigImage,
	IntPtr tempImage,
	IntPtr corners,
	ref int cornerCount,
	double qualityLevel,
	double minDistance,
	IntPtr mask,
	int blockSize,
	int useHarris,
	double k
)

2. 函数参数解释

image
Type: System..::..IntPtr
The source 8-bit or floating-point 32-bit, single-channel image
eigImage
Type: System..::..IntPtr
Temporary floating-point 32-bit image of the same size as image
tempImage
Type: System..::..IntPtr
Another temporary image of the same size and same format as eig_image
corners
Type: System..::..IntPtr
Output parameter. Detected corners
cornerCount
Type: System..::..Int32
Output parameter. Number of detected corners
qualityLevel
Type: System..::..Double
Multiplier for the maxmin eigenvalue; specifies minimal accepted quality of image corners
minDistance
Type: System..::..Double
Limit, specifying minimum possible distance between returned corners; Euclidian distance is used
mask
Type: System..::..IntPtr
Region of interest. The function selects points either in the specified region or in the whole image if the mask is IntPtr.Zero
blockSize
Type: System..::..Int32
Size of the averaging block, passed to underlying cvCornerMinEigenVal or cvCornerHarris used by the function
useHarris
Type: System..::..Int32
If nonzero, Harris operator (cvCornerHarris) is used instead of default cvCornerMinEigenVal.
k
Type: System..::..Double
Free parameter of Harris detector; used only if useHarris != 0
3. 应用举例

            Image<Bgr, byte> img = (Image<Bgr, byte>)imageBox_Ori.Image;
            Image<Gray, byte> ImgGray = img.Convert<Gray, byte>();//将原始图像转换为灰度图像

            Image<Gray, Single> imageDest = new Image<Gray, float>(ImgGray.Size);
            Image<Gray, Single> imgTemp = new Image<Gray, float>(ImgGray.Size);
            int count = 700;
            corners = new PointF[count];
            double qualityLevel = 0.01;
            double minDistance = 20;
            int blockSize = 7;
            int useHarris = 0;//是否应用Harris检测角点
            double k = 0.04;//只有在useHarris != 0时起作用

            GCHandle hObject = GCHandle.Alloc(corners, GCHandleType.Pinned);//C#语言中没有指针的概念,对于没有Ptr属性的对象可用此方法获取对象的指针
            IntPtr pObject = hObject.AddrOfPinnedObject();
            CvInvoke.cvGoodFeaturesToTrack(ImgGray.Ptr, imageDest.Ptr, imgTemp.Ptr, pObject, ref count, qualityLevel, minDistance, IntPtr.Zero, blockSize, useHarris, k);
            if (hObject.IsAllocated)
            {
                hObject.Free();
            }
            #endregion

注意:C#语言中没有指针的概念,而cvGoodFeaturesToTrack函数的参数中有很多指针类型,所以此时需要想办法获取各对象的地址。对于一部分如Image,Matrix等类的对象,包含Ptr属性,可直接当作指针来用。而对于没有该属性的变量或对象如数组,则可以通过上述代码中的方法获得其地址。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值