Click here to Skip to main content
15,910,603 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I'm getting this error while trying to build a project, its part of a project looking at a webcam to find a AR symbol, watching 1 webcam, but now I want to watch 2 separate webcams, so instead of doubling the code I've tried to take the code out an call it but I get the following error.

"The name 'glyphValues' does not exist in the current context"

I had the code working with the existing code:

C#
if (confidence >= minConfidenceLevel)
{

    resMatching = CheckForMatching(Glyph_1, glyphValues);
            if (resMatching != -1)
            {
                this.Invoke(new MethodInvoker(delegate
                {
                    getidbox.Text = ("1");
                    checkdatabase();
                }));
            }


    // Debug.Print(System.Convert.ToString(confidence));
    ImgRes.Image = glyphImage.ToManagedImage();
    ImgRes2.Image = glyphImage.ToManagedImage();

}


but now i get the error when i do this:

C#
if (confidence >= minConfidenceLevel)
                        {

                            symbolslist();


                            // Debug.Print(System.Convert.ToString(confidence));
                            ImgRes.Image = glyphImage.ToManagedImage();
                            ImgRes2.Image = glyphImage.ToManagedImage();

                        }
                    }
                }
            }
            // *************************
            // Display result in window
            // *************************
            pictureBox1.Image = grayImage.ToManagedImage();
            GC.Collect();
        }

        public void symbolslist()
        {

            // NEW SYMBOLS
            resMatching = CheckForMatching(Glyph_1, glyphValues);
            if (resMatching != -1)
            {
                this.Invoke(new MethodInvoker(delegate
                {
                    getidbox.Text = ("1");
                    checkdatabase();
                }));
            }
}


Anyone?
Posted

I think the symbolslist method is in other context, so the glyphValues variable does not exist in it.

You should add as a parameter the glyphValues to the symbolslist method:
C#
public void symbolslist(byte[] glyphValues)
{
    // NEW SYMBOLS
    resMatching = CheckForMatching(Glyph_1, glyphValues);
    if (resMatching != -1)
    {
        this.Invoke(new MethodInvoker(delegate
        {
             getidbox.Text = ("1");
             checkdatabase();
        }));
    }
}


And now you can call the method:
C#
if (confidence >= minConfidenceLevel)
{
     symbolslist(glyphValues);

     // Debug.Print(System.Convert.ToString(confidence));
     ImgRes.Image = glyphImage.ToManagedImage();
     ImgRes2.Image = glyphImage.ToManagedImage();
}
 
Share this answer
 
v7
Comments
PeterHall 10-Sep-13 10:36am    
How would I go about that?
norbitrial 10-Sep-13 10:40am    
I've improved my solution. I don't know what the glyphValues's type is, but you can change to the original one.
PeterHall 10-Sep-13 10:48am    
i've just tried you solution, got some different errors e.g.

"The best overloaded method match for 'CTCAM3.MainForm.CheckForMatching(byte[*,*], byte[*,*])' has some invalid arguments"

and

"Argument 2: cannot convert from 'object' to 'byte[*,*]'"

any other ideas?
norbitrial 10-Sep-13 10:54am    
If the glyphValues variable is a byte array, it will work well. I've changed the head of your method: public void symbolslist(byte[] glyphValues)

Let me know if does not work.
Awesome! works like a dream.

Slight deviation, how would I be able to move this out of that file and into another.

E.g. Like a module.
 
Share this answer
 
Comments
Ron Beyer 10-Sep-13 11:25am    
You should post this as a comment to the above solution (not as a new solution). However, the concept of "modules" does not exist in C# (its a VB thing). In order to move it into its own "file" you can create a new class that holds this function. You could also declare the class that its currently in as "partial" but I really dislike doing that since it makes it difficult to maintain.
Sergey Alexandrovich Kryukov 10-Sep-13 12:42pm    
Also, the class could be partial, some parts on different files...
There are many cases (with appropriate coding style, of course) when it's not difficult to maintain, but, just the opposite, highly improve maintenance.
—SA

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