【发布时间】:2018-02-09 09:50:08
【问题描述】:
我在使用 Google Vision API 时遇到了问题。 我正在循环这个过程,分析几张图片,但是当我打印结果时,所有的过程都在 5 分钟后进入一个块,但我想知道是否可以启动程序并让它在之后打印结果每张图片分析?
这是我的算法代码:
bool space = false;
// var image = Google.Cloud.Vision.V1.Image.FromFile("C:\\temp\\sequence\\n" + i + ".jpg");
var image = Google.Cloud.Vision.V1.Image.FromFile(path);
var client = ImageAnnotatorClient.Create();
var response = client.DetectLabels(image);
CropHintsAnnotation confidence = client.DetectCropHints(image);
bool car = false;
bool vehicle = false;
bool land = false;
int score = 0;
//System.IO.Directory
foreach (var annotation in response)
{
textBox1.Text += annotation.Description + "\r\n";
textBox1.Text += "Score : " + annotation.Score + "\r\n";
vehicle = !annotation.Description.Equals("vehicle");
car = !annotation.Description.Equals("car");
land = !annotation.Description.Equals("land vehicle");
if (car == false)
{
score += 1;
//textBox1.Text += "\r\nEmpty ? " + car + "\r\n\r\n";
}
else if (vehicle == false)
{
score += 1;
//textBox1.Text += "\r\nEmpty ? " + vehicle + "\r\n\r\n";
}
else if (land == false)
{
score += 1;
//textBox1.Text += "\r\nEmpty ? " + land + "\r\n\r\n";
}
else if (annotation.Description.Equals("asphalt"))
{
score += -20;
//textBox1.Text += "\r\nEmpty ? True \r\n\r\n";
}
else
{
score += 0;
}
}
if ( score > 0)
{
//textBox1.Text += "The parking space is taken \r\n\r\n";
space = true;
}
else
{
//textBox1.Text += "The parking space is empty \r\n\r\n";
space = false;
}
return space;
我用 foreach(目录中的图像文件)循环这个。
有什么想法可以帮助我吗?
非常感谢!
【问题讨论】:
-
all is coming in a block after 5 minutes of process哪一行代码需要 5 分钟? -
如果我取消注释书写行,它是 TextBox1.text += annotation.Description;和打印分数的行,都在进程结束时打印
-
看起来好多了!已经接近我想要的了,但已经足够了,非常感谢!
标签: c# loops google-vision