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
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属性,可直接当作指针来用。而对于没有该属性的变量或对象如数组,则可以通过上述代码中的方法获得其地址。