protected void fastHarrisRansacBlendStraight(List <Bitmap> imgs)
{
List <IntPoint[]> harrisPoints = new List <IntPoint[]>();
MatrixH homography;
//Calculate all the Harris Points
HarrisCornersDetector harris = new HarrisCornersDetector(0.03f, 10000f);
for (int i = 0; i < imgs.Count; i++)
{
harrisPoints.Add(harris.ProcessImage(imgs[i]).ToArray());
}
Bitmap final = imgs[0];
for (int i = 1; i < imgs.Count; i++)
{
//Convert my frames to grayscale so I can find and adjust the normal vectors
AForge.Imaging.Filters.GrayscaleBT709 grayscale = new AForge.Imaging.Filters.GrayscaleBT709();
AForge.Imaging.DocumentSkewChecker skew = new AForge.Imaging.DocumentSkewChecker();
double finalAngle = skew.GetSkewAngle(grayscale.Apply(final));
double imgAngle = skew.GetSkewAngle(grayscale.Apply(imgs[i]));
//Less than 5% to account for human error with rotations and wobbles
if (Math.Abs(finalAngle - imgAngle) < 5)
{
AForge.Imaging.Filters.RotateBilinear rotate = new AForge.Imaging.Filters.RotateBilinear(finalAngle - imgAngle);
rotate.FillColor = Color.FromArgb(0, 255, 255, 255);
imgs[i] = rotate.Apply(imgs[i]);
//Update harris
harrisPoints[i] = harris.ProcessImage(imgs[i]).ToArray();
}
IntPoint[] harrisFinal = harris.ProcessImage(final).ToArray();
//Correlate the Harris pts between imgs
CorrelationMatching matcher = new CorrelationMatching(5, final, imgs[i]);
IntPoint[][] matches = matcher.Match(harrisFinal, harrisPoints[i]);
//Create the homography matrix using ransac
RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.025, 0.99);
homography = ransac.Estimate(matches[0], matches[1]);
Blend blend = new Blend(homography, final);
blend.Gradient = true;
final = blend.Apply(imgs[i]);
}
showImage(final);
}