我不能让它适用于vb [英] I can't make it works with vb
问题描述
我尝试使用vb.net进行面部检测。
我这样做:
Const APIKEY As String =" my api密钥QUOT;
Dim faceservice As New FaceServiceClient(APIKEY)
[...]
然后我得到了我的文件路径进入'filelist'var。
然后我调用:
私有异步函数run()As Task
For i = 1 to filelist.Count - 1
使用imageFileStream As System.IO.FileStream = IO.File.OpenRead(filelist(i - 1))
Dim faces1 = Await faceservice.DetectAsync(imageFileStream)
Dim faceid1 = faces1(0).FaceId
结束使用
使用imageFileStream2 As System.IO.FileStream = IO.File.OpenRead(filelist(i))
Dim faces2 = Await faceservice.DetectAsync(imageFileStream2)
Dim faceid2 = faces2(0).FaceId
结束使用
下一个
结束功能
但是调用不返回任何面(faces1和face2什么都不是)并且没有错误发生。
任何人都可以帮助我吗? :)
(抱歉,英语不是我的母语)
编辑:我添加了对ClientLibrary的引用,而不是我在c#sdk中找到的,我添加了这个:
Imports Microsoft.ProjectOxford .Face
Imports Microsoft.ProjectOxford.Face.Contract
当你使用face SDK时,你可以通过catch'ClientException'来获取错误。
如下所示:
           试试
{
await faceserviceClient。 DetectAsync ( imageFileStream );
  }
catch(ClientException ex)
{
Console.WriteLine(ex.Error.Code);
Console.WriteLine(ex.Error.Message);
}
Hi,
I try to make face detection works with vb.net.
I make it like this :
Const APIKEY As String = "my api key" Dim faceservice As New FaceServiceClient(APIKEY)
[...]
Then i get my file paths into 'filelist' var.
then i call :
Private Async Function run() As Task For i = 1 To filelist.Count - 1 Using imageFileStream As System.IO.FileStream = IO.File.OpenRead(filelist(i - 1)) Dim faces1 = Await faceservice.DetectAsync(imageFileStream) Dim faceid1 = faces1(0).FaceId End Using Using imageFileStream2 As System.IO.FileStream = IO.File.OpenRead(filelist(i)) Dim faces2 = Await faceservice.DetectAsync(imageFileStream2) Dim faceid2 = faces2(0).FaceId End Using Next End Function
But the call doesn't return any faces (faces1 and face2 are nothing) and no errors occurs.
Can anyone please help me ? :)
(sorry, english is not my mother language)
edit : i added a reference to ClientLibrary than i found into c# sdk and i added this :
Imports Microsoft.ProjectOxford.Face Imports Microsoft.ProjectOxford.Face.Contract
when you use face SDK, you can get errors by catch 'ClientException'.
like below:
try
{
await faceserviceClient.DetectAsync(imageFileStream);
}
catch(ClientException ex)
{
Console.WriteLine(ex.Error.Code);
Console.WriteLine(ex.Error.Message);
}
这篇关于我不能让它适用于vb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!