在当前上下文中不存在 [英] does not exist in the current context

查看:100
本文介绍了在当前上下文中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我在尝试构建项目时遇到此错误,它是一个项目的一部分,正在查看网络摄像头以查找AR符号,观看1个网络摄像头,但现在我想要观看2个单独的网络摄像头,因此不要加倍代码我试图把代码拿出来调用它但是我得到以下错误。



当前上下文中不存在名称'glyphValues'



我的代码使用现有代码:



  if (置信度>  = minConfidenceLevel)
{

resMatching = CheckForMatching(Glyph_1,glyphValues);
if (resMatching!= -1)
{
this .Invoke( new MethodInvoker( delegate
{
getidbox.Text =(< span class =code-string> 1);
checkdatabase();
}));
}


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

}





但现在我收到错误时:



 如果(置信度>  = minConfidenceLevel)
{

symbolslist();


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

}
}
}
}
// *************************
// 在窗口中显示结果
// *************************
pictureBox1.Image = grayImage.ToManagedImage();
GC.Collect();
}

public void symbolslist()
{

// 新符号
resMatching = CheckForMatching(Glyph_1 ,glyphValues);
if (resMatching!= -1)
{
this .Invoke( new MethodInvoker( delegate
{
getidbox.Text =(< span class =code-string> 1);
checkdatabase();
}));
}
}





任何人?

解决方案

< blockquote>我认为symbolslist方法在其他上下文中,因此glyphValues变量不存在于其中。



您应该将glyphValues作为参数添加到symbolslist方法:

  public   void  symbolslist(< span class =code-keyword> byte  [] glyphValues)
{
// 新符号
resMatching = CheckForMatching(Glyph_1,glyphValues);
if (resMatching!= -1)
{
this .Invoke( new MethodInvoker( delegate
{
getidbox.Text =(< span class =code-string> 1);
checkdatabase();
}));
}
}





现在你可以拨打方法:

< pre lang =cs> if (置信度> = minConfidenceLevel)
{
symbolslist(glyphValues);

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


太棒了!像梦一样工作。



轻微的偏差,我怎么能把它从那个文件移到另一个文件中。



例如像模块一样。


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:

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:

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?

解决方案

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:

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:

if (confidence >= minConfidenceLevel)
{
     symbolslist(glyphValues);

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


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.


这篇关于在当前上下文中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆