【发布时间】:2017-06-23 09:47:56
【问题描述】:
让我把问题暴露给你:
我目前正在 Visual Studio Community 2017 版上进行开发。 我制作了一个使用 Google API 分析图像内容的 Windows 窗体。我设法使它适用于一张单张图片,所以过程是: 我启动程序,出现 Windows,按下“分析图像”按钮,然后在 TextBox 中打印标签检测的结果。
这部分效果很好。
但是现在,我想分析一个文件的所有图像,所以我从 5 个图像开始,只是为了尝试。 所以我做了一个foreach循环,并用“1.jpg”、“2.jpg”等重命名了我的图片……直到“5.jpg”。 这是代码:
private void Button1_Click(object sender, EventArgs e)
{
textBox1.Text = "";
for (int i = 1; i < 6; i++)
{
int number = i;
textBox1.Text = "Image number : " + number + "\r\n";
var image = Google.Cloud.Vision.V1.Image.FromFile("C:\\temp\\sequence\\" + number + ".jpg");
var client = ImageAnnotatorClient.Create();
var response = client.DetectLabels(image);
foreach (var annotation in response)
{
textBox1.Text += annotation.Description + "\r\n";
}
textBox1.Text = "Next image processing.... \r\n";
}
}
当我按下“分析按钮”( Button1 )时,程序会打印 “图 1:” 然后我必须等待几秒钟,然后它会打印“下一个图像处理...”,它再也不会打印任何东西了。
所以有什么想法吗? 是不是因为我必须清除 TextBox 才能在其中重新写入?
有人知道我的问题吗? :(
提前感谢您的帮助!
【问题讨论】:
标签: c# visual-studio-2017 google-cloud-vision