Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi I've faced an error with the following code !
C#
private void check_Click(object sender, EventArgs e)
        {
            // locate objects using blob counter
            BlobCounter blobCounter = new BlobCounter();
            blobCounter.ProcessImage((Bitmap)PictureBox1.Image);
            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))
                {
                    g.DrawEllipse(redPen,
                        (int)(center.X - radius),
                        (int)(center.Y - radius),
                        (int)(radius * 2),
                        (int)(radius * 2));
                }
            }

            redPen.Dispose();
            g.Dispose();
        }

The Error :: (( The name 'shapeChecker' does not exist in the current context )) Can any one tell me how to fix it ?
Posted
Updated 30-Jan-13 9:16am
v7

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.

—SA
 
Share this answer
 
Comments
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,
—SA
Sergey Alexandrovich Kryukov 21-Jan-13 15:20pm    
You are very welcome.
Thank you for your understanding.
Good luck, call again.
—SA
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.
—SA
DinoRondelly 30-Jan-13 18:33pm    
+5
Sergey Alexandrovich Kryukov 30-Jan-13 18:47pm    
Thank you, Dino.
—SA
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900