I’m trying to compile this code (the last one):
http://www.aforgenet.com/framework/features/blobs_processing.html
but it throws: Use of unassigned local variable ‘edgePoints’ ..
here is the code:
BlobCounter blobCounter = new BlobCounter();
blobCounter.ProcessImage(image23);
Blob[] blobs = blobCounter.GetObjectsInformation();
GrahamConvexHull hullFinder = new GrahamConvexHull();
BitmapData data = image23.LockBits(new Rectangle(0, 0, image23.Width, image23.Height), ImageLockMode.ReadWrite, image23.PixelFormat);
foreach (Blob blob in blobs)
{
List<IntPoint> leftPoints, rightPoints, edgePoints;
blobCounter.GetBlobsLeftAndRightEdges(blob, out leftPoints, out rightPoints);
edgePoints.AddRange(leftPoints);
edgePoints.AddRange(rightPoints);
List<IntPoint> hull = hullFinder.FindHull(edgePoints);
Drawing.Polygon(data, hull, Color.Red);
}
image23.UnlockBits(data);
And this is the line that he has problem with:
edgePoints.AddRange(leftPoints);
I tied to assign Null to edgePoints but it failed:
List<IntPoint> leftPoints, rightPoints, edgePoints= null;
What’s the problem? I didn’t modify source code so everything should work..
You need to, well – assign a value to it:
Before you call method on that instance.
Your
leftPointsandrightPointsare probably initialized bycall (note the
outkeywords), butedgePointsisn’t – you need to do that yourself.