Share via


RecognitionAlternate.GetPropertyValue Method

Returns the value of a specified RecognitionProperty of the RecognitionAlternate object.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Syntax

'Declaration
Public Function GetPropertyValue ( _
    g As Guid _
) As Byte()
'Usage
Dim instance As RecognitionAlternate 
Dim g As Guid 
Dim returnValue As Byte()

returnValue = instance.GetPropertyValue(g)
public byte[] GetPropertyValue(
    Guid g
)
public:
array<unsigned char>^ GetPropertyValue(
    Guid g
)
public function GetPropertyValue(
    g : Guid
) : byte[]

Parameters

  • g
    Type: System.Guid

    The property of the alternate to return, as a globally unique identifier (GUID) for one of the fields on the RecognitionProperty object.

Return Value

Type: array<System.Byte[]
Returns the value of the property type in the form of a byte array. The return value is interpreted differently for each property type.

Remarks

Use this method to obtain property values for RecognitionProperty objects that have no corresponding helper property on the RecognitionAlternate object. Helper properties on the RecognitionAlternate object include the Confidence and LineNumber properties.

The following table describes the type of value returned in the byte array.

RecognitionProperty Type

Description

ConfidenceLevel

RecognitionConfidence enumeration value

HotPoint

Point object

LineMetrics

Equivalent to the LATTICE_METRICS Structure structure

LineNumber

Int32 value

MaximumStrokeCount

Not used

PointsPerInch

Not used

Segmentation

Not used. Use the AlternatesWithConstantPropertyValues method instead.

To learn which Recognizer properties are exposed on alternate, first use the SupportedProperties property to see which properties are potentially available. These properties may or may not be passed on to the RecognitionAlternate. Then use GetPropertyValue to determine which properties are exposed on the RecognitionAlternate.

Note

Not all Recognizer properties are passed to the RecognitionAlternate object. For example, the Microsoft® gesture recognizer exposes HotPoint that can only be queried through the SupportedProperties property. The HotPoint property is not exposed on a RecognitionAlternate.

Examples

This C# example displays the baseline used in the recognition of a Strokes collection. The GetPropertyValue method gets the line metrics from the top alternate. Then the Renderer object attached to an InkOverlay, theInkOverlay, is used to convert the ink space coordinates to pixel coordinates. Lastly, the baseline is drawn in green. This example assumes that you have already checked the SupportedProperties property to make sure that the LineMetrics property is supported.

[C#]

using Microsoft.Ink;
using System.Drawing.Drawing2D;
using System.IO;
//...
    private void DrawBaseline(Strokes theStrokes)
    {
        // Get the top alternate for all the strokes
        RecognizerContext context = new RecognizerContext();
        context.Strokes = theStrokes;
        RecognitionStatus status = new RecognitionStatus();
        RecognitionResult result = context.Recognize(out status);
        RecognitionAlternate topAlternate = result.TopAlternate;

        // Get the line metrics from the top alternate
        byte [] byteArray = topAlternate.GetPropertyValue(RecognitionProperty.LineMetrics);
        using (MemoryStream stream = new MemoryStream(byteArray))
        using (BinaryReader reader = new BinaryReader(stream))
        {
            int startX = reader.ReadInt32();
            int startY = reader.ReadInt32();
            int endX = reader.ReadInt32();
            int endY = reader.ReadInt32();

            // Convert baseline to pixel coordinates
            Graphics tempGraphics = CreateGraphics();
            Point startPoint = new Point(startX, startY);
            Point endPoint = new Point(endX, endY);
            theInkOverlay.Renderer.InkSpaceToPixel(tempGraphics, ref startPoint);
            theInkOverlay.Renderer.InkSpaceToPixel(tempGraphics, ref endPoint);
            tempGraphics.DrawLine(new Pen(Color.Green), startPoint, endPoint);

            // Dispose of temporary graphics
            tempGraphics.Dispose();
        }
    }

This Microsoft Visual Basic® .NET example displays the baseline used in the recognition of a Strokes collection. The GetPropertyValue method gets the line metrics from the top alternate. Then the Renderer object attached to an InkOverlay, theInkOverlay, is used to convert the ink space coordinates to pixel coordinates. Lastly, the baseline is drawn in green. This example assumes that you have already checked the SupportedProperties property to make sure that the LineMetrics property is supported.

[Visual Basic]

Imports Microsoft.Ink
Imports System.Drawing.Drawing2D
Imports System.IO
'...
    Private Sub DrawBaseline(ByVal theStrokes As Strokes)
        ' Get the top alternate for all the strokes
        Dim context As New RecognizerContext()
        context.Strokes = theStrokes
        Dim status As New RecognitionStatus()
        Dim result As RecognitionResult = context.Recognize(status)
        Dim topAlternate As RecognitionAlternate = result.TopAlternate

        ' Get the line metrics from the top alternate
        Dim byteArray() As Byte = topAlternate.GetPropertyValue(RecognitionProperty.LineMetrics)
        Dim stream As New MemoryStream(byteArray)
        Dim reader As New BinaryReader(stream)

        Dim startX As Integer = reader.ReadInt32()
        Dim startY As Integer = reader.ReadInt32()
        Dim endX As Integer = reader.ReadInt32()
        Dim endY As Integer = reader.ReadInt32()

        ' Convert baseline to pixel coordinates
        Dim tempGraphics As Graphics = CreateGraphics()
        Dim startPoint As New Point(startX, startY)
        Dim endPoint As New Point(endX, endY)
        theInkOverlay.Renderer.InkSpaceToPixel(tempGraphics, startPoint)
        theInkOverlay.Renderer.InkSpaceToPixel(tempGraphics, endPoint)
        tempGraphics.DrawLine(New Pen(Color.Green), startPoint, endPoint)

        ' Clean up
        tempGraphics.Dispose()
        reader.Close()
        stream.Close()
    End Sub

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

RecognitionAlternate Class

RecognitionAlternate Members

Microsoft.Ink Namespace

RecognitionAlternate.AlternatesWithConstantPropertyValues

RecognitionProperty