Click here to Skip to main content
12,560,241 members (58,005 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
Hi I've faced an error with the following code !
private void check_Click(object sender, EventArgs e)
            // locate objects using blob counter
            BlobCounter blobCounter = new BlobCounter();
            Blob[] blobs = blobCounter.GetObjectsInformation();
            // create Graphics object to draw on the image and a pen
            Graphics g = Graphics.FromImage((Bitmap)TargetPic.Image);
            Pen redPen = new Pen(Color.Red, 2);
            // check each object and draw circle around objects, which
            // are recognized as circles
            for (int i = 0, n = blobs.Length; i < n; i++)
                List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blob[i]);
                AForge.Point center;
                float radius;
                if (shapeChecker.IsCircle(edgePoints, out center, out radius))
                        (int)(center.X - radius),
                        (int)(center.Y - radius),
                        (int)(radius * 2),
                        (int)(radius * 2));
The Error :: (( The name 'shapeChecker' does not exist in the current context )) Can any one tell me how to fix it ?
Posted 19-Jan-13 9:41am
Updated 30-Jan-13 9:16am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you write code by yourself, such problems are resolved without anyone's help. If you use some name like shapeChecker, you know where did you define it.

And what you do it nearly useless. You tool someone's code you don't really understand. You don't even understand that you should define everything you ever use. No wonder the compiler cannot compile it. The solution would be: define it. But there is a little use if you don't write code by yourself and trying some shamanic ritual with copy-paste.

If you don't know how to define a type's member or a variable, going in for image recognition makes no sense at all. You need to learn the very basics first, and it would be a pretty long way.

Sergey Alexandrovich Kryukov 20-Jan-13 12:56pm
I can understand how difficult it can be, but what can you possibly do? only to to deep in it; and this is quite possible, so many people taught themselves well.
Good luck,
Sergey Alexandrovich Kryukov 21-Jan-13 15:20pm
You are very welcome.
Thank you for your understanding.
Good luck, call again.
Sergey Alexandrovich Kryukov 22-Jan-13 17:16pm
Thanks for this notification, but I gave you the best advice I could before I saw it.
DinoRondelly 30-Jan-13 18:33pm
Sergey Alexandrovich Kryukov 30-Jan-13 18:47pm
Thank you, Dino.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

This error is very very easy to debug, you may define it somewhere in your whole project but not valid in the scope of the code you provided, just try to modify the definition of shapeChecker (use Search tool to find all references of it in your project). I guess you have defined a class called ShapeChecker which has some methods to check for some specified shapes.

You should also search for 'variable scope in C#' to know more thoroughly about scope in programming.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.161026.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100