public static cvCalcEigenObjects ( IntPtr input, MCvTermCriteria &calcLimit, IntPtr eigVecs, float eigVals, IntPtr avg ) : void | ||
input | IntPtr | Pointer to the array of IplImage input objects |
calcLimit | MCvTermCriteria | Criteria that determine when to stop calculation of eigen objects. Depending on the parameter calcLimit, calculations are finished either after first calcLimit.max_iter dominating eigen objects are retrieved or if the ratio of the current eigenvalue to the largest eigenvalue comes down to calcLimit.epsilon threshold. The value calcLimit -> type must be CV_TERMCRIT_NUMB, CV_TERMCRIT_EPS, or CV_TERMCRIT_NUMB | CV_TERMCRIT_EPS . The function returns the real values calcLimit->max_iter and calcLimit->epsilon |
eigVecs | IntPtr | Pointer either to the array of eigen objects |
eigVals | float | Pointer to the eigenvalues array in the descending order; may be NULL |
avg | IntPtr | Averaged object |
return | void |
public static void cvCalcEigenObjects(
IntPtr[] input,
ref MCvTermCriteria calcLimit,
IntPtr[] eigVecs,
float[] eigVals,
IntPtr avg)
{
cvCalcEigenObjects(
input.Length,
input,
eigVecs,
CvEnum.EIGOBJ_TYPE.CV_EIGOBJ_NO_CALLBACK,
0,
IntPtr.Zero,
ref calcLimit,
avg,
eigVals);
}
CvInvoke::cvCalcEigenObjects ( int nObjects, IntPtr input, IntPtr output, CvEnum ioFlags, int ioBufSize, IntPtr userData, MCvTermCriteria &calcLimit, IntPtr avg, float eigVals ) : void |
/// <summary> /// Caculate the eigen images for the specific traning image /// </summary> /// <param name="trainingImages">The images used for training </param> /// <param name="termCrit">The criteria for tranning</param> /// <param name="eigenImages">The resulting eigen images</param> /// <param name="avg">The resulting average image</param> public static void CalcEigenObjects(Image <Gray, Byte>[] trainingImages, ref MCvTermCriteria termCrit, out Image <Gray, Single>[] eigenImages, out Image <Gray, Single> avg) { int width = trainingImages[0].Width; int height = trainingImages[0].Height; IntPtr[] inObjs = Array.ConvertAll <Image <Gray, Byte>, IntPtr>(trainingImages, delegate(Image <Gray, Byte> img) { return(img.Ptr); }); if (termCrit.max_iter <= 0 || termCrit.max_iter > trainingImages.Length) { termCrit.max_iter = trainingImages.Length; } int maxEigenObjs = termCrit.max_iter; #region initialize eigen images eigenImages = new Image <Gray, float> [maxEigenObjs]; for (int i = 0; i < eigenImages.Length; i++) { eigenImages[i] = new Image <Gray, float>(width, height); } IntPtr[] eigObjs = Array.ConvertAll <Image <Gray, Single>, IntPtr>(eigenImages, delegate(Image <Gray, Single> img) { return(img.Ptr); }); #endregion avg = new Image <Gray, Single>(width, height); CvInvoke.cvCalcEigenObjects( inObjs, ref termCrit, eigObjs, null, avg.Ptr); }