RecognitionResult.TopConfidence 屬性
取得 RecognitionResult 物件之 TopAlternate 屬性的信賴等級。
命名空間: Microsoft.Ink
組件: Microsoft.Ink (在 Microsoft.Ink.dll 中)
語法
'宣告
Public ReadOnly Property TopConfidence As RecognitionConfidence
'用途
Dim instance As RecognitionResult
Dim value As RecognitionConfidence
value = instance.TopConfidence
public RecognitionConfidence TopConfidence { get; }
public:
property RecognitionConfidence TopConfidence {
RecognitionConfidence get ();
}
/** @property */
public RecognitionConfidence get_TopConfidence()
public function get TopConfidence () : RecognitionConfidence
屬性值
型別:Microsoft.Ink.RecognitionConfidence
RecognitionResult 物件之 TopAlternate 屬性的信賴等級。
備註
Microsoft® 的「辨識器」中,只有 Microsoft 英文 (美國) 手寫辨識器和 Microsoft 筆勢辨識器支援信賴等級。協力廠商辨識器不一定支援信賴等級。
範例
在這個範例中,會處理同步辨識以回應使用者動作,例如按一下功能表項目或按鈕。首先,會從與 InkOverlay 物件相關聯的 Strokes 集合指派 RecognizerContext 物件的 Strokes 集合,並檢查筆劃計數。如果 Strokes 集合包含至少一個 Stroke 物件,則辨識程序會先呼叫 Recognize 方法。如果辨識成功,而且 TopConfidence (如果支援的話) 不等於 RecognitionConfidencePoor (亦即,它是 Intermediate 或 Strong),則會將 TopString 加入至清單方塊以便顯示。
' assign strokes collection from the collected strokes
Me.mRecognizerContext.Strokes = Me.mInkOverlay.Ink.Strokes
' check stroke count. Recognize() will throw exception if no strokes
If (Me.mRecognizerContext.Strokes.Count > 0) Then
Dim status As RecognitionStatus
' perform the recognition
Dim rResult As RecognitionResult = Me.mRecognizerContext.Recognize(status)
' see if the recognizer used supports confidence levels
Dim rSupportsConfidence As Boolean = RecognizerSupportsConfidence(mRecognizerContext.Recognizer)
' check status and TopConfidence (if supported)
If (RecognitionStatus.NoError = status And _
((rSupportsConfidence And _
rResult.TopConfidence <> RecognitionConfidence.Poor) Or _
Not rSupportsConfidence)) Then
listBoxRecognitionResults.Items.Add(rResult.TopString)
End If
End If
// assign strokes collection from the collected strokes
this.mRecognizerContext.Strokes = this.mInkOverlay.Ink.Strokes;
// check stroke count. Recognize() will throw exception if no strokes
if (this.mRecognizerContext.Strokes.Count > 0)
{
RecognitionStatus status;
// perform the recognition
RecognitionResult rResult = this.mRecognizerContext.Recognize(out status);
// see if the recognizer used supports confidence levels
bool rSupportsConfidence = RecognizerSupportsConfidence(mRecognizerContext.Recognizer);
// check status and TopConfidence (if supported)
if (RecognitionStatus.NoError == status &&
((rSupportsConfidence &&
rResult.TopConfidence != RecognitionConfidence.Poor) ||
!rSupportsConfidence))
{
listBoxRecognitionResults.Items.Add(rResult.TopString);
}
}
下列範例說明 Helper 方法,這個方法可用來判斷 Recognizer 是否支援信賴等級。
Private Function RecognizerSupportsConfidence(ByVal pRecognizer As Recognizer) As Boolean
For Each G As Guid In pRecognizer.SupportedProperties
If G = RecognitionProperty.ConfidenceLevel Then
Return True
End If
Next
Return False
End Function
private bool RecognizerSupportsConfidence(Recognizer pRecognizer)
{
foreach (Guid G in pRecognizer.SupportedProperties)
{
if (G == RecognitionProperty.ConfidenceLevel)
{
return true;
}
}
return false;
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0