Click here to Skip to main content
Rate this: bad
good
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();
            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 19-Jan-13 9:41am
Edited 30-Jan-13 9:16am
v7
Rate this: bad
good
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.
 
—SA
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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 at 21-Jan-13 15:20pm
   
You are very welcome.
Thank you for your understanding.
Good luck, call again.
—SA
Sergey Alexandrovich Kryukov at 22-Jan-13 17:16pm
   
Thanks for this notification, but I gave you the best advice I could before I saw it.
—SA
DinoRondelly at 30-Jan-13 18:33pm
   
+5
Sergey Alexandrovich Kryukov at 30-Jan-13 18:47pm
   
Thank you, Dino.
—SA
Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 6,649
1 Sergey Alexandrovich Kryukov 6,270
2 CPallini 5,190
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2014
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